@@ -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); |
@@ -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 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function reorganize(callable $reorganizer): Stream |
54 | 54 | { |
55 | 55 | $reorganizedCollection = $reorganizer($this->list); |
56 | - if (! $reorganizedCollection instanceof Collection) { |
|
56 | + if (!$reorganizedCollection instanceof Collection) { |
|
57 | 57 | throw new RuntimeException('Result set of reorganizer call must be instance of Collection interface'); |
58 | 58 | } |
59 | 59 | $this->list = $reorganizedCollection; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | $values = []; |
125 | 125 | $map = []; |
126 | - $this->each(static function ($el) use ($extractor, & $map, & $values) { |
|
126 | + $this->each(static function($el) use ($extractor, & $map, & $values) { |
|
127 | 127 | $value = $extractor($el); |
128 | 128 | if (!is_scalar($value)) { |
129 | 129 | throw new RuntimeException('Only scalar value can be as result of sort extractor'); |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $size = $this->list->size(); |
167 | 167 | /** @var ListSequence $list */ |
168 | 168 | $list = $this->list->copy(); |
169 | - $this->walk(static function ($head, $index) use ($list, $size) { |
|
169 | + $this->walk(static function($head, $index) use ($list, $size) { |
|
170 | 170 | $tailIndex = $size - $index - 1; |
171 | 171 | $tail = $list->get($tailIndex); |
172 | 172 | $list->set($tail, $index); |
173 | 173 | $list->set($head, $tailIndex); |
174 | - }, (int)($size/2)); |
|
174 | + }, (int)($size / 2)); |
|
175 | 175 | $this->list = $list; |
176 | 176 | |
177 | 177 | return $this; |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | public function limit(int $count): Stream |
304 | 304 | { |
305 | 305 | $newCollection = $this->emptyList(); |
306 | - $this->walk(static function ($el) use ($newCollection) { |
|
306 | + $this->walk(static function($el) use ($newCollection) { |
|
307 | 307 | $newCollection->add($el); |
308 | 308 | }, $count); |
309 | 309 |
@@ -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 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public static function lock(): Closure |
18 | 18 | { |
19 | - return static function (): bool { |
|
19 | + return static function(): bool { |
|
20 | 20 | return false; |
21 | 21 | }; |
22 | 22 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function notNull(): Closure |
29 | 29 | { |
30 | - return static function ($el): bool { |
|
30 | + return static function($el): bool { |
|
31 | 31 | return $el !== null; |
32 | 32 | }; |
33 | 33 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function notResistance(): Closure |
40 | 40 | { |
41 | - return static function (): bool { |
|
41 | + return static function(): bool { |
|
42 | 42 | return true; |
43 | 43 | }; |
44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public static function eachEven(): Closure |
51 | 51 | { |
52 | 52 | $isEven = false; |
53 | - return static function () use (& $isEven) { |
|
53 | + return static function() use (& $isEven) { |
|
54 | 54 | $res = $isEven; |
55 | 55 | $isEven = !$isEven; |
56 | 56 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public static function nth($number): Closure |
67 | 67 | { |
68 | 68 | $counter = 0; |
69 | - return static function () use ($number, & $counter) { |
|
69 | + return static function() use ($number, & $counter) { |
|
70 | 70 | $res = ++$counter % $number === 0; |
71 | 71 | if ($res) { |
72 | 72 | $counter = 0; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public static function equal($value): Closure |
84 | 84 | { |
85 | - return static function ($el) use ($value): bool { |
|
85 | + return static function($el) use ($value): bool { |
|
86 | 86 | return $el === $value; |
87 | 87 | }; |
88 | 88 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public static function lessThan($value): Closure |
96 | 96 | { |
97 | - return static function ($el) use ($value): bool { |
|
97 | + return static function($el) use ($value): bool { |
|
98 | 98 | return $el < $value; |
99 | 99 | }; |
100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public static function lessOrEqual($value): Closure |
108 | 108 | { |
109 | - return static function ($el) use ($value): bool { |
|
109 | + return static function($el) use ($value): bool { |
|
110 | 110 | return $el <= $value; |
111 | 111 | }; |
112 | 112 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public static function moreThan($value): Closure |
120 | 120 | { |
121 | - return static function ($el) use ($value): bool { |
|
121 | + return static function($el) use ($value): bool { |
|
122 | 122 | return $el > $value; |
123 | 123 | }; |
124 | 124 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public static function moreOrEqual($value): Closure |
132 | 132 | { |
133 | - return static function ($el) use ($value): bool { |
|
133 | + return static function($el) use ($value): bool { |
|
134 | 134 | return $el >= $value; |
135 | 135 | }; |
136 | 136 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public static function not($value): Closure |
144 | 144 | { |
145 | - return static function ($el) use ($value): bool { |
|
145 | + return static function($el) use ($value): bool { |
|
146 | 146 | return $el !== $value; |
147 | 147 | }; |
148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public static function in(array $values): Closure |
156 | 156 | { |
157 | - return static function ($el) use ($values): bool { |
|
157 | + return static function($el) use ($values): bool { |
|
158 | 158 | return in_array($el, $values, true); |
159 | 159 | }; |
160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public static function notIn(array $values): Closure |
168 | 168 | { |
169 | - return static function ($el) use ($values): bool { |
|
169 | + return static function($el) use ($values): bool { |
|
170 | 170 | return !in_array($el, $values, true); |
171 | 171 | }; |
172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function where(string $property, $value): Closure |
181 | 181 | { |
182 | - return static function ($ob) use ($property, $value) { |
|
182 | + return static function($ob) use ($property, $value) { |
|
183 | 183 | return $value === ObjectFunctions::getPropertyValue($ob, $property); |
184 | 184 | }; |
185 | 185 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public static function whereNot(string $property, $value): Closure |
194 | 194 | { |
195 | - return static function ($ob) use ($property, $value) { |
|
195 | + return static function($ob) use ($property, $value) { |
|
196 | 196 | return $value !== ObjectFunctions::getPropertyValue($ob, $property); |
197 | 197 | }; |
198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function whereIn(string $property, array $values): Closure |
207 | 207 | { |
208 | - return static function ($ob) use ($property, $values) { |
|
208 | + return static function($ob) use ($property, $values) { |
|
209 | 209 | return in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
210 | 210 | }; |
211 | 211 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public static function whereNotIn(string $property, array $values): Closure |
220 | 220 | { |
221 | - return static function ($ob) use ($property, $values) { |
|
221 | + return static function($ob) use ($property, $values) { |
|
222 | 222 | return !in_array(ObjectFunctions::getPropertyValue($ob, $property), $values, true); |
223 | 223 | }; |
224 | 224 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public static function whereMoreThan(string $property, $value): Closure |
233 | 233 | { |
234 | - return static function (object $ob) use ($property, $value) { |
|
234 | + return static function(object $ob) use ($property, $value) { |
|
235 | 235 | return ObjectFunctions::getPropertyValue($ob, $property) > $value; |
236 | 236 | }; |
237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public static function whereLessThan(string $property, $value): Closure |
246 | 246 | { |
247 | - return static function (object $ob) use ($property, $value) { |
|
247 | + return static function(object $ob) use ($property, $value) { |
|
248 | 248 | return ObjectFunctions::getPropertyValue($ob, $property) < $value; |
249 | 249 | }; |
250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function whereMoreOrEqual(string $property, $value): Closure |
259 | 259 | { |
260 | - return static function (object $ob) use ($property, $value) { |
|
260 | + return static function(object $ob) use ($property, $value) { |
|
261 | 261 | return ObjectFunctions::getPropertyValue($ob, $property) >= $value; |
262 | 262 | }; |
263 | 263 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public static function whereLessOrEqual(string $property, $value): Closure |
272 | 272 | { |
273 | - return static function (object $ob) use ($property, $value) { |
|
273 | + return static function(object $ob) use ($property, $value) { |
|
274 | 274 | return ObjectFunctions::getPropertyValue($ob, $property) <= $value; |
275 | 275 | }; |
276 | 276 | } |