@@ -65,6 +65,7 @@ discard block |
||
| 65 | 65 | * Cross join the given arrays, returning all possible permutations. |
| 66 | 66 | * |
| 67 | 67 | * @param iterable ...$arrays |
| 68 | + * @param iterable[] $arrays |
|
| 68 | 69 | * @return array |
| 69 | 70 | */ |
| 70 | 71 | public static function crossJoin(...$arrays) |
@@ -275,7 +276,7 @@ discard block |
||
| 275 | 276 | * Get an item from an array using "dot" notation. |
| 276 | 277 | * |
| 277 | 278 | * @param \ArrayAccess|array $array |
| 278 | - * @param string|int|null $key |
|
| 279 | + * @param string $key |
|
| 279 | 280 | * @param mixed $default |
| 280 | 281 | * @return mixed |
| 281 | 282 | */ |
@@ -406,7 +407,7 @@ discard block |
||
| 406 | 407 | * |
| 407 | 408 | * @param iterable $array |
| 408 | 409 | * @param string|array $value |
| 409 | - * @param string|array|null $key |
|
| 410 | + * @param string|null $key |
|
| 410 | 411 | * @return array |
| 411 | 412 | */ |
| 412 | 413 | public static function pluck($array, $value, $key = null) |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | foreach ($array as $values) { |
| 52 | 52 | if ($values instanceof Collection) { |
| 53 | 53 | $values = $values->all(); |
| 54 | - } elseif (! is_array($values)) { |
|
| 54 | + } elseif (!is_array($values)) { |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $results = []; |
| 112 | 112 | |
| 113 | 113 | foreach ($array as $key => $value) { |
| 114 | - if (is_array($value) && ! empty($value)) { |
|
| 114 | + if (is_array($value) && !empty($value)) { |
|
| 115 | 115 | $results = array_merge($results, static::dot($value, $prepend.$key.'.')); |
| 116 | 116 | } else { |
| 117 | 117 | $results[$prepend.$key] = $value; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | foreach ($array as $item) { |
| 212 | 212 | $item = $item instanceof Collection ? $item->all() : $item; |
| 213 | 213 | |
| 214 | - if (! is_array($item)) { |
|
| 214 | + if (!is_array($item)) { |
|
| 215 | 215 | $result[] = $item; |
| 216 | 216 | } else { |
| 217 | 217 | $values = $depth === 1 |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public static function get($array, $key, $default = null) |
| 283 | 283 | { |
| 284 | - if (! static::accessible($array)) { |
|
| 284 | + if (!static::accessible($array)) { |
|
| 285 | 285 | return value($default); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | $keys = (array) $keys; |
| 321 | 321 | |
| 322 | - if (! $array || $keys === []) { |
|
| 322 | + if (!$array || $keys === []) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $keys = (array) $keys; |
| 359 | 359 | |
| 360 | - if (! $array) { |
|
| 360 | + if (!$array) { |
|
| 361 | 361 | return false; |
| 362 | 362 | } |
| 363 | 363 | |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | // If the key doesn't exist at this depth, we will just create an empty array |
| 554 | 554 | // to hold the next value, allowing us to create the arrays to hold final |
| 555 | 555 | // values at the correct depth. Then we'll keep digging into the array. |
| 556 | - if (! isset($array[$key]) || ! is_array($array[$key])) { |
|
| 556 | + if (!isset($array[$key]) || !is_array($array[$key])) { |
|
| 557 | 557 | $array[$key] = []; |
| 558 | 558 | } |
| 559 | 559 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return new static; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $instance = new static(function () use ($number) { |
|
| 63 | + $instance = new static(function() use ($number) { |
|
| 64 | 64 | for ($current = 1; $current <= $number; $current++) { |
| 65 | 65 | yield $current; |
| 66 | 66 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public static function range($from, $to) |
| 80 | 80 | { |
| 81 | - return new static(function () use ($from, $to) { |
|
| 81 | + return new static(function() use ($from, $to) { |
|
| 82 | 82 | for (; $from <= $to; $from++) { |
| 83 | 83 | yield $from; |
| 84 | 84 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $cache = []; |
| 124 | 124 | |
| 125 | - return new static(function () use ($iterator, &$iteratorIndex, &$cache) { |
|
| 125 | + return new static(function() use ($iterator, &$iteratorIndex, &$cache) { |
|
| 126 | 126 | for ($index = 0; true; $index++) { |
| 127 | 127 | if (array_key_exists($index, $cache)) { |
| 128 | 128 | yield $cache[$index][0] => $cache[$index][1]; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $iteratorIndex++; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if (! $iterator->valid()) { |
|
| 139 | + if (!$iterator->valid()) { |
|
| 140 | 140 | break; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function collapse() |
| 189 | 189 | { |
| 190 | - return new static(function () { |
|
| 190 | + return new static(function() { |
|
| 191 | 191 | foreach ($this as $values) { |
| 192 | 192 | if (is_array($values) || $values instanceof Enumerable) { |
| 193 | 193 | foreach ($values as $value) { |
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | public function filter(callable $callback = null) |
| 353 | 353 | { |
| 354 | 354 | if (is_null($callback)) { |
| 355 | - $callback = function ($value) { |
|
| 355 | + $callback = function($value) { |
|
| 356 | 356 | return (bool) $value; |
| 357 | 357 | }; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - return new static(function () use ($callback) { |
|
| 360 | + return new static(function() use ($callback) { |
|
| 361 | 361 | foreach ($this as $key => $value) { |
| 362 | 362 | if ($callback($value, $key)) { |
| 363 | 363 | yield $key => $value; |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $iterator = $this->getIterator(); |
| 379 | 379 | |
| 380 | 380 | if (is_null($callback)) { |
| 381 | - if (! $iterator->valid()) { |
|
| 381 | + if (!$iterator->valid()) { |
|
| 382 | 382 | return value($default); |
| 383 | 383 | } |
| 384 | 384 | |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | public function flatten($depth = INF) |
| 404 | 404 | { |
| 405 | - $instance = new static(function () use ($depth) { |
|
| 405 | + $instance = new static(function() use ($depth) { |
|
| 406 | 406 | foreach ($this as $item) { |
| 407 | - if (! is_array($item) && ! $item instanceof Enumerable) { |
|
| 407 | + if (!is_array($item) && !$item instanceof Enumerable) { |
|
| 408 | 408 | yield $item; |
| 409 | 409 | } elseif ($depth === 1) { |
| 410 | 410 | yield from $item; |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function flip() |
| 426 | 426 | { |
| 427 | - return new static(function () { |
|
| 427 | + return new static(function() { |
|
| 428 | 428 | foreach ($this as $key => $value) { |
| 429 | 429 | yield $value => $key; |
| 430 | 430 | } |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | */ |
| 474 | 474 | public function keyBy($keyBy) |
| 475 | 475 | { |
| 476 | - return new static(function () use ($keyBy) { |
|
| 476 | + return new static(function() use ($keyBy) { |
|
| 477 | 477 | $keyBy = $this->valueRetriever($keyBy); |
| 478 | 478 | |
| 479 | 479 | foreach ($this as $key => $item) { |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | */ |
| 550 | 550 | public function isEmpty() |
| 551 | 551 | { |
| 552 | - return ! $this->getIterator()->valid(); |
|
| 552 | + return !$this->getIterator()->valid(); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | /** |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | */ |
| 572 | 572 | public function keys() |
| 573 | 573 | { |
| 574 | - return new static(function () { |
|
| 574 | + return new static(function() { |
|
| 575 | 575 | foreach ($this as $key => $value) { |
| 576 | 576 | yield $key; |
| 577 | 577 | } |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | */ |
| 608 | 608 | public function pluck($value, $key = null) |
| 609 | 609 | { |
| 610 | - return new static(function () use ($value, $key) { |
|
| 610 | + return new static(function() use ($value, $key) { |
|
| 611 | 611 | [$value, $key] = $this->explodePluckParameters($value, $key); |
| 612 | 612 | |
| 613 | 613 | foreach ($this as $item) { |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | */ |
| 637 | 637 | public function map(callable $callback) |
| 638 | 638 | { |
| 639 | - return new static(function () use ($callback) { |
|
| 639 | + return new static(function() use ($callback) { |
|
| 640 | 640 | foreach ($this as $key => $value) { |
| 641 | 641 | yield $key => $callback($value, $key); |
| 642 | 642 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | */ |
| 667 | 667 | public function mapWithKeys(callable $callback) |
| 668 | 668 | { |
| 669 | - return new static(function () use ($callback) { |
|
| 669 | + return new static(function() use ($callback) { |
|
| 670 | 670 | foreach ($this as $key => $value) { |
| 671 | 671 | yield from $callback($value, $key); |
| 672 | 672 | } |
@@ -703,13 +703,13 @@ discard block |
||
| 703 | 703 | */ |
| 704 | 704 | public function combine($values) |
| 705 | 705 | { |
| 706 | - return new static(function () use ($values) { |
|
| 706 | + return new static(function() use ($values) { |
|
| 707 | 707 | $values = $this->makeIterator($values); |
| 708 | 708 | |
| 709 | 709 | $errorMessage = 'Both parameters should have an equal number of elements'; |
| 710 | 710 | |
| 711 | 711 | foreach ($this as $key) { |
| 712 | - if (! $values->valid()) { |
|
| 712 | + if (!$values->valid()) { |
|
| 713 | 713 | trigger_error($errorMessage, E_USER_WARNING); |
| 714 | 714 | |
| 715 | 715 | break; |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | */ |
| 747 | 747 | public function nth($step, $offset = 0) |
| 748 | 748 | { |
| 749 | - return new static(function () use ($step, $offset) { |
|
| 749 | + return new static(function() use ($step, $offset) { |
|
| 750 | 750 | $position = 0; |
| 751 | 751 | |
| 752 | 752 | foreach ($this as $item) { |
@@ -769,11 +769,11 @@ discard block |
||
| 769 | 769 | { |
| 770 | 770 | if ($keys instanceof Enumerable) { |
| 771 | 771 | $keys = $keys->all(); |
| 772 | - } elseif (! is_null($keys)) { |
|
| 772 | + } elseif (!is_null($keys)) { |
|
| 773 | 773 | $keys = is_array($keys) ? $keys : func_get_args(); |
| 774 | 774 | } |
| 775 | 775 | |
| 776 | - return new static(function () use ($keys) { |
|
| 776 | + return new static(function() use ($keys) { |
|
| 777 | 777 | if (is_null($keys)) { |
| 778 | 778 | yield from $this; |
| 779 | 779 | } else { |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | */ |
| 803 | 803 | public function concat($source) |
| 804 | 804 | { |
| 805 | - return (new static(function () use ($source) { |
|
| 805 | + return (new static(function() use ($source) { |
|
| 806 | 806 | yield from $this; |
| 807 | 807 | yield from $source; |
| 808 | 808 | }))->values(); |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | public function replace($items) |
| 851 | 851 | { |
| 852 | - return new static(function () use ($items) { |
|
| 852 | + return new static(function() use ($items) { |
|
| 853 | 853 | $items = $this->getArrayableItems($items); |
| 854 | 854 | |
| 855 | 855 | foreach ($this as $key => $value) { |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | { |
| 901 | 901 | $predicate = $this->useAsCallable($value) |
| 902 | 902 | ? $value |
| 903 | - : function ($item) use ($value, $strict) { |
|
| 903 | + : function($item) use ($value, $strict) { |
|
| 904 | 904 | return $strict ? $item === $value : $item == $value; |
| 905 | 905 | }; |
| 906 | 906 | |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | */ |
| 933 | 933 | public function skip($count) |
| 934 | 934 | { |
| 935 | - return new static(function () use ($count) { |
|
| 935 | + return new static(function() use ($count) { |
|
| 936 | 936 | $iterator = $this->getIterator(); |
| 937 | 937 | |
| 938 | 938 | while ($iterator->valid() && $count--) { |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | return static::empty(); |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - return new static(function () use ($size) { |
|
| 991 | + return new static(function() use ($size) { |
|
| 992 | 992 | $iterator = $this->getIterator(); |
| 993 | 993 | |
| 994 | 994 | while ($iterator->valid()) { |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | if (count($chunk) < $size) { |
| 1001 | 1001 | $iterator->next(); |
| 1002 | 1002 | |
| 1003 | - if (! $iterator->valid()) { |
|
| 1003 | + if (!$iterator->valid()) { |
|
| 1004 | 1004 | break; |
| 1005 | 1005 | } |
| 1006 | 1006 | } else { |
@@ -1097,11 +1097,11 @@ discard block |
||
| 1097 | 1097 | return $this->passthru('take', func_get_args()); |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - return new static(function () use ($limit) { |
|
| 1100 | + return new static(function() use ($limit) { |
|
| 1101 | 1101 | $iterator = $this->getIterator(); |
| 1102 | 1102 | |
| 1103 | 1103 | while ($limit--) { |
| 1104 | - if (! $iterator->valid()) { |
|
| 1104 | + if (!$iterator->valid()) { |
|
| 1105 | 1105 | break; |
| 1106 | 1106 | } |
| 1107 | 1107 | |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | */ |
| 1123 | 1123 | public function tapEach(callable $callback) |
| 1124 | 1124 | { |
| 1125 | - return new static(function () use ($callback) { |
|
| 1125 | + return new static(function() use ($callback) { |
|
| 1126 | 1126 | foreach ($this as $key => $value) { |
| 1127 | 1127 | $callback($value, $key); |
| 1128 | 1128 | |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | */ |
| 1139 | 1139 | public function values() |
| 1140 | 1140 | { |
| 1141 | - return new static(function () { |
|
| 1141 | + return new static(function() { |
|
| 1142 | 1142 | foreach ($this as $item) { |
| 1143 | 1143 | yield $item; |
| 1144 | 1144 | } |
@@ -1158,8 +1158,8 @@ discard block |
||
| 1158 | 1158 | { |
| 1159 | 1159 | $iterables = func_get_args(); |
| 1160 | 1160 | |
| 1161 | - return new static(function () use ($iterables) { |
|
| 1162 | - $iterators = Collection::make($iterables)->map(function ($iterable) { |
|
| 1161 | + return new static(function() use ($iterables) { |
|
| 1162 | + $iterators = Collection::make($iterables)->map(function($iterable) { |
|
| 1163 | 1163 | return $this->makeIterator($iterable); |
| 1164 | 1164 | })->prepend($this->getIterator()); |
| 1165 | 1165 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | return $this->passthru('pad', func_get_args()); |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - return new static(function () use ($size, $value) { |
|
| 1187 | + return new static(function() use ($size, $value) { |
|
| 1188 | 1188 | $yielded = 0; |
| 1189 | 1189 | |
| 1190 | 1190 | foreach ($this as $index => $item) { |
@@ -1267,7 +1267,7 @@ discard block |
||
| 1267 | 1267 | */ |
| 1268 | 1268 | protected function passthru($method, array $params) |
| 1269 | 1269 | { |
| 1270 | - return new static(function () use ($method, $params) { |
|
| 1270 | + return new static(function() use ($method, $params) { |
|
| 1271 | 1271 | yield from $this->collect()->$method(...$params); |
| 1272 | 1272 | }); |
| 1273 | 1273 | } |