@@ -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); |
@@ -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)) { |
@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function lock(): Closure |
19 | 19 | { |
20 | - return static function (): bool { |
|
20 | + return static function(): bool { |
|
21 | 21 | return false; |
22 | 22 | }; |
23 | 23 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function notNull(): Closure |
30 | 30 | { |
31 | - return static function ($el): bool { |
|
31 | + return static function($el): bool { |
|
32 | 32 | return $el !== null; |
33 | 33 | }; |
34 | 34 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function notResistance(): Closure |
41 | 41 | { |
42 | - return static function (): bool { |
|
42 | + return static function(): bool { |
|
43 | 43 | return true; |
44 | 44 | }; |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public static function eachEven(): Closure |
52 | 52 | { |
53 | 53 | $isEven = false; |
54 | - return static function () use (& $isEven) { |
|
54 | + return static function() use (& $isEven) { |
|
55 | 55 | $res = $isEven; |
56 | 56 | $isEven = !$isEven; |
57 | 57 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public static function nth($number): Closure |
68 | 68 | { |
69 | 69 | $counter = 0; |
70 | - return static function () use ($number, & $counter) { |
|
70 | + return static function() use ($number, & $counter) { |
|
71 | 71 | $res = ++$counter % $number === 0; |
72 | 72 | if ($res) { |
73 | 73 | $counter = 0; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function equal($value): Closure |
85 | 85 | { |
86 | - return static function ($el) use ($value): bool { |
|
86 | + return static function($el) use ($value): bool { |
|
87 | 87 | return $el === $value; |
88 | 88 | }; |
89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public static function lockDuplicated(): Closure |
95 | 95 | { |
96 | 96 | $set = new HashSet(); |
97 | - return static function ($el) use ($set): bool { |
|
97 | + return static function($el) use ($set): bool { |
|
98 | 98 | $res = !$set->contains($el); |
99 | 99 | $set->add($el); |
100 | 100 | return $res; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public static function lessThan($value): Closure |
110 | 110 | { |
111 | - return static function ($el) use ($value): bool { |
|
111 | + return static function($el) use ($value): bool { |
|
112 | 112 | return $el < $value; |
113 | 113 | }; |
114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function lessOrEqual($value): Closure |
122 | 122 | { |
123 | - return static function ($el) use ($value): bool { |
|
123 | + return static function($el) use ($value): bool { |
|
124 | 124 | return $el <= $value; |
125 | 125 | }; |
126 | 126 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function greaterThan($value): Closure |
134 | 134 | { |
135 | - return static function ($el) use ($value): bool { |
|
135 | + return static function($el) use ($value): bool { |
|
136 | 136 | return $el > $value; |
137 | 137 | }; |
138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public static function greaterOrEqual($value): Closure |
146 | 146 | { |
147 | - return static function ($el) use ($value): bool { |
|
147 | + return static function($el) use ($value): bool { |
|
148 | 148 | return $el >= $value; |
149 | 149 | }; |
150 | 150 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function not($value): Closure |
158 | 158 | { |
159 | - return static function ($el) use ($value): bool { |
|
159 | + return static function($el) use ($value): bool { |
|
160 | 160 | return $el !== $value; |
161 | 161 | }; |
162 | 162 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public static function in(array $values): Closure |
170 | 170 | { |
171 | - return static function ($el) use ($values): bool { |
|
171 | + return static function($el) use ($values): bool { |
|
172 | 172 | return in_array($el, $values, true); |
173 | 173 | }; |
174 | 174 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public static function notIn(array $values): Closure |
182 | 182 | { |
183 | - return static function ($el) use ($values): bool { |
|
183 | + return static function($el) use ($values): bool { |
|
184 | 184 | return !in_array($el, $values, true); |
185 | 185 | }; |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public static function where(string $property, $value): Closure |
195 | 195 | { |
196 | - return static function ($ob) use ($property, $value) { |
|
196 | + return static function($ob) use ($property, $value) { |
|
197 | 197 | return $value === ObjectFunctions::getPropertyValue($ob, $property); |
198 | 198 | }; |
199 | 199 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public static function whereNot(string $property, $value): Closure |
208 | 208 | { |
209 | - return static function ($ob) use ($property, $value) { |
|
209 | + return static function($ob) use ($property, $value) { |
|
210 | 210 | return $value !== ObjectFunctions::getPropertyValue($ob, $property); |
211 | 211 | }; |
212 | 212 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public static function whereIn(string $property, array $values): Closure |
221 | 221 | { |
222 | - return static function ($ob) use ($property, $values) { |
|
222 | + return static function($ob) use ($property, $values) { |
|
223 | 223 | return in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
224 | 224 | }; |
225 | 225 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public static function whereNotIn(string $property, array $values): Closure |
234 | 234 | { |
235 | - return static function ($ob) use ($property, $values) { |
|
235 | + return static function($ob) use ($property, $values) { |
|
236 | 236 | return !in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
237 | 237 | }; |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public static function whereGreaterThan(string $property, $value): Closure |
247 | 247 | { |
248 | - return static function ($ob) use ($property, $value) { |
|
248 | + return static function($ob) use ($property, $value) { |
|
249 | 249 | return ObjectFunctions::getPropertyValue($ob, $property) > $value; |
250 | 250 | }; |
251 | 251 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public static function whereLessThan(string $property, $value): Closure |
260 | 260 | { |
261 | - return static function ($ob) use ($property, $value) { |
|
261 | + return static function($ob) use ($property, $value) { |
|
262 | 262 | return ObjectFunctions::getPropertyValue($ob, $property) < $value; |
263 | 263 | }; |
264 | 264 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function whereGreaterOrEqual(string $property, $value): Closure |
273 | 273 | { |
274 | - return static function ($ob) use ($property, $value) { |
|
274 | + return static function($ob) use ($property, $value) { |
|
275 | 275 | return ObjectFunctions::getPropertyValue($ob, $property) >= $value; |
276 | 276 | }; |
277 | 277 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public static function whereLessOrEqual(string $property, $value): Closure |
286 | 286 | { |
287 | - return static function ($ob) use ($property, $value) { |
|
287 | + return static function($ob) use ($property, $value) { |
|
288 | 288 | return ObjectFunctions::getPropertyValue($ob, $property) <= $value; |
289 | 289 | }; |
290 | 290 | } |