From 551903c32ec60ed944c51145265098d8a40f7d51 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Mon, 6 Feb 2017 01:14:03 -0500 Subject: [PATCH 1/2] add parameter & return type hints to the Arr class --- src/Illuminate/Support/Arr.php | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Illuminate/Support/Arr.php b/src/Illuminate/Support/Arr.php index f24de4f4721b..27652726c1df 100755 --- a/src/Illuminate/Support/Arr.php +++ b/src/Illuminate/Support/Arr.php @@ -15,7 +15,7 @@ class Arr * @param mixed $value * @return bool */ - public static function accessible($value) + public static function accessible($value) : bool { return is_array($value) || $value instanceof ArrayAccess; } @@ -28,7 +28,7 @@ public static function accessible($value) * @param mixed $value * @return array */ - public static function add($array, $key, $value) + public static function add(array $array, string $key, $value) : array { if (is_null(static::get($array, $key))) { static::set($array, $key, $value); @@ -43,7 +43,7 @@ public static function add($array, $key, $value) * @param array $array * @return array */ - public static function collapse($array) + public static function collapse(array $array) : array { $results = []; @@ -66,7 +66,7 @@ public static function collapse($array) * @param array $array * @return array */ - public static function divide($array) + public static function divide(array $array) : array { return [array_keys($array), array_values($array)]; } @@ -78,7 +78,7 @@ public static function divide($array) * @param string $prepend * @return array */ - public static function dot($array, $prepend = '') + public static function dot(array $array, string $prepend = '') : array { $results = []; @@ -100,7 +100,7 @@ public static function dot($array, $prepend = '') * @param array|string $keys * @return array */ - public static function except($array, $keys) + public static function except(array $array, $keys) : array { static::forget($array, $keys); @@ -114,7 +114,7 @@ public static function except($array, $keys) * @param string|int $key * @return bool */ - public static function exists($array, $key) + public static function exists($array, $key) : bool { if ($array instanceof ArrayAccess) { return $array->offsetExists($key); @@ -176,7 +176,7 @@ public static function last($array, callable $callback = null, $default = null) * @param int $depth * @return array */ - public static function flatten($array, $depth = INF) + public static function flatten(array $array, $depth = INF) : array { return array_reduce($array, function ($result, $item) use ($depth) { $item = $item instanceof Collection ? $item->all() : $item; @@ -198,7 +198,7 @@ public static function flatten($array, $depth = INF) * @param array|string $keys * @return void */ - public static function forget(&$array, $keys) + public static function forget(array &$array, $keys) : void { $original = &$array; @@ -275,7 +275,7 @@ public static function get($array, $key, $default = null) * @param string|array $keys * @return bool */ - public static function has($array, $keys) + public static function has($array, $keys) : bool { if (is_null($keys)) { return false; @@ -318,7 +318,7 @@ public static function has($array, $keys) * @param array $array * @return bool */ - public static function isAssoc(array $array) + public static function isAssoc(array $array) : bool { $keys = array_keys($array); @@ -332,7 +332,7 @@ public static function isAssoc(array $array) * @param array|string $keys * @return array */ - public static function only($array, $keys) + public static function only(array $array, $keys) : array { return array_intersect_key($array, array_flip((array) $keys)); } @@ -345,7 +345,7 @@ public static function only($array, $keys) * @param string|array|null $key * @return array */ - public static function pluck($array, $value, $key = null) + public static function pluck(array $array, $value, $key = null) : array { $results = []; @@ -376,7 +376,7 @@ public static function pluck($array, $value, $key = null) * @param string|array|null $key * @return array */ - protected static function explodePluckParameters($value, $key) + protected static function explodePluckParameters($value, $key) : array { $value = is_string($value) ? explode('.', $value) : $value; @@ -393,7 +393,7 @@ protected static function explodePluckParameters($value, $key) * @param mixed $key * @return array */ - public static function prepend($array, $value, $key = null) + public static function prepend(array $array, $value, $key = null) : array { if (is_null($key)) { array_unshift($array, $value); @@ -412,7 +412,7 @@ public static function prepend($array, $value, $key = null) * @param mixed $default * @return mixed */ - public static function pull(&$array, $key, $default = null) + public static function pull(array &$array, string $key, $default = null) { $value = static::get($array, $key, $default); @@ -431,7 +431,7 @@ public static function pull(&$array, $key, $default = null) * @param mixed $value * @return array */ - public static function set(&$array, $key, $value) + public static function set(array &$array, $key, $value) : array { if (is_null($key)) { return $array = $value; @@ -463,7 +463,7 @@ public static function set(&$array, $key, $value) * @param array $array * @return array */ - public static function shuffle($array) + public static function shuffle(array $array) : array { shuffle($array); @@ -477,7 +477,7 @@ public static function shuffle($array) * @param callable|string $callback * @return array */ - public static function sort($array, $callback) + public static function sort(array $array, $callback) : array { return Collection::make($array)->sortBy($callback)->all(); } @@ -488,7 +488,7 @@ public static function sort($array, $callback) * @param array $array * @return array */ - public static function sortRecursive($array) + public static function sortRecursive(array $array) : array { foreach ($array as &$value) { if (is_array($value)) { @@ -512,7 +512,7 @@ public static function sortRecursive($array) * @param callable $callback * @return array */ - public static function where($array, callable $callback) + public static function where(array $array, callable $callback) : array { return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH); } From f68fa01f8b9e189a49edf99a16c55d441018daf5 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Mon, 6 Feb 2017 01:22:37 -0500 Subject: [PATCH 2/2] remove void, thats php >= 7.1 :( --- src/Illuminate/Support/Arr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Arr.php b/src/Illuminate/Support/Arr.php index 27652726c1df..ec65c671a83e 100755 --- a/src/Illuminate/Support/Arr.php +++ b/src/Illuminate/Support/Arr.php @@ -198,7 +198,7 @@ public static function flatten(array $array, $depth = INF) : array * @param array|string $keys * @return void */ - public static function forget(array &$array, $keys) : void + public static function forget(array &$array, $keys) { $original = &$array;