Miscellaneous updates

This commit is contained in:
Timothy Warren 2017-01-10 15:49:14 -05:00
parent 2eeb15d37b
commit 71fdab33f3
4 changed files with 19 additions and 6 deletions

View File

@ -39,8 +39,14 @@
"predis/predis": "1.1.*", "predis/predis": "1.1.*",
"squizlabs/php_codesniffer": "^3.0.0@RC" "squizlabs/php_codesniffer": "^3.0.0@RC"
}, },
"scripts": {
"coverage": "vendor/bin/phpunit -c build",
"build": "vendor/bin/robo build",
"docs": "cd build && ../vendor/bin/phpdox && cd ..",
"test": "vendor/bin/phpunit"
},
"suggest": { "suggest": {
"monolog/monolog": "Provides implementation of psr/log", "monolog/monolog": "Provides implementation of psr/log",
"predis/predis": "Required for redis cache driver" "predis/predis": "Required for redis cache driver"
} }
} }

View File

@ -31,7 +31,7 @@ class Json {
* @param int $depth * @param int $depth
* @return string * @return string
*/ */
public static function encode($data, $options = 0, $depth = 512) public static function encode($data, $options = 0, $depth = 512): string
{ {
$json = json_encode($data, $options, $depth); $json = json_encode($data, $options, $depth);
self::check_json_error(); self::check_json_error();

View File

@ -88,7 +88,7 @@ class ArrayType {
* @param string $method * @param string $method
* @param array $args * @param array $args
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function __call(string $method, array $args) public function __call(string $method, array $args)
{ {
@ -97,8 +97,7 @@ class ArrayType {
{ {
$func = $this->nativeMethods[$method]; $func = $this->nativeMethods[$method];
// Set the current array as the first argument of the method // Set the current array as the first argument of the method
array_unshift($args, $this->arr); return call_user_func($func, $this->arr, ...$args);
return call_user_func_array($func, $args);
} }
// Mapping for in-place methods // Mapping for in-place methods
@ -211,7 +210,10 @@ class ArrayType {
/** /**
* Return a reference to the value of an arbitrary key on the array * Return a reference to the value of an arbitrary key on the array
* *
* @param array $key * @example $arr = new ArrayType([0 => ['data' => ['foo' => 'bar']]]);
* $val = $arr->getDeepKey([0, 'data', 'foo']);
* // returns 'bar'
* @param array $key An array of keys of the array
* @return mixed * @return mixed
*/ */
public function &getDeepKey(array $key) public function &getDeepKey(array $key)

View File

@ -65,4 +65,9 @@ class JsonTest extends Ion_TestCase {
Json::decode($badJson); Json::decode($badJson);
} }
public function testDecodeNull()
{
$this->assertNull(Json::decode(NULL));
}
} }