@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | declare(strict_types=1); |
25 | 25 | |
26 | -if (! function_exists('stringContains')) { |
|
26 | +if (!function_exists('stringContains')) { |
|
27 | 27 | /** |
28 | 28 | * Checks if a string contains a sub string |
29 | 29 | * |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | -if (! function_exists('array_flatten')) { |
|
40 | +if (!function_exists('array_flatten')) { |
|
41 | 41 | /** |
42 | 42 | * Flattens an array to desired depth. |
43 | 43 | * doesn't preserve keys |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | return array_reduce( |
52 | 52 | $array, |
53 | - function (array $carry, $element) use ($n): array { |
|
53 | + function(array $carry, $element) use ($n) : array { |
|
54 | 54 | // Remove empty arrays. |
55 | 55 | if (is_array($element) && empty($element)) { |
56 | 56 | return $carry; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | -if (! function_exists('toObject')) { |
|
72 | +if (!function_exists('toObject')) { |
|
73 | 73 | /** |
74 | 74 | * Simple mapper for turning arrays into stdClass objects. |
75 | 75 | * |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | -if (! function_exists('invokeCallable')) { |
|
90 | +if (!function_exists('invokeCallable')) { |
|
91 | 91 | /** |
92 | 92 | * Used to invoke a callable. |
93 | 93 | * |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -if (! function_exists('isArrayAccess')) { |
|
104 | +if (!function_exists('isArrayAccess')) { |
|
105 | 105 | /** |
106 | 106 | * Checks if an array or an object which has array like access. |
107 | 107 | * |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param mixed $b The values to compare with |
46 | 46 | * @return bool |
47 | 47 | */ |
48 | - return function ($b) use ($a): bool { |
|
49 | - if (! sameScalar($b, $a)) { |
|
48 | + return function($b) use ($a): bool { |
|
49 | + if (!sameScalar($b, $a)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param mixed $b The values to compare with |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | - return function ($b) use ($a): bool { |
|
87 | - return ! isEqualTo($a)($b); |
|
86 | + return function($b) use ($a): bool { |
|
87 | + return !isEqualTo($a)($b); |
|
88 | 88 | }; |
89 | 89 | } |
90 | 90 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @param Number $b |
102 | 102 | * @return bool |
103 | 103 | */ |
104 | - return function ($b) use ($a): bool { |
|
105 | - return isEqualIn(array( 'integer', 'double' ))(gettype($b)) |
|
104 | + return function($b) use ($a): bool { |
|
105 | + return isEqualIn(array('integer', 'double'))(gettype($b)) |
|
106 | 106 | ? $a < $b : false; |
107 | 107 | }; |
108 | 108 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param mixed $b |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - return function ($b) use ($a): bool { |
|
124 | - return isEqualIn(array( 'integer', 'double' ))(gettype($b)) |
|
123 | + return function($b) use ($a): bool { |
|
124 | + return isEqualIn(array('integer', 'double'))(gettype($b)) |
|
125 | 125 | ? $a > $b : false; |
126 | 126 | }; |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param Number $b The base value to compare with must be int or float. |
140 | 140 | * @return bool |
141 | 141 | */ |
142 | - return function ($b) use ($a): bool { |
|
142 | + return function($b) use ($a): bool { |
|
143 | 143 | return any(isEqualTo($a), isLessThan($a))($b); |
144 | 144 | }; |
145 | 145 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param Number $b |
158 | 158 | * @return bool |
159 | 159 | */ |
160 | - return function ($b) use ($a): bool { |
|
160 | + return function($b) use ($a): bool { |
|
161 | 161 | return any(isEqualTo($a), isGreaterThan($a))($b); |
162 | 162 | }; |
163 | 163 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param mixed[] $b The array of values which it could be |
175 | 175 | * @return bool |
176 | 176 | */ |
177 | - return function ($b) use ($a): ?bool { |
|
177 | + return function($b) use ($a): ?bool { |
|
178 | 178 | if ( |
179 | 179 | is_numeric($b) || is_bool($b) || |
180 | 180 | is_string($b) || is_array($b) |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | return in_array( |
185 | 185 | (array) $b, |
186 | 186 | array_map( |
187 | - function ($e): array { |
|
187 | + function($e): array { |
|
188 | 188 | return (array) $e; |
189 | 189 | }, |
190 | 190 | $a |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function notEmpty($value): bool |
208 | 208 | { |
209 | - return ! empty($value); |
|
209 | + return !empty($value); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param mixed $value |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | - return function ($value) use ($callables): bool { |
|
224 | + return function($value) use ($callables): bool { |
|
225 | 225 | return (bool) array_reduce( |
226 | 226 | $callables, |
227 | - function ($result, $callable) use ($value) { |
|
227 | + function($result, $callable) use ($value) { |
|
228 | 228 | return (is_bool($result) && $result === false) ? false : $callable($value); |
229 | 229 | }, |
230 | 230 | null |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | * @param mixed $value |
245 | 245 | * @return bool |
246 | 246 | */ |
247 | - return function ($value) use ($callables): bool { |
|
247 | + return function($value) use ($callables): bool { |
|
248 | 248 | return (bool) array_reduce( |
249 | 249 | $callables, |
250 | - function ($result, $callable) use ($value) { |
|
250 | + function($result, $callable) use ($value) { |
|
251 | 251 | return (is_bool($result) && $result === true) ? true : $callable($value); |
252 | 252 | }, |
253 | 253 | null |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param mixed $value |
268 | 268 | * @return bool |
269 | 269 | */ |
270 | - return function ($value) use ($source) { |
|
270 | + return function($value) use ($source) { |
|
271 | 271 | return gettype($value) === $source; |
272 | 272 | }; |
273 | 273 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | function allTrue(bool ...$variables): bool |
299 | 299 | { |
300 | 300 | foreach ($variables as $value) { |
301 | - if (! is_bool($value) || $value !== true) { |
|
301 | + if (!is_bool($value) || $value !== true) { |
|
302 | 302 | return false; |
303 | 303 | } |
304 | 304 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param mixed $value |
389 | 389 | * @return bool |
390 | 390 | */ |
391 | - return function ($value) use ($callable): bool { |
|
392 | - return ! (bool) $callable($value); |
|
391 | + return function($value) use ($callable): bool { |
|
392 | + return !(bool) $callable($value); |
|
393 | 393 | }; |
394 | 394 | } |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * Only works for public or dynamic properties. |
265 | 265 | * |
266 | 266 | * @param array<string,mixed>|ArrayObject<string,mixed>|object $store |
267 | - * @param string $property The property key. |
|
267 | + * @param string $property The property key. |
|
268 | 268 | * @return Closure(mixed):(array<string,mixed>|ArrayObject<string,mixed>|object) |
269 | 269 | */ |
270 | 270 | function setProperty($store, string $property): Closure |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param mixed The value passed into the functions |
50 | 50 | * @return mixed The final result. |
51 | 51 | */ |
52 | - return function ($e) use ($callables) { |
|
52 | + return function($e) use ($callables) { |
|
53 | 53 | foreach ($callables as $callable) { |
54 | 54 | $e = $callable($e); |
55 | 55 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param mixed The value passed into the functions |
71 | 71 | * @return mixed The final result. |
72 | 72 | */ |
73 | - return function ($e) use ($callables) { |
|
73 | + return function($e) use ($callables) { |
|
74 | 74 | foreach (\array_reverse($callables) as $callable) { |
75 | 75 | $e = $callable($e); |
76 | 76 | } |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @param mixed The value passed into the functions |
92 | 92 | * @return mixed|null The final result or null. |
93 | 93 | */ |
94 | - return function ($e) use ($callables) { |
|
94 | + return function($e) use ($callables) { |
|
95 | 95 | foreach ($callables as $callable) { |
96 | - if (! is_null($e)) { |
|
96 | + if (!is_null($e)) { |
|
97 | 97 | $e = $callable($e); |
98 | 98 | } |
99 | 99 | } |
@@ -116,17 +116,17 @@ discard block |
||
116 | 116 | * @param mixed $e The value being passed through the functions. |
117 | 117 | * @return mixed The final result. |
118 | 118 | */ |
119 | - return function ($e) use ($validator, $callables) { |
|
119 | + return function($e) use ($validator, $callables) { |
|
120 | 120 | foreach ($callables as $callable) { |
121 | 121 | // If invalid, abort and return null |
122 | - if (! $validator($e)) { |
|
122 | + if (!$validator($e)) { |
|
123 | 123 | return null; |
124 | 124 | } |
125 | 125 | // Run through callable. |
126 | 126 | $e = $callable($e); |
127 | 127 | |
128 | 128 | // Check results and bail if invalid type. |
129 | - if (! $validator($e)) { |
|
129 | + if (!$validator($e)) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param mixed $data The array or object to attempt to get param. |
173 | 173 | * @return mixed|null |
174 | 174 | */ |
175 | - return function ($data) use ($property) { |
|
175 | + return function($data) use ($property) { |
|
176 | 176 | if (is_array($data)) { |
177 | - return array_key_exists($property, $data) ? $data[ $property ] : null; |
|
177 | + return array_key_exists($property, $data) ? $data[$property] : null; |
|
178 | 178 | } elseif (is_object($data)) { |
179 | 179 | return property_exists($data, $property) ? $data->{$property} : null; |
180 | 180 | } else { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param mixed[]|object $data The array or object to attempt to get param. |
198 | 198 | * @return mixed|null |
199 | 199 | */ |
200 | - return function ($data) use ($nodes) { |
|
200 | + return function($data) use ($nodes) { |
|
201 | 201 | foreach ($nodes as $node) { |
202 | 202 | $data = getProperty($node)($data); |
203 | 203 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param mixed $data The array or object to attempt to get param. |
223 | 223 | * @return mixed|null |
224 | 224 | */ |
225 | - return function ($data) use ($property): bool { |
|
225 | + return function($data) use ($property): bool { |
|
226 | 226 | if (is_array($data)) { |
227 | 227 | return array_key_exists($property, $data); |
228 | 228 | } elseif (is_object($data)) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param mixed $data The array or object to attempt to get param. |
248 | 248 | * @return bool |
249 | 249 | */ |
250 | - return function ($data) use ($property, $value): bool { |
|
250 | + return function($data) use ($property, $value): bool { |
|
251 | 251 | return pipe( |
252 | 252 | $data, |
253 | 253 | getProperty($property), |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | { |
273 | 273 | |
274 | 274 | // If passed store is not an array or object, throw exception. |
275 | - if (! isArrayAccess($store) && ! is_object($store)) { |
|
275 | + if (!isArrayAccess($store) && !is_object($store)) { |
|
276 | 276 | throw new TypeError('Only objects or arrays can be constructed using setProperty.'); |
277 | 277 | } |
278 | 278 | |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | * @param mixed $value The value to set to keu. |
281 | 281 | * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore. |
282 | 282 | */ |
283 | - return function ($value) use ($store, $property) { |
|
283 | + return function($value) use ($store, $property) { |
|
284 | 284 | if (isArrayAccess($store)) { |
285 | 285 | /** @phpstan-ignore-next-line */ |
286 | - $store[ $property ] = $value; |
|
286 | + $store[$property] = $value; |
|
287 | 287 | } else { |
288 | 288 | $store->{$property} = $value; |
289 | 289 | } |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param mixed $data The data to pass through the callable |
307 | 307 | * @return array |
308 | 308 | */ |
309 | - return function ($data) use ($key, $value): array { |
|
310 | - return array( $key => $value($data) ); |
|
309 | + return function($data) use ($key, $value): array { |
|
310 | + return array($key => $value($data)); |
|
311 | 311 | }; |
312 | 312 | } |
313 | 313 | |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | * @param callable(mixed):mixed ...$encoders encodeProperty() functions. |
325 | 325 | * @return Closure |
326 | 326 | */ |
327 | - return function (...$encoders) use ($dataType): Closure { |
|
327 | + return function(...$encoders) use ($dataType): Closure { |
|
328 | 328 | /** |
329 | 329 | * @param mixed $data The data to pass through the encoders. |
330 | 330 | * @return array<string,mixed>|object The encoded object/array. |
331 | 331 | */ |
332 | - return function ($data) use ($dataType, $encoders) { |
|
332 | + return function($data) use ($dataType, $encoders) { |
|
333 | 333 | foreach ($encoders as $encoder) { |
334 | 334 | $key = array_keys($encoder($data))[0]; |
335 | 335 | // throw exception if key is int |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param mixed ...$args |
357 | 357 | * @return mixed |
358 | 358 | */ |
359 | - return function (...$args) use ($fn) { |
|
359 | + return function(...$args) use ($fn) { |
|
360 | 360 | return $fn(...$args); |
361 | 361 | }; |
362 | 362 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * @param mixed $ignored Any values can be passed and ignored. |
374 | 374 | * @return mixed |
375 | 375 | */ |
376 | - return function (...$ignored) use ($value) { |
|
376 | + return function(...$ignored) use ($value) { |
|
377 | 377 | return $value; |
378 | 378 | }; |
379 | 379 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param mixed $value |
409 | 409 | * @return mixed |
410 | 410 | */ |
411 | - return function ($value) use ($condition, $then) { |
|
411 | + return function($value) use ($condition, $then) { |
|
412 | 412 | return true === (bool) $condition($value) |
413 | 413 | ? $then($value) |
414 | 414 | : $value; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @param mixed $value |
432 | 432 | * @return mixed |
433 | 433 | */ |
434 | - return function ($value) use ($condition, $then, $else) { |
|
434 | + return function($value) use ($condition, $then, $else) { |
|
435 | 435 | return true === (bool) $condition($value) |
436 | 436 | ? $then($value) |
437 | 437 | : $else($value); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param int|null $value |
47 | 47 | * @return Closure(int|null):(Closure|int)|int |
48 | 48 | */ |
49 | - return function (?int $value = null) use ($initial) { |
|
49 | + return function(?int $value = null) use ($initial) { |
|
50 | 50 | if ($value) { |
51 | 51 | $initial += $value; |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param float|null $value |
67 | 67 | * @return Closure(float|null):(Closure|float)|float |
68 | 68 | */ |
69 | - return function (?float $value = null) use ($initial) { |
|
69 | + return function(?float $value = null) use ($initial) { |
|
70 | 70 | if ($value) { |
71 | 71 | $initial += $value; |
72 | 72 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param Number $value |
92 | 92 | * @return int|float |
93 | 93 | */ |
94 | - return function ($value) use ($initial) { |
|
94 | + return function($value) use ($initial) { |
|
95 | 95 | return $initial + $value; |
96 | 96 | }; |
97 | 97 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param Number $value |
115 | 115 | * @return int|float |
116 | 116 | */ |
117 | - return function ($value) use ($initial) { |
|
117 | + return function($value) use ($initial) { |
|
118 | 118 | return $value - $initial; |
119 | 119 | }; |
120 | 120 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param Number $value |
138 | 138 | * @return Number |
139 | 139 | */ |
140 | - return function ($value) use ($initial) { |
|
140 | + return function($value) use ($initial) { |
|
141 | 141 | return $value * $initial; |
142 | 142 | }; |
143 | 143 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @param float $value |
162 | 162 | * @return float |
163 | 163 | */ |
164 | - return function ($value) use ($divisor): float { |
|
164 | + return function($value) use ($divisor): float { |
|
165 | 165 | return $value / $divisor; |
166 | 166 | }; |
167 | 167 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param float $value |
184 | 184 | * @return float |
185 | 185 | */ |
186 | - return function ($value) use ($dividend): float { |
|
186 | + return function($value) use ($dividend): float { |
|
187 | 187 | return $dividend / $value; |
188 | 188 | }; |
189 | 189 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param float $value |
206 | 206 | * @return float |
207 | 207 | */ |
208 | - return function ($value) use ($divisor): float { |
|
208 | + return function($value) use ($divisor): float { |
|
209 | 209 | return $value % $divisor; |
210 | 210 | }; |
211 | 211 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param float $value |
228 | 228 | * @return float |
229 | 229 | */ |
230 | - return function ($value) use ($dividend): float { |
|
230 | + return function($value) use ($dividend): float { |
|
231 | 231 | return $dividend % $value; |
232 | 232 | }; |
233 | 233 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return bool |
251 | 251 | * @throws InvalidArgumentException If neither int or float passed. |
252 | 252 | */ |
253 | - return function ($value) use ($multiple): bool { |
|
253 | + return function($value) use ($multiple): bool { |
|
254 | 254 | if (!C\isNumber($value)) { |
255 | 255 | throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
256 | 256 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @return bool |
278 | 278 | * @throws InvalidArgumentException If neither int or float passed. |
279 | 279 | */ |
280 | - return function (int $value) use ($factor): bool { |
|
280 | + return function(int $value) use ($factor): bool { |
|
281 | 281 | // Return false if 0 |
282 | 282 | if ($value === 0) { |
283 | 283 | return false; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return float |
307 | 307 | * @throws InvalidArgumentException If neither int or float passed. |
308 | 308 | */ |
309 | - return function ($value) use ($precision): float { |
|
309 | + return function($value) use ($precision): float { |
|
310 | 310 | if (!C\isNumber($value)) { |
311 | 311 | throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )"); |
312 | 312 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @return Number |
333 | 333 | * @throws InvalidArgumentException If neither int or float passed. |
334 | 334 | */ |
335 | - return function ($value) use ($exponent) { |
|
335 | + return function($value) use ($exponent) { |
|
336 | 336 | if (!C\isNumber($value)) { |
337 | 337 | throw new \InvalidArgumentException('Num\\power() only accepts a valid Number ( Int|Float )'); |
338 | 338 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @return Number |
359 | 359 | * @throws InvalidArgumentException If neither int or float passed. |
360 | 360 | */ |
361 | - return function ($value) use ($root) { |
|
361 | + return function($value) use ($root) { |
|
362 | 362 | if (!C\isNumber($value)) { |
363 | 363 | throw new \InvalidArgumentException('Num\\root() only accepts a valid Number ( Int|Float )'); |
364 | 364 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $string |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - return function (string $string) use ($opening, $closing): string { |
|
51 | + return function(string $string) use ($opening, $closing) : string { |
|
52 | 52 | return \sprintf('%s%s%s', $opening, $string, $closing ?? $opening); |
53 | 53 | }; |
54 | 54 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param string $string |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - return function (string $string) use ($start, $finish): string { |
|
72 | - return ! $finish |
|
71 | + return function(string $string) use ($start, $finish) : string { |
|
72 | + return !$finish |
|
73 | 73 | ? substr($string, $start) |
74 | 74 | : substr($string, $start, $finish); |
75 | 75 | }; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string $string |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - return function (string $string) use ($prepend): string { |
|
90 | + return function(string $string) use ($prepend): string { |
|
91 | 91 | return \sprintf('%s%s', $prepend, $string); |
92 | 92 | }; |
93 | 93 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string $string |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - return function (string $string) use ($append): string { |
|
107 | + return function(string $string) use ($append): string { |
|
108 | 108 | return \sprintf('%s%s', $string, $append); |
109 | 109 | }; |
110 | 110 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param array<string, mixed> $values |
122 | 122 | * @return string Will return original string if false. |
123 | 123 | */ |
124 | - return function (array $values = array()) use ($template): string { |
|
124 | + return function(array $values = array()) use ($template): string { |
|
125 | 125 | return \vsprintf($template, $values); |
126 | 126 | }; |
127 | 127 | } |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @param string $replace value to replace with |
139 | 139 | * @return Closure(string):string |
140 | 140 | */ |
141 | - return function (string $replace) use ($find): Closure { |
|
141 | + return function(string $replace) use ($find): Closure { |
|
142 | 142 | /** |
143 | 143 | * @param string $subject String to carry out find and replace. |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - return function ($subject) use ($find, $replace): string { |
|
146 | + return function($subject) use ($find, $replace): string { |
|
147 | 147 | return \str_replace($find, $replace, $subject); |
148 | 148 | }; |
149 | 149 | }; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $source |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - return function ($source) use ($find, $replace): string { |
|
165 | + return function($source) use ($find, $replace): string { |
|
166 | 166 | return \str_replace($find, $replace, $source); |
167 | 167 | }; |
168 | 168 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param string $string |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - return function (string $string) use ($replace, $offset, $length): string { |
|
184 | + return function(string $string) use ($replace, $offset, $length) : string { |
|
185 | 185 | return $length |
186 | 186 | ? \substr_replace($string, $replace, $offset, $length) |
187 | 187 | : \substr_replace($string, $replace, $offset); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param string $source |
201 | 201 | * @return bool |
202 | 202 | */ |
203 | - return function (string $source) use ($find): bool { |
|
203 | + return function(string $source) use ($find): bool { |
|
204 | 204 | return (\substr($source, 0, \strlen($find)) === $find); |
205 | 205 | }; |
206 | 206 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param string $source |
218 | 218 | * @return bool |
219 | 219 | */ |
220 | - return function (string $source) use ($find): bool { |
|
220 | + return function(string $source) use ($find): bool { |
|
221 | 221 | if (\strlen($find) === 0) { |
222 | 222 | return true; |
223 | 223 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param string $haystack String to look in. |
238 | 238 | * @return bool |
239 | 239 | */ |
240 | - return function (string $haystack) use ($needle): bool { |
|
240 | + return function(string $haystack) use ($needle): bool { |
|
241 | 241 | return \stringContains($haystack, $needle); |
242 | 242 | }; |
243 | 243 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param string $source String to look in. |
255 | 255 | * @return bool |
256 | 256 | */ |
257 | - return function (string $source) use ($pattern): bool { |
|
257 | + return function(string $source) use ($pattern): bool { |
|
258 | 258 | return (bool) \preg_match($pattern, $source); |
259 | 259 | }; |
260 | 260 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string $name |
272 | 272 | * @return string[] |
273 | 273 | */ |
274 | - return function (string $string) use ($pattern): ?array { |
|
274 | + return function(string $string) use ($pattern): ?array { |
|
275 | 275 | return \preg_split($pattern, $string) ?: null; |
276 | 276 | }; |
277 | 277 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param string|int|float $number |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - return function ($number) use ($precision, $point, $thousands): string { |
|
293 | + return function($number) use ($precision, $point, $thousands): string { |
|
294 | 294 | return \is_numeric($number) |
295 | 295 | ? \number_format((float) $number, (int) $precision, $point, $thousands) |
296 | 296 | : ''; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $string The string to have char, slash escaped. |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - return function (string $string) use ($charList): string { |
|
314 | + return function(string $string) use ($charList): string { |
|
315 | 315 | return \addcslashes($string, $charList); |
316 | 316 | }; |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param string $string The string to be split |
329 | 329 | * @return array<int, string> |
330 | 330 | */ |
331 | - return function (string $string) use ($length): array { |
|
331 | + return function(string $string) use ($length): array { |
|
332 | 332 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
333 | 333 | }; |
334 | 334 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @param string $string The string to be chunked |
347 | 347 | * @return string |
348 | 348 | */ |
349 | - return function (string $string) use ($length, $end): string { |
|
349 | + return function(string $string) use ($length, $end): string { |
|
350 | 350 | return \chunk_split($string, max(1, $length), $end); |
351 | 351 | }; |
352 | 352 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param string $string The string to be wrapped |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - return function (string $string) use ($width, $break, $cut): string { |
|
368 | + return function(string $string) use ($width, $break, $cut): string { |
|
369 | 369 | return \wordwrap($string, $width, $break, $cut); |
370 | 370 | }; |
371 | 371 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | function countChars(int $mode = 1): Closure |
381 | 381 | { |
382 | 382 | // Throw an exception if the mode is not supported. |
383 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
383 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
384 | 384 | throw new \InvalidArgumentException('Invalid mode'); |
385 | 385 | } |
386 | 386 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @param string $string The string to have its char counted. |
389 | 389 | * @return int[]|string |
390 | 390 | */ |
391 | - return function (string $string) use ($mode) { |
|
391 | + return function(string $string) use ($mode) { |
|
392 | 392 | return \count_chars($string, $mode); |
393 | 393 | }; |
394 | 394 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $haystack |
408 | 408 | * @return int |
409 | 409 | */ |
410 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
410 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
411 | 411 | return $length |
412 | 412 | ? \substr_count($haystack, $needle, $offset, $length) |
413 | 413 | : \substr_count($haystack, $needle, $offset); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param string $string The string to be trimmed |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - return function (string $string) use ($mask): string { |
|
429 | + return function(string $string) use ($mask): string { |
|
430 | 430 | return \trim($string, $mask); |
431 | 431 | }; |
432 | 432 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @param string $string The string to be trimmed |
444 | 444 | * @return string |
445 | 445 | */ |
446 | - return function (string $string) use ($mask): string { |
|
446 | + return function(string $string) use ($mask): string { |
|
447 | 447 | return \ltrim($string, $mask); |
448 | 448 | }; |
449 | 449 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param string $string The string to be trimmed |
461 | 461 | * @return string |
462 | 462 | */ |
463 | - return function (string $string) use ($mask): string { |
|
463 | + return function(string $string) use ($mask): string { |
|
464 | 464 | return \rtrim($string, $mask); |
465 | 465 | }; |
466 | 466 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param string $comparisonString The string to compare against base. |
480 | 480 | * @return Number |
481 | 481 | */ |
482 | - return function (string $comparisonString) use ($base, $asPc) { |
|
482 | + return function(string $comparisonString) use ($base, $asPc) { |
|
483 | 483 | $pc = 0.00; |
484 | 484 | $matching = similar_text($base, $comparisonString, $pc); |
485 | 485 | return $asPc ? $pc : $matching; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @param string $comparisonString The string to act as the base. |
501 | 501 | * @return Number |
502 | 502 | */ |
503 | - return function (string $base) use ($comparisonString, $asPc) { |
|
503 | + return function(string $base) use ($comparisonString, $asPc) { |
|
504 | 504 | $pc = 0.00; |
505 | 505 | $matching = similar_text($base, $comparisonString, $pc); |
506 | 506 | return $asPc ? $pc : $matching; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @param string $string The string to pad out. |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - return function (string $string) use ($length, $padContent, $type): string { |
|
524 | + return function(string $string) use ($length, $padContent, $type): string { |
|
525 | 525 | return \str_pad($string, $length, $padContent, $type); |
526 | 526 | }; |
527 | 527 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @param string $string The string to repeat |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - return function (string $string) use ($count): string { |
|
541 | + return function(string $string) use ($count): string { |
|
542 | 542 | return \str_repeat($string, $count); |
543 | 543 | }; |
544 | 544 | } |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * @param string $string The string to pad out. |
557 | 557 | * @return int|string[] |
558 | 558 | */ |
559 | - return function (string $string) use ($format, $charList) { |
|
559 | + return function(string $string) use ($format, $charList) { |
|
560 | 560 | return $charList |
561 | 561 | ? (\str_word_count($string, $format, $charList) ?: 0) |
562 | 562 | : (\str_word_count($string, $format) ?: 0); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @param string $string The string to strip tags from. |
576 | 576 | * @return string |
577 | 577 | */ |
578 | - return function (string $string) use ($allowedTags): string { |
|
578 | + return function(string $string) use ($allowedTags) : string { |
|
579 | 579 | return $allowedTags |
580 | 580 | ? \strip_tags($string, $allowedTags) |
581 | 581 | : \strip_tags($string); |
@@ -592,13 +592,13 @@ discard block |
||
592 | 592 | */ |
593 | 593 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
594 | 594 | { |
595 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
595 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
596 | 596 | |
597 | 597 | /** |
598 | 598 | * @param string $haystack The haystack to look through. |
599 | 599 | * @return int|null |
600 | 600 | */ |
601 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
601 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
602 | 602 | $pos = $caseSensitive |
603 | 603 | ? strpos($haystack, $needle, $offset) |
604 | 604 | : stripos($haystack, $needle, $offset); |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | */ |
617 | 617 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
618 | 618 | { |
619 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
619 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
620 | 620 | |
621 | 621 | /** |
622 | 622 | * @param string $haystack The haystack to look through. |
623 | 623 | * @return int|null |
624 | 624 | */ |
625 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
625 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
626 | 626 | $pos = $caseSensitive |
627 | 627 | ? strrpos($haystack, $needle, $offset) |
628 | 628 | : strripos($haystack, $needle, $offset); |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | |
645 | 645 | // Decode flags, only look for none defaults. |
646 | 646 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
647 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
647 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
648 | 648 | |
649 | 649 | /** |
650 | 650 | * @param string $haystack The haystack to look through. |
651 | 651 | * @return string |
652 | 652 | */ |
653 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
653 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
654 | 654 | $result = $caseSensitive |
655 | 655 | ? strstr($haystack, $needle, $beforeNeedle) |
656 | 656 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @param string $haystack |
672 | 672 | * @return string |
673 | 673 | */ |
674 | - return function (string $haystack) use ($chars): string { |
|
674 | + return function(string $haystack) use ($chars): string { |
|
675 | 675 | $result = strpbrk($haystack, $chars); |
676 | 676 | return is_string($result) ? $result : ''; |
677 | 677 | }; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * @param string $haystack |
691 | 691 | * @return string |
692 | 692 | */ |
693 | - return function (string $haystack) use ($char): string { |
|
693 | + return function(string $haystack) use ($char): string { |
|
694 | 694 | $result = strrchr($haystack, $char); |
695 | 695 | return is_string($result) ? $result : ''; |
696 | 696 | }; |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @param string $haystack |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - return function (string $haystack) use ($dictionary): string { |
|
712 | + return function(string $haystack) use ($dictionary): string { |
|
713 | 713 | $result = strtr($haystack, $dictionary); |
714 | 714 | return $result; |
715 | 715 | }; |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * @param string|null $value |
740 | 740 | * @return Closure|string |
741 | 741 | */ |
742 | - return function (?string $value = null) use ($initial) { |
|
742 | + return function(?string $value = null) use ($initial) { |
|
743 | 743 | if ($value) { |
744 | 744 | $initial .= $value; |
745 | 745 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param Class $value |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - return function ($value) use ($class): bool { |
|
63 | + return function($value) use ($class): bool { |
|
64 | 64 | if (is_object($value)) { |
65 | 65 | $value = get_class($value); |
66 | 66 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param Class $class |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - return function ($class) use ($interface): bool { |
|
87 | + return function($class) use ($interface): bool { |
|
88 | 88 | return in_array( |
89 | 89 | $interface, |
90 | 90 | class_implements($class, false) ?: array(), |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | * @param object $object |
106 | 106 | * @return array<string, mixed> |
107 | 107 | */ |
108 | - return function ($object): array { |
|
108 | + return function($object): array { |
|
109 | 109 | |
110 | 110 | // If not object, return empty array. |
111 | - if (! is_object($object)) { |
|
111 | + if (!is_object($object)) { |
|
112 | 112 | return array(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $objectVars = get_object_vars($object); |
116 | 116 | return array_reduce( |
117 | 117 | array_keys($objectVars), |
118 | - function (array $array, $key) use ($objectVars): array { |
|
119 | - $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ]; |
|
118 | + function(array $array, $key) use ($objectVars): array { |
|
119 | + $array[ltrim((string) $key, '_')] = $objectVars[$key]; |
|
120 | 120 | return $array; |
121 | 121 | }, |
122 | 122 | array() |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param mixed $value Adds value start of array. |
47 | 47 | * @return array New array with value on head. |
48 | 48 | */ |
49 | - return function ($value) use ($array): array { |
|
49 | + return function($value) use ($array): array { |
|
50 | 50 | array_unshift($array, $value); |
51 | 51 | return $array; |
52 | 52 | }; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param mixed $value Adds value end of array. |
65 | 65 | * @return array<int|string, mixed> New array with value on tail. |
66 | 66 | */ |
67 | - return function ($value) use ($array): array { |
|
67 | + return function($value) use ($array): array { |
|
68 | 68 | $array[] = $value; |
69 | 69 | return $array; |
70 | 70 | }; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | function head(array $array) |
80 | 80 | { |
81 | - return ! empty($array) ? array_values($array)[0] : null; |
|
81 | + return !empty($array) ? array_values($array)[0] : null; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | function tail(array $array) |
91 | 91 | { |
92 | - return ! empty($array) ? array_reverse($array, false)[0] : null; |
|
92 | + return !empty($array) ? array_reverse($array, false)[0] : null; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param array<int|string, mixed> $array Array join |
107 | 107 | * @return string. |
108 | 108 | */ |
109 | - return function (array $array) use ($glue): string { |
|
109 | + return function(array $array) use ($glue) : string { |
|
110 | 110 | return $glue ? \join($glue, $array) : \join($array); |
111 | 111 | }; |
112 | 112 | } |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | function zip(array $additional, $default = null): Closure |
123 | 123 | { |
124 | 124 | $additional = array_values($additional); |
125 | - return function (array $array) use ($additional, $default) { |
|
125 | + return function(array $array) use ($additional, $default) { |
|
126 | 126 | $array = array_values($array); |
127 | 127 | return array_reduce( |
128 | 128 | array_keys($array), |
129 | - function ($carry, $key) use ($array, $additional, $default): array { |
|
129 | + function($carry, $key) use ($array, $additional, $default): array { |
|
130 | 130 | $carry[] = array( |
131 | - $array[ $key ], |
|
132 | - array_key_exists($key, $additional) ? $additional[ $key ] : $default, |
|
131 | + $array[$key], |
|
132 | + array_key_exists($key, $additional) ? $additional[$key] : $default, |
|
133 | 133 | ); |
134 | 134 | return $carry; |
135 | 135 | }, |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * @param mixed $value Adds value to inner array if value set, else returns. |
160 | 160 | * @return mixed[]|Closure |
161 | 161 | */ |
162 | - return function ($value = null) use ($inital) { |
|
162 | + return function($value = null) use ($inital) { |
|
163 | 163 | if ($value) { |
164 | 164 | $inital[] = $value; |
165 | 165 | } |
166 | - return ! is_null($value) ? arrayCompiler($inital) : $inital; |
|
166 | + return !is_null($value) ? arrayCompiler($inital) : $inital; |
|
167 | 167 | }; |
168 | 168 | } |
169 | 169 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @param mixed $value |
185 | 185 | * @return mixed[]|Closure |
186 | 186 | */ |
187 | - return function ($value = null) use ($validator, $inital) { |
|
188 | - if (! is_null($value) && $validator($value)) { |
|
187 | + return function($value = null) use ($validator, $inital) { |
|
188 | + if (!is_null($value) && $validator($value)) { |
|
189 | 189 | $inital[] = $value; |
190 | 190 | } |
191 | - return ! is_null($value) ? arrayCompilerTyped($validator, $inital) : $inital; |
|
191 | + return !is_null($value) ? arrayCompilerTyped($validator, $inital) : $inital; |
|
192 | 192 | }; |
193 | 193 | } |
194 | 194 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param array<int|string, mixed> $source Array to filter |
214 | 214 | * @return array<int|string, mixed> Filtered array. |
215 | 215 | */ |
216 | - return function (array $source) use ($callable): array { |
|
216 | + return function(array $source) use ($callable): array { |
|
217 | 217 | return array_filter($source, $callable); |
218 | 218 | }; |
219 | 219 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param array<int|string, mixed> $source Array to filter |
231 | 231 | * @return array<int|string, mixed> Filtered array. |
232 | 232 | */ |
233 | - return function (array $source) use ($callable): array { |
|
233 | + return function(array $source) use ($callable): array { |
|
234 | 234 | return array_filter($source, $callable, \ARRAY_FILTER_USE_KEY); |
235 | 235 | }; |
236 | 236 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param array<int|string, mixed> $source Array to filter |
249 | 249 | * @return array<int|string, mixed> Filtered array. |
250 | 250 | */ |
251 | - return function (array $source) use ($callables): array { |
|
251 | + return function(array $source) use ($callables): array { |
|
252 | 252 | return array_filter($source, Comp\groupAnd(...$callables)); |
253 | 253 | }; |
254 | 254 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @param array<int|string, mixed> $source Array to filter |
267 | 267 | * @return array<int|string, mixed> Filtered array. |
268 | 268 | */ |
269 | - return function (array $source) use ($callables): array { |
|
269 | + return function(array $source) use ($callables): array { |
|
270 | 270 | return array_filter($source, Comp\groupOr(...$callables)); |
271 | 271 | }; |
272 | 272 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param array<int|string, mixed> $array The array to filter |
284 | 284 | * @return mixed|null The first element from the filtered array or null if filter returns empty |
285 | 285 | */ |
286 | - return function (array $array) use ($func) { |
|
286 | + return function(array $array) use ($func) { |
|
287 | 287 | return head(array_filter($array, $func)); |
288 | 288 | }; |
289 | 289 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param array<int|string, mixed> $array The array to filter |
301 | 301 | * @return mixed|null The last element from the filtered array. |
302 | 302 | */ |
303 | - return function (array $array) use ($func) { |
|
303 | + return function(array $array) use ($func) { |
|
304 | 304 | return tail(array_filter($array, $func)); |
305 | 305 | }; |
306 | 306 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param array<int|string, mixed> $array The array to filter then map. |
321 | 321 | * @return array<int|string, mixed> |
322 | 322 | */ |
323 | - return function (array $array) use ($filter, $map): array { |
|
323 | + return function(array $array) use ($filter, $map): array { |
|
324 | 324 | return array_map($map, array_filter($array, $filter)); |
325 | 325 | }; |
326 | 326 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param array<int|string, mixed> $array |
338 | 338 | * @return int Count |
339 | 339 | */ |
340 | - return function (array $array) use ($function) { |
|
340 | + return function(array $array) use ($function) { |
|
341 | 341 | return count(array_filter($array, $function)); |
342 | 342 | }; |
343 | 343 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param mixed[] $array |
357 | 357 | * @return array{0:mixed[], 1:mixed[]} |
358 | 358 | */ |
359 | - return function (array $array) use ($function): array { |
|
359 | + return function(array $array) use ($function): array { |
|
360 | 360 | return array_reduce( |
361 | 361 | $array, |
362 | 362 | /** |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | * @param mixed $element |
365 | 365 | * @return array{0:mixed[], 1:mixed[]} |
366 | 366 | */ |
367 | - function ($carry, $element) use ($function): array { |
|
367 | + function($carry, $element) use ($function): array { |
|
368 | 368 | $key = (bool) $function($element) ? 1 : 0; |
369 | - $carry[ $key ][] = $element; |
|
369 | + $carry[$key][] = $element; |
|
370 | 370 | return $carry; |
371 | 371 | }, |
372 | - array( array(), array() ) |
|
372 | + array(array(), array()) |
|
373 | 373 | ); |
374 | 374 | }; |
375 | 375 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @param mixed[] $array |
387 | 387 | * @return bool |
388 | 388 | */ |
389 | - return function (array $array) use ($function): bool { |
|
389 | + return function(array $array) use ($function): bool { |
|
390 | 390 | foreach ($array as $value) { |
391 | 391 | if (false === $function($value)) { |
392 | 392 | return false; |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param mixed[] $array |
410 | 410 | * @return bool |
411 | 411 | */ |
412 | - return function (array $array) use ($function): bool { |
|
412 | + return function(array $array) use ($function): bool { |
|
413 | 413 | foreach ($array as $value) { |
414 | 414 | if (true === $function($value)) { |
415 | 415 | return true; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param mixed[] $array The array to map |
441 | 441 | * @return mixed[] |
442 | 442 | */ |
443 | - return function (array $array) use ($func): array { |
|
443 | + return function(array $array) use ($func): array { |
|
444 | 444 | return array_map($func, $array); |
445 | 445 | }; |
446 | 446 | } |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | * @param mixed[] $array The array to map |
459 | 459 | * @return mixed[] |
460 | 460 | */ |
461 | - return function (array $array) use ($func): array { |
|
461 | + return function(array $array) use ($func): array { |
|
462 | 462 | return array_reduce( |
463 | 463 | array_keys($array), |
464 | - function ($carry, $key) use ($func, $array) { |
|
465 | - $carry[ $func($key) ] = $array[ $key ]; |
|
464 | + function($carry, $key) use ($func, $array) { |
|
465 | + $carry[$func($key)] = $array[$key]; |
|
466 | 466 | return $carry; |
467 | 467 | }, |
468 | 468 | array() |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | * @param mixed[] $array The array to map |
484 | 484 | * @return mixed[] |
485 | 485 | */ |
486 | - return function (array $array) use ($func, $data): array { |
|
486 | + return function(array $array) use ($func, $data): array { |
|
487 | 487 | return array_map( |
488 | - function ($e) use ($data, $func) { |
|
488 | + function($e) use ($data, $func) { |
|
489 | 489 | return $func($e, ...$data); |
490 | 490 | }, |
491 | 491 | $array |
@@ -505,9 +505,9 @@ discard block |
||
505 | 505 | * @param mixed[] $array The array to map |
506 | 506 | * @return mixed[] |
507 | 507 | */ |
508 | - return function (array $array) use ($func): array { |
|
508 | + return function(array $array) use ($func): array { |
|
509 | 509 | return array_map( |
510 | - function ($key, $value) use ($func) { |
|
510 | + function($key, $value) use ($func) { |
|
511 | 511 | return $func($value, $key); |
512 | 512 | }, |
513 | 513 | $array, |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @param mixed[] $array |
530 | 530 | * @return mixed[] |
531 | 531 | */ |
532 | - return function (array $array) use ($n, $function): array { |
|
532 | + return function(array $array) use ($n, $function) : array { |
|
533 | 533 | return array_reduce( |
534 | 534 | $array, |
535 | 535 | /** |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @param mixed $element |
538 | 538 | * @return mixed[] |
539 | 539 | */ |
540 | - function (array $carry, $element) use ($n, $function): array { |
|
540 | + function(array $carry, $element) use ($n, $function) : array { |
|
541 | 541 | if (is_array($element) && (is_null($n) || $n > 0)) { |
542 | 542 | $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element)); |
543 | 543 | } else { |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @param mixed[] $array The array to be grouped |
570 | 570 | * @return mixed[] Grouped array. |
571 | 571 | */ |
572 | - return function (array $array) use ($function): array { |
|
572 | + return function(array $array) use ($function): array { |
|
573 | 573 | return array_reduce( |
574 | 574 | $array, |
575 | 575 | /** |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * @param mixed $element |
578 | 578 | * @return mixed[] |
579 | 579 | */ |
580 | - function ($carry, $item) use ($function): array { |
|
581 | - $carry[ call_user_func($function, $item) ][] = $item; |
|
580 | + function($carry, $item) use ($function): array { |
|
581 | + $carry[call_user_func($function, $item)][] = $item; |
|
582 | 582 | return $carry; |
583 | 583 | }, |
584 | 584 | array() |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * @param mixed[] $array Array to chunk |
600 | 600 | * @return mixed[] |
601 | 601 | */ |
602 | - return function (array $array) use ($count, $preserveKeys): array { |
|
602 | + return function(array $array) use ($count, $preserveKeys): array { |
|
603 | 603 | return array_chunk($array, max(1, $count), $preserveKeys); |
604 | 604 | }; |
605 | 605 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * @param mixed[] $array |
618 | 618 | * @return mixed[] |
619 | 619 | */ |
620 | - return function (array $array) use ($column, $key): array { |
|
620 | + return function(array $array) use ($column, $key) : array { |
|
621 | 621 | return array_column($array, $column, $key); |
622 | 622 | }; |
623 | 623 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * @param mixed[] $array Array to flatten |
635 | 635 | * @return mixed[] |
636 | 636 | */ |
637 | - return function (array $array) use ($n): array { |
|
637 | + return function(array $array) use ($n) : array { |
|
638 | 638 | return array_reduce( |
639 | 639 | $array, |
640 | 640 | /** |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @param mixed|mixed[] $element |
643 | 643 | * @return array<int|string, mixed> |
644 | 644 | */ |
645 | - function (array $carry, $element) use ($n): array { |
|
645 | + function(array $carry, $element) use ($n) : array { |
|
646 | 646 | // Remove empty arrays. |
647 | 647 | if (is_array($element) && empty($element)) { |
648 | 648 | return $carry; |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * @param mixed[] $array The array to have elements replaced from. |
674 | 674 | * @return mixed[] Array with replacements. |
675 | 675 | */ |
676 | - return function (array $array) use ($with): array { |
|
676 | + return function(array $array) use ($with): array { |
|
677 | 677 | return array_replace_recursive($array, ...$with); |
678 | 678 | }; |
679 | 679 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * @param mixed[] $array The array to have elements replaced from. |
691 | 691 | * @return mixed[] Array with replacements. |
692 | 692 | */ |
693 | - return function (array $array) use ($with): array { |
|
693 | + return function(array $array) use ($with): array { |
|
694 | 694 | return array_replace($array, ...$with); |
695 | 695 | }; |
696 | 696 | } |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param mixed[] $array Array to do sum() on. |
708 | 708 | * @return Number The total. |
709 | 709 | */ |
710 | - return function (array $array) use ($function) { |
|
710 | + return function(array $array) use ($function) { |
|
711 | 711 | return array_sum(array_map($function, $array)); |
712 | 712 | }; |
713 | 713 | } |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param mixed[] $array |
729 | 729 | * @return object |
730 | 730 | */ |
731 | - return function (array $array) use ($object): object { |
|
731 | + return function(array $array) use ($object): object { |
|
732 | 732 | foreach ($array as $key => $value) { |
733 | 733 | $key = is_string($key) ? $key : (string) $key; |
734 | 734 | $object->{$key} = $value; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | * @param mixed $data |
757 | 757 | * @return string|null |
758 | 758 | */ |
759 | - return function ($data) use ($flags, $depth): ?string { |
|
759 | + return function($data) use ($flags, $depth): ?string { |
|
760 | 760 | return \json_encode($data, $flags, max(1, $depth)) ?: null; |
761 | 761 | }; |
762 | 762 | } |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | * @param mixed[]$array The array to sort |
783 | 783 | * @return mixed[] The sorted array (new array) |
784 | 784 | */ |
785 | - return function (array $array) use ($flag) { |
|
785 | + return function(array $array) use ($flag) { |
|
786 | 786 | \sort($array, $flag); |
787 | 787 | return $array; |
788 | 788 | }; |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * @param mixed[]$array The array to sort |
802 | 802 | * @return mixed[] The sorted array (new array) |
803 | 803 | */ |
804 | - return function (array $array) use ($flag) { |
|
804 | + return function(array $array) use ($flag) { |
|
805 | 805 | \rsort($array, $flag); |
806 | 806 | return $array; |
807 | 807 | }; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | * @param mixed[]$array The array to sort |
821 | 821 | * @return mixed[] The sorted array (new array) |
822 | 822 | */ |
823 | - return function (array $array) use ($flag) { |
|
823 | + return function(array $array) use ($flag) { |
|
824 | 824 | \ksort($array, $flag); |
825 | 825 | return $array; |
826 | 826 | }; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * @param mixed[]$array The array to sort |
839 | 839 | * @return mixed[] The sorted array (new array) |
840 | 840 | */ |
841 | - return function (array $array) use ($flag) { |
|
841 | + return function(array $array) use ($flag) { |
|
842 | 842 | \krsort($array, $flag); |
843 | 843 | return $array; |
844 | 844 | }; |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | * @param mixed[]$array The array to sort |
858 | 858 | * @return mixed[] The sorted array (new array) |
859 | 859 | */ |
860 | - return function (array $array) use ($flag) { |
|
860 | + return function(array $array) use ($flag) { |
|
861 | 861 | \asort($array, $flag); |
862 | 862 | return $array; |
863 | 863 | }; |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | * @param mixed[]$array The array to sort |
877 | 877 | * @return mixed[] The sorted array (new array) |
878 | 878 | */ |
879 | - return function (array $array) use ($flag) { |
|
879 | + return function(array $array) use ($flag) { |
|
880 | 880 | \arsort($array, $flag); |
881 | 881 | return $array; |
882 | 882 | }; |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @param mixed[]$array The array to sort |
894 | 894 | * @return mixed[] The sorted array (new array) |
895 | 895 | */ |
896 | - return function (array $array) { |
|
896 | + return function(array $array) { |
|
897 | 897 | \natsort($array); |
898 | 898 | return $array; |
899 | 899 | }; |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | * @param mixed[]$array The array to sort |
911 | 911 | * @return mixed[] The sorted array (new array) |
912 | 912 | */ |
913 | - return function (array $array) { |
|
913 | + return function(array $array) { |
|
914 | 914 | \natcasesort($array); |
915 | 915 | return $array; |
916 | 916 | }; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @param mixed[] $array The array to sort |
929 | 929 | * @return mixed[] The sorted array (new array) |
930 | 930 | */ |
931 | - return function (array $array) use ($function) { |
|
931 | + return function(array $array) use ($function) { |
|
932 | 932 | \uksort($array, $function); |
933 | 933 | return $array; |
934 | 934 | }; |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * @param mixed[]$array The array to sort |
948 | 948 | * @return mixed[] The sorted array (new array) |
949 | 949 | */ |
950 | - return function (array $array) use ($function) { |
|
950 | + return function(array $array) use ($function) { |
|
951 | 951 | \uasort($array, $function); |
952 | 952 | return $array; |
953 | 953 | }; |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | * @param mixed[]$array The array to sort |
968 | 968 | * @return mixed[] The sorted array (new array) |
969 | 969 | */ |
970 | - return function (array $array) use ($function) { |
|
970 | + return function(array $array) use ($function) { |
|
971 | 971 | \usort($array, $function); |
972 | 972 | return $array; |
973 | 973 | }; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | */ |
983 | 983 | function scan(callable $function, $initialValue): Closure |
984 | 984 | { |
985 | - return function (array $array) use ($function, $initialValue) { |
|
985 | + return function(array $array) use ($function, $initialValue) { |
|
986 | 986 | $carry[] = $initialValue; |
987 | 987 | foreach ($array as $key => $value) { |
988 | 988 | $initialValue = $function($initialValue, $value); |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | */ |
1002 | 1002 | function scanR(callable $function, $initialValue): Closure |
1003 | 1003 | { |
1004 | - return function (array $array) use ($function, $initialValue) { |
|
1004 | + return function(array $array) use ($function, $initialValue) { |
|
1005 | 1005 | $carry[] = $initialValue; |
1006 | 1006 | foreach (array_reverse($array) as $key => $value) { |
1007 | 1007 | $initialValue = $function($initialValue, $value); |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | * @param mixed[] $array |
1025 | 1025 | * @return mixed |
1026 | 1026 | */ |
1027 | - return function (array $array) use ($callable, $initial) { |
|
1027 | + return function(array $array) use ($callable, $initial) { |
|
1028 | 1028 | return array_reduce($array, $callable, $initial); |
1029 | 1029 | }; |
1030 | 1030 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | * @param mixed[] $array |
1043 | 1043 | * @return mixed |
1044 | 1044 | */ |
1045 | - return function (array $array) use ($callable, $initial) { |
|
1045 | + return function(array $array) use ($callable, $initial) { |
|
1046 | 1046 | return array_reduce(\array_reverse($array), $callable, $initial); |
1047 | 1047 | }; |
1048 | 1048 | } |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * @param mixed[] $array |
1062 | 1062 | * @return mixed |
1063 | 1063 | */ |
1064 | - return function (array $array) use ($callable, $initial) { |
|
1064 | + return function(array $array) use ($callable, $initial) { |
|
1065 | 1065 | foreach ($array as $key => $value) { |
1066 | 1066 | $initial = $callable($initial, $key, $value); |
1067 | 1067 | } |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * @param mixed[] $array |
1088 | 1088 | * @return mixed[] |
1089 | 1089 | */ |
1090 | - return function (array $array) use ($count) { |
|
1090 | + return function(array $array) use ($count) { |
|
1091 | 1091 | return \array_slice($array, 0, $count); |
1092 | 1092 | }; |
1093 | 1093 | } |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | // If count is 0, return an empty array |
1110 | 1110 | if ($count === 0) { |
1111 | - return function (array $array) { |
|
1111 | + return function(array $array) { |
|
1112 | 1112 | return array(); |
1113 | 1113 | }; |
1114 | 1114 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | * @param mixed[] $array |
1118 | 1118 | * @return mixed[] |
1119 | 1119 | */ |
1120 | - return function (array $array) use ($count) { |
|
1120 | + return function(array $array) use ($count) { |
|
1121 | 1121 | return \array_slice($array, - $count); |
1122 | 1122 | }; |
1123 | 1123 | } |
@@ -1135,13 +1135,13 @@ discard block |
||
1135 | 1135 | * @param mixed[] $array |
1136 | 1136 | * @return mixed[] |
1137 | 1137 | */ |
1138 | - return function (array $array) use ($conditional) { |
|
1138 | + return function(array $array) use ($conditional) { |
|
1139 | 1139 | $carry = array(); |
1140 | 1140 | foreach ($array as $key => $value) { |
1141 | 1141 | if (true === $conditional($value)) { |
1142 | 1142 | break; |
1143 | 1143 | } |
1144 | - $carry[ $key ] = $value; |
|
1144 | + $carry[$key] = $value; |
|
1145 | 1145 | } |
1146 | 1146 | return $carry; |
1147 | 1147 | }; |
@@ -1160,13 +1160,13 @@ discard block |
||
1160 | 1160 | * @param mixed[] $array |
1161 | 1161 | * @return mixed[] |
1162 | 1162 | */ |
1163 | - return function (array $array) use ($conditional) { |
|
1163 | + return function(array $array) use ($conditional) { |
|
1164 | 1164 | $carry = array(); |
1165 | 1165 | foreach ($array as $key => $value) { |
1166 | 1166 | if (false === $conditional($value)) { |
1167 | 1167 | break; |
1168 | 1168 | } |
1169 | - $carry[ $key ] = $value; |
|
1169 | + $carry[$key] = $value; |
|
1170 | 1170 | } |
1171 | 1171 | return $carry; |
1172 | 1172 | }; |