@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function toPropertyValue(string $name): Closure |
19 | 19 | { |
20 | - return static function ($obj) use ($name) { |
|
20 | + return static function($obj) use ($name) { |
|
21 | 21 | return ObjectFunctions::getPropertyValue($obj, $name); |
22 | 22 | }; |
23 | 23 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function toProperties(array $names): Closure |
31 | 31 | { |
32 | - return static function ($obj) use ($names) { |
|
32 | + return static function($obj) use ($names) { |
|
33 | 33 | $res = []; |
34 | 34 | foreach ($names as $name) { |
35 | 35 | $res[$name] = ObjectFunctions::getPropertyValue($obj, $name); |
@@ -59,7 +59,7 @@ |
||
59 | 59 | |
60 | 60 | public function removeAt(int $index) |
61 | 61 | { |
62 | - throw $this->createBlockingException(); |
|
62 | + throw $this->createBlockingException(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | private function createBlockingException(): RuntimeException |
@@ -12,11 +12,11 @@ |
||
12 | 12 | if ($this->isEmpty()) { |
13 | 13 | return false; |
14 | 14 | } |
15 | - $fMatch = static function ($tested) use ($element): bool { |
|
15 | + $fMatch = static function($tested) use ($element): bool { |
|
16 | 16 | return $tested === $element; |
17 | 17 | }; |
18 | 18 | if ($element instanceof HashCodeAware) { |
19 | - $fMatch = static function ($tested) use ($element): bool { |
|
19 | + $fMatch = static function($tested) use ($element): bool { |
|
20 | 20 | if ($tested instanceof HashCodeAware) { |
21 | 21 | return $tested->getHashCode() === $element->getHashCode(); |
22 | 22 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public static function directSequence($length): Iterator |
11 | 11 | { |
12 | 12 | $current = 0; |
13 | - return new CallbackIterator(static function () use (& $current, $length) { |
|
13 | + return new CallbackIterator(static function() use (& $current, $length) { |
|
14 | 14 | if ($current === $length) { |
15 | 15 | return (new IterateResult())->setAsRunOut(); |
16 | 16 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function reverseSequence($length): Iterator |
23 | 23 | { |
24 | 24 | $current = $length - 1; |
25 | - return new CallbackIterator(static function () use (& $current) { |
|
25 | + return new CallbackIterator(static function() use (& $current) { |
|
26 | 26 | if ($current === -1) { |
27 | 27 | return (new IterateResult())->setAsRunOut(); |
28 | 28 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | if ($times < 0) { |
23 | 23 | throw new RuntimeException('The count of values ($times) must be a positive value'); |
24 | 24 | } |
25 | - $generator = $generator ?? static function (int $index) { |
|
25 | + $generator = $generator ?? static function(int $index) { |
|
26 | 26 | return $index; |
27 | 27 | }; |
28 | 28 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function concat(string $delimiter = ''): Closure |
26 | 26 | { |
27 | - return static function (Collection $collection) use ($delimiter) { |
|
27 | + return static function(Collection $collection) use ($delimiter) { |
|
28 | 28 | return implode($delimiter, $collection->toArray()); |
29 | 29 | }; |
30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param Collection $collection |
40 | 40 | * @return float|int |
41 | 41 | */ |
42 | - return static function (Collection $collection) { |
|
42 | + return static function(Collection $collection) { |
|
43 | 43 | $array = $collection->toArray(); |
44 | 44 | |
45 | 45 | return array_sum($array) / count($array); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function group(): Closure |
54 | 54 | { |
55 | - return static function (Collection $collection): Map { |
|
56 | - $groupBy = self::groupBy(static function ($el) { |
|
55 | + return static function(Collection $collection): Map { |
|
56 | + $groupBy = self::groupBy(static function($el) { |
|
57 | 57 | return $el; |
58 | 58 | }); |
59 | 59 | return $groupBy($collection); |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public static function groupByProperty(string $property): Closure |
69 | 69 | { |
70 | - return static function (Collection $collection) use ($property): Map { |
|
71 | - $fGetValue = static function ($obj) use ($property) { |
|
70 | + return static function(Collection $collection) use ($property): Map { |
|
71 | + $fGetValue = static function($obj) use ($property) { |
|
72 | 72 | return ObjectFunctions::getPropertyValue($obj, $property); |
73 | 73 | }; |
74 | 74 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function groupBy(callable $f): Closure |
86 | 86 | { |
87 | - return static function (Collection $collection) use ($f): Map { |
|
87 | + return static function(Collection $collection) use ($f): Map { |
|
88 | 88 | $group = new HashMap(); |
89 | 89 | $collection |
90 | 90 | ->stream() |
91 | - ->each(static function ($el) use ($group, $f) { |
|
91 | + ->each(static function($el) use ($group, $f) { |
|
92 | 92 | $value = $f($el); |
93 | 93 | $count = 0; |
94 | 94 | if (($gCount = $group->get($value)) !== null) { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public static function dump(): callable |
15 | 15 | { |
16 | - return static function ($el) { |
|
16 | + return static function($el) { |
|
17 | 17 | var_dump($el); |
18 | 18 | }; |
19 | 19 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public static function scalarComparator(): Closure |
17 | 17 | { |
18 | - return static function ($a, $b) { |
|
18 | + return static function($a, $b) { |
|
19 | 19 | return $a <=> $b; |
20 | 20 | }; |
21 | 21 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function objectPropertyComparator(string $property): Closure |
29 | 29 | { |
30 | - return static function ($a, $b) use ($property) { |
|
30 | + return static function($a, $b) use ($property) { |
|
31 | 31 | return ObjectFunctions::getPropertyValue($a, $property) <=> ObjectFunctions::getPropertyValue($b, $property); |
32 | 32 | }; |
33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function callbackComparator(callable $f): Closure |
41 | 41 | { |
42 | - return static function ($a, $b) use ($f) { |
|
42 | + return static function($a, $b) use ($f) { |
|
43 | 43 | return $f($a) <=> $f($b); |
44 | 44 | }; |
45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function reorganize(callable $reorganizer): Stream |
53 | 53 | { |
54 | 54 | $reorganizedCollection = $reorganizer($this->list->copy()); |
55 | - if (! $reorganizedCollection instanceof Collection) { |
|
55 | + if (!$reorganizedCollection instanceof Collection) { |
|
56 | 56 | throw new RuntimeException('Result set of reorganizer call must be instance of Collection interface'); |
57 | 57 | } |
58 | 58 | $this->list = $reorganizedCollection; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $values = []; |
124 | 124 | $map = []; |
125 | - $this->each(static function ($el) use ($extractor, & $map, & $values) { |
|
125 | + $this->each(static function($el) use ($extractor, & $map, & $values) { |
|
126 | 126 | $value = $extractor($el); |
127 | 127 | if (!is_scalar($value)) { |
128 | 128 | throw new RuntimeException('Only scalar value can be as result of sort extractor'); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function findAny() |
184 | 184 | { |
185 | - $size = $this->list->size(); |
|
185 | + $size = $this->list->size(); |
|
186 | 186 | if ($size === 0) { |
187 | 187 | return null; |
188 | 188 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | public function limit(int $size): Stream |
308 | 308 | { |
309 | 309 | $newCollection = $this->emptyList(); |
310 | - $this->walk(static function ($el) use ($newCollection) { |
|
310 | + $this->walk(static function($el) use ($newCollection) { |
|
311 | 311 | $newCollection->add($el); |
312 | 312 | }, $size); |
313 | 313 |