@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | public function getIterator() |
24 | 24 | { |
25 | - return new ArrayIterator(array_map(static function (MapEntry $entry) { |
|
25 | + return new ArrayIterator(array_map(static function(MapEntry $entry) { |
|
26 | 26 | return $entry->getValue(); |
27 | 27 | }, $this->entries)); |
28 | 28 | } |
@@ -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 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public static function shuffle(): Closure |
23 | 23 | { |
24 | - return static function (Collection $collection): Collection { |
|
24 | + return static function(Collection $collection): Collection { |
|
25 | 25 | $array = $collection->toArray(); |
26 | 26 | shuffle($array); |
27 | 27 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public static function random(int $count = 1): Closure |
38 | 38 | { |
39 | - return static function (Collection $collection) use ($count): Collection { |
|
39 | + return static function(Collection $collection) use ($count): Collection { |
|
40 | 40 | /** |
41 | 41 | * Collection |
42 | 42 | */ |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | $generated = 0; |
57 | 57 | $multiplicity = (int)round($collectionSize / $expectedCount); |
58 | 58 | |
59 | - $rangeRandomizer = static function () use ($multiplicity): int { |
|
59 | + $rangeRandomizer = static function() use ($multiplicity): int { |
|
60 | 60 | return random_int(0, $multiplicity - 1); |
61 | 61 | }; |
62 | 62 | |
63 | - $trier = static function () use (& $generated, & $rest, $expectedCount, $rangeRandomizer): bool { |
|
63 | + $trier = static function() use (& $generated, & $rest, $expectedCount, $rangeRandomizer): bool { |
|
64 | 64 | $rest--; |
65 | 65 | if ($generated === $expectedCount) { |
66 | 66 | return false; |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public static function chunk(int $size): Closure |
91 | 91 | { |
92 | - return static function (Collection $collection) use ($size): Collection { |
|
92 | + return static function(Collection $collection) use ($size): Collection { |
|
93 | 93 | $chunkCollection = self::collectionConstructor(); |
94 | 94 | $currentChunk = self::collectionConstructor(); |
95 | 95 | $pointer = $size; |
96 | 96 | $collection |
97 | 97 | ->stream() |
98 | - ->each(static function ($el) use ($size, $chunkCollection, & $currentChunk, & $pointer) { |
|
98 | + ->each(static function($el) use ($size, $chunkCollection, & $currentChunk, & $pointer) { |
|
99 | 99 | $pointer--; |
100 | 100 | $currentChunk->add($el); |
101 | 101 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public static function collapse(): Closure |
118 | 118 | { |
119 | - return static function (Collection $collection): Collection { |
|
120 | - $flatIterable = static function (iterable $collection) use (& $flatIterable): array { |
|
119 | + return static function(Collection $collection): Collection { |
|
120 | + $flatIterable = static function(iterable $collection) use (& $flatIterable): array { |
|
121 | 121 | $res = []; |
122 | 122 | foreach ($collection as $item) { |
123 | 123 | if (is_iterable($item)) { |