@@ -13,7 +13,6 @@ discard block |
||
| 13 | 13 | use CallableUnifierTrait; |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * @param array $items |
|
| 17 | 16 | * @return static |
| 18 | 17 | */ |
| 19 | 18 | public static function from($iterable) |
@@ -49,7 +48,7 @@ discard block |
||
| 49 | 48 | /** |
| 50 | 49 | * Return reindexed items |
| 51 | 50 | * |
| 52 | - * @return array |
|
| 51 | + * @return callable |
|
| 53 | 52 | */ |
| 54 | 53 | public function values() |
| 55 | 54 | { |
@@ -151,7 +150,6 @@ discard block |
||
| 151 | 150 | } |
| 152 | 151 | |
| 153 | 152 | /** |
| 154 | - * @param int $offset |
|
| 155 | 153 | * @param int $length |
| 156 | 154 | * @param bool $preserveKeys |
| 157 | 155 | * @return static |
@@ -180,7 +178,7 @@ discard block |
||
| 180 | 178 | } |
| 181 | 179 | |
| 182 | 180 | /** |
| 183 | - * @param Collection $collection |
|
| 181 | + * @param Collection $collections |
|
| 184 | 182 | * @return static |
| 185 | 183 | */ |
| 186 | 184 | public function merge(...$collections) |
@@ -279,7 +277,7 @@ discard block |
||
| 279 | 277 | |
| 280 | 278 | /** |
| 281 | 279 | * @param callable $callable |
| 282 | - * @param mixed $initial |
|
| 280 | + * @param Collection $initial |
|
| 283 | 281 | * @return mixed |
| 284 | 282 | */ |
| 285 | 283 | public function reduce(callable $callable, $initial) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $function = $this->normalizeAsCallables($callable); |
| 112 | 112 | return new static(array_filter( |
| 113 | 113 | $this->getArrayCopy(), |
| 114 | - function ($item) use ($function) { |
|
| 114 | + function($item) use ($function) { |
|
| 115 | 115 | return !$function($item); |
| 116 | 116 | } |
| 117 | 117 | )); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function merge(...$collections) |
| 187 | 187 | { |
| 188 | - $values = array_map(function (CollectionInterface $collection) { |
|
| 188 | + $values = array_map(function(CollectionInterface $collection) { |
|
| 189 | 189 | return $collection->values(); |
| 190 | 190 | }, $collections); |
| 191 | 191 | return new static(array_merge($this->values(), ...$values)); |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | $results = []; |
| 201 | 201 | foreach ($this->values() as $key => $value) { |
| 202 | 202 | $groupKeys = $function($value, $key); |
| 203 | - if (! is_array($groupKeys)) { |
|
| 203 | + if (!is_array($groupKeys)) { |
|
| 204 | 204 | $groupKeys = [$groupKeys]; |
| 205 | 205 | } |
| 206 | 206 | foreach ($groupKeys as $groupKey) { |
| 207 | 207 | if (!in_array(gettype($groupKey), ['string', 'int'])) { |
| 208 | 208 | $groupKey = (int) $groupKey; |
| 209 | 209 | } |
| 210 | - if (! array_key_exists($groupKey, $results)) { |
|
| 210 | + if (!array_key_exists($groupKey, $results)) { |
|
| 211 | 211 | $results[$groupKey] = new static; |
| 212 | 212 | } |
| 213 | 213 | $results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | public function concat() |
| 225 | 225 | { |
| 226 | 226 | return $this->reduce( |
| 227 | - function (CollectionInterface $accumulator, Collection $item) { |
|
| 227 | + function(CollectionInterface $accumulator, Collection $item) { |
|
| 228 | 228 | if ($item instanceof Collection) { |
| 229 | 229 | $accumulator = $accumulator->merge($item); |
| 230 | 230 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * Return reindexed items as array |
| 21 | 21 | * |
| 22 | - * @return array |
|
| 22 | + * @return callable |
|
| 23 | 23 | */ |
| 24 | 24 | public function values(); |
| 25 | 25 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * Merge one or more collections |
| 52 | 52 | * |
| 53 | - * @param Collection $collection |
|
| 53 | + * @param Collection $collections |
|
| 54 | 54 | * @return self |
| 55 | 55 | */ |
| 56 | 56 | public function merge(...$collections); |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | if (is_object($callable)) { |
| 22 | 22 | return $callable; |
| 23 | 23 | } |
| 24 | - return function () use ($callable) { |
|
| 24 | + return function() use ($callable) { |
|
| 25 | 25 | return call_user_func_array($callable, func_get_args()); |
| 26 | 26 | }; |
| 27 | 27 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function map(callable $callable) |
| 71 | 71 | { |
| 72 | 72 | $function = $this->normalizeAsCallables($callable); |
| 73 | - $mapping = function ($iterator) use ($function) { |
|
| 73 | + $mapping = function($iterator) use ($function) { |
|
| 74 | 74 | foreach ($iterator as $key => $item) { |
| 75 | 75 | yield $key => $function($item); |
| 76 | 76 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function filter(callable $callable) |
| 85 | 85 | { |
| 86 | 86 | $function = $this->normalizeAsCallables($callable); |
| 87 | - $filter = function ($iterator) use ($function) { |
|
| 87 | + $filter = function($iterator) use ($function) { |
|
| 88 | 88 | foreach ($iterator as $key => $item) { |
| 89 | 89 | if ($function($item)) { |
| 90 | 90 | yield $item; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | public function reject(callable $callable) |
| 113 | 113 | { |
| 114 | 114 | $function = $this->normalizeAsCallables($callable); |
| 115 | - $rejection = function ($iterator) use ($function) { |
|
| 115 | + $rejection = function($iterator) use ($function) { |
|
| 116 | 116 | foreach ($iterator as $key => $item) { |
| 117 | 117 | if (!$function($item)) { |
| 118 | 118 | yield $item; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function merge(...$collections) |
| 129 | 129 | { |
| 130 | - $merging = function (...$iterators) { |
|
| 130 | + $merging = function(...$iterators) { |
|
| 131 | 131 | foreach ($iterators as $iterator) { |
| 132 | 132 | foreach ($iterator as $item) { |
| 133 | 133 | yield $item; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $validateItem = static::validateItem($itemType); |
| 89 | 89 | array_map( |
| 90 | - function ($item) use ($validateItem) { |
|
| 90 | + function($item) use ($validateItem) { |
|
| 91 | 91 | $validateItem($item); |
| 92 | 92 | }, |
| 93 | 93 | $items |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected static function validateItem($type) |
| 104 | 104 | { |
| 105 | - return function ($item) use ($type) { |
|
| 105 | + return function($item) use ($type) { |
|
| 106 | 106 | if (!is_object($item)) { |
| 107 | 107 | throw new \InvalidArgumentException(sprintf('Invalid type [%s], expected [%s].', gettype($item), $type)); |
| 108 | 108 | } |