@@ -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 | * |
@@ -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 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $string |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - return function (string $string) use ($openingTag, $closingTag): string { |
|
70 | + return function(string $string) use ($openingTag, $closingTag) : string { |
|
71 | 71 | return \sprintf('<%s>%s</%s>', $openingTag, $string, $closingTag ?? $openingTag); |
72 | 72 | }; |
73 | 73 | } |
@@ -85,15 +85,14 @@ discard block |
||
85 | 85 | * @param string $string |
86 | 86 | * @return string |
87 | 87 | */ |
88 | - return function (string $string) use ($url, $target): string { |
|
88 | + return function(string $string) use ($url, $target) : string { |
|
89 | 89 | return $target ? |
90 | 90 | \sprintf( |
91 | 91 | "<a href='%s' target='%s'>%s</a>", |
92 | 92 | $url, |
93 | 93 | $target, |
94 | 94 | $string |
95 | - ) : |
|
96 | - \sprintf( |
|
95 | + ) : \sprintf( |
|
97 | 96 | "<a href='%s'>%s</a>", |
98 | 97 | $url, |
99 | 98 | $string |
@@ -117,8 +116,8 @@ discard block |
||
117 | 116 | * @param string $string |
118 | 117 | * @return string |
119 | 118 | */ |
120 | - return function (string $string) use ($start, $finish): string { |
|
121 | - return ! $finish |
|
119 | + return function(string $string) use ($start, $finish) : string { |
|
120 | + return !$finish |
|
122 | 121 | ? substr($string, $start) |
123 | 122 | : substr($string, $start, $finish); |
124 | 123 | }; |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | * @param string $string |
137 | 136 | * @return string |
138 | 137 | */ |
139 | - return function (string $string) use ($prepend): string { |
|
138 | + return function(string $string) use ($prepend): string { |
|
140 | 139 | return \sprintf('%s%s', $prepend, $string); |
141 | 140 | }; |
142 | 141 | } |
@@ -153,7 +152,7 @@ discard block |
||
153 | 152 | * @param string $string |
154 | 153 | * @return string |
155 | 154 | */ |
156 | - return function (string $string) use ($append): string { |
|
155 | + return function(string $string) use ($append): string { |
|
157 | 156 | return \sprintf('%s%s', $string, $append); |
158 | 157 | }; |
159 | 158 | } |
@@ -170,9 +169,9 @@ discard block |
||
170 | 169 | * @param string $string |
171 | 170 | * @return string Will return original string if false. |
172 | 171 | */ |
173 | - return function (string $string) use ($args): string { |
|
172 | + return function(string $string) use ($args): string { |
|
174 | 173 | $result = \vsprintf($string, $args); |
175 | - return ! C\isFalse($result) ? $result : $string; |
|
174 | + return !C\isFalse($result) ? $result : $string; |
|
176 | 175 | }; |
177 | 176 | } |
178 | 177 | |
@@ -188,12 +187,12 @@ discard block |
||
188 | 187 | * @param string $replace value to replace with |
189 | 188 | * @return Closure(string):string |
190 | 189 | */ |
191 | - return function (string $replace) use ($find): Closure { |
|
190 | + return function(string $replace) use ($find): Closure { |
|
192 | 191 | /** |
193 | 192 | * @param string $subject String to carry out find and replace. |
194 | 193 | * @return string |
195 | 194 | */ |
196 | - return function ($subject) use ($find, $replace): string { |
|
195 | + return function($subject) use ($find, $replace): string { |
|
197 | 196 | return \str_replace($find, $replace, $subject); |
198 | 197 | }; |
199 | 198 | }; |
@@ -212,7 +211,7 @@ discard block |
||
212 | 211 | * @param string $source |
213 | 212 | * @return string |
214 | 213 | */ |
215 | - return function ($source) use ($find, $replace): string { |
|
214 | + return function($source) use ($find, $replace): string { |
|
216 | 215 | return \str_replace($find, $replace, $source); |
217 | 216 | }; |
218 | 217 | } |
@@ -231,7 +230,7 @@ discard block |
||
231 | 230 | * @param string $string |
232 | 231 | * @return string |
233 | 232 | */ |
234 | - return function (string $string) use ($replace, $offset, $length): string { |
|
233 | + return function(string $string) use ($replace, $offset, $length) : string { |
|
235 | 234 | return $length |
236 | 235 | ? \substr_replace($string, $replace, $offset, $length) |
237 | 236 | : \substr_replace($string, $replace, $offset); |
@@ -250,7 +249,7 @@ discard block |
||
250 | 249 | * @param string $source |
251 | 250 | * @return bool |
252 | 251 | */ |
253 | - return function (string $source) use ($find): bool { |
|
252 | + return function(string $source) use ($find): bool { |
|
254 | 253 | return (\substr($source, 0, \strlen($find)) === $find); |
255 | 254 | }; |
256 | 255 | } |
@@ -267,7 +266,7 @@ discard block |
||
267 | 266 | * @param string $source |
268 | 267 | * @return bool |
269 | 268 | */ |
270 | - return function (string $source) use ($find): bool { |
|
269 | + return function(string $source) use ($find): bool { |
|
271 | 270 | if (\strlen($find) === 0) { |
272 | 271 | return true; |
273 | 272 | } |
@@ -287,7 +286,7 @@ discard block |
||
287 | 286 | * @param string $haystack String to look in. |
288 | 287 | * @return bool |
289 | 288 | */ |
290 | - return function (string $haystack) use ($needle): bool { |
|
289 | + return function(string $haystack) use ($needle): bool { |
|
291 | 290 | return \stringContains($haystack, $needle); |
292 | 291 | }; |
293 | 292 | } |
@@ -304,7 +303,7 @@ discard block |
||
304 | 303 | * @param string $source String to look in. |
305 | 304 | * @return bool |
306 | 305 | */ |
307 | - return function (string $source) use ($pattern): bool { |
|
306 | + return function(string $source) use ($pattern): bool { |
|
308 | 307 | return (bool) \preg_match($pattern, $source); |
309 | 308 | }; |
310 | 309 | } |
@@ -321,7 +320,7 @@ discard block |
||
321 | 320 | * @param string $name |
322 | 321 | * @return string[] |
323 | 322 | */ |
324 | - return function (string $string) use ($pattern): ?array { |
|
323 | + return function(string $string) use ($pattern): ?array { |
|
325 | 324 | return \preg_split($pattern, $string) ?: null; |
326 | 325 | }; |
327 | 326 | } |
@@ -340,7 +339,7 @@ discard block |
||
340 | 339 | * @param string|int|float $number |
341 | 340 | * @return string |
342 | 341 | */ |
343 | - return function ($number) use ($precision, $point, $thousands): string { |
|
342 | + return function($number) use ($precision, $point, $thousands): string { |
|
344 | 343 | return \is_numeric($number) |
345 | 344 | ? \number_format((float) $number, (int) $precision, $point, $thousands) |
346 | 345 | : ''; |
@@ -361,7 +360,7 @@ discard block |
||
361 | 360 | * @param string $string The string to have char, slash escaped. |
362 | 361 | * @return string |
363 | 362 | */ |
364 | - return function (string $string) use ($charList): string { |
|
363 | + return function(string $string) use ($charList): string { |
|
365 | 364 | return \addcslashes($string, $charList); |
366 | 365 | }; |
367 | 366 | } |
@@ -378,7 +377,7 @@ discard block |
||
378 | 377 | * @param string $string The string to be split |
379 | 378 | * @return array<int, string> |
380 | 379 | */ |
381 | - return function (string $string) use ($length): array { |
|
380 | + return function(string $string) use ($length): array { |
|
382 | 381 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
383 | 382 | }; |
384 | 383 | } |
@@ -396,7 +395,7 @@ discard block |
||
396 | 395 | * @param string $string The string to be chunked |
397 | 396 | * @return string |
398 | 397 | */ |
399 | - return function (string $string) use ($length, $end): string { |
|
398 | + return function(string $string) use ($length, $end): string { |
|
400 | 399 | return \chunk_split($string, max(1, $length), $end); |
401 | 400 | }; |
402 | 401 | } |
@@ -415,7 +414,7 @@ discard block |
||
415 | 414 | * @param string $string The string to be wrapped |
416 | 415 | * @return string |
417 | 416 | */ |
418 | - return function (string $string) use ($width, $break, $cut): string { |
|
417 | + return function(string $string) use ($width, $break, $cut): string { |
|
419 | 418 | return \wordwrap($string, $width, $break, $cut); |
420 | 419 | }; |
421 | 420 | } |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | function countChars(int $mode = 1): Closure |
431 | 430 | { |
432 | 431 | // Throw an exception if the mode is not supported. |
433 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
432 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
434 | 433 | throw new \InvalidArgumentException('Invalid mode'); |
435 | 434 | } |
436 | 435 | |
@@ -438,7 +437,7 @@ discard block |
||
438 | 437 | * @param string $string The string to have its char counted. |
439 | 438 | * @return int[]|string |
440 | 439 | */ |
441 | - return function (string $string) use ($mode) { |
|
440 | + return function(string $string) use ($mode) { |
|
442 | 441 | return \count_chars($string, $mode); |
443 | 442 | }; |
444 | 443 | } |
@@ -457,7 +456,7 @@ discard block |
||
457 | 456 | * @param string $haystack |
458 | 457 | * @return int |
459 | 458 | */ |
460 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
459 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
461 | 460 | return $length |
462 | 461 | ? \substr_count($haystack, $needle, $offset, $length) |
463 | 462 | : \substr_count($haystack, $needle, $offset); |
@@ -476,7 +475,7 @@ discard block |
||
476 | 475 | * @param string $string The string to be trimmed |
477 | 476 | * @return string |
478 | 477 | */ |
479 | - return function (string $string) use ($mask): string { |
|
478 | + return function(string $string) use ($mask): string { |
|
480 | 479 | return \trim($string, $mask); |
481 | 480 | }; |
482 | 481 | } |
@@ -493,7 +492,7 @@ discard block |
||
493 | 492 | * @param string $string The string to be trimmed |
494 | 493 | * @return string |
495 | 494 | */ |
496 | - return function (string $string) use ($mask): string { |
|
495 | + return function(string $string) use ($mask): string { |
|
497 | 496 | return \ltrim($string, $mask); |
498 | 497 | }; |
499 | 498 | } |
@@ -510,7 +509,7 @@ discard block |
||
510 | 509 | * @param string $string The string to be trimmed |
511 | 510 | * @return string |
512 | 511 | */ |
513 | - return function (string $string) use ($mask): string { |
|
512 | + return function(string $string) use ($mask): string { |
|
514 | 513 | return \rtrim($string, $mask); |
515 | 514 | }; |
516 | 515 | } |
@@ -529,7 +528,7 @@ discard block |
||
529 | 528 | * @param string $comparisonString The string to compare against base. |
530 | 529 | * @return Number |
531 | 530 | */ |
532 | - return function (string $comparisonString) use ($base, $asPc) { |
|
531 | + return function(string $comparisonString) use ($base, $asPc) { |
|
533 | 532 | $pc = 0.00; |
534 | 533 | $matching = similar_text($base, $comparisonString, $pc); |
535 | 534 | return $asPc ? $pc : $matching; |
@@ -550,7 +549,7 @@ discard block |
||
550 | 549 | * @param string $comparisonString The string to act as the base. |
551 | 550 | * @return Number |
552 | 551 | */ |
553 | - return function (string $base) use ($comparisonString, $asPc) { |
|
552 | + return function(string $base) use ($comparisonString, $asPc) { |
|
554 | 553 | $pc = 0.00; |
555 | 554 | $matching = similar_text($base, $comparisonString, $pc); |
556 | 555 | return $asPc ? $pc : $matching; |
@@ -571,7 +570,7 @@ discard block |
||
571 | 570 | * @param string $string The string to pad out. |
572 | 571 | * @return string |
573 | 572 | */ |
574 | - return function (string $string) use ($length, $padContent, $type): string { |
|
573 | + return function(string $string) use ($length, $padContent, $type): string { |
|
575 | 574 | return \str_pad($string, $length, $padContent, $type); |
576 | 575 | }; |
577 | 576 | } |
@@ -588,7 +587,7 @@ discard block |
||
588 | 587 | * @param string $string The string to repeat |
589 | 588 | * @return string |
590 | 589 | */ |
591 | - return function (string $string) use ($count): string { |
|
590 | + return function(string $string) use ($count): string { |
|
592 | 591 | return \str_repeat($string, $count); |
593 | 592 | }; |
594 | 593 | } |
@@ -606,7 +605,7 @@ discard block |
||
606 | 605 | * @param string $string The string to pad out. |
607 | 606 | * @return int|string[] |
608 | 607 | */ |
609 | - return function (string $string) use ($format, $charList) { |
|
608 | + return function(string $string) use ($format, $charList) { |
|
610 | 609 | return $charList |
611 | 610 | ? (\str_word_count($string, $format, $charList) ?: 0) |
612 | 611 | : (\str_word_count($string, $format) ?: 0); |
@@ -625,7 +624,7 @@ discard block |
||
625 | 624 | * @param string $string The string to strip tags from. |
626 | 625 | * @return string |
627 | 626 | */ |
628 | - return function (string $string) use ($allowedTags): string { |
|
627 | + return function(string $string) use ($allowedTags) : string { |
|
629 | 628 | return $allowedTags |
630 | 629 | ? \strip_tags($string, $allowedTags) |
631 | 630 | : \strip_tags($string); |
@@ -642,13 +641,13 @@ discard block |
||
642 | 641 | */ |
643 | 642 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
644 | 643 | { |
645 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
644 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
646 | 645 | |
647 | 646 | /** |
648 | 647 | * @param string $haystack The haystack to look through. |
649 | 648 | * @return int|null |
650 | 649 | */ |
651 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
650 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
652 | 651 | $pos = $caseSensitive |
653 | 652 | ? strpos($haystack, $needle, $offset) |
654 | 653 | : stripos($haystack, $needle, $offset); |
@@ -666,13 +665,13 @@ discard block |
||
666 | 665 | */ |
667 | 666 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
668 | 667 | { |
669 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
668 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
670 | 669 | |
671 | 670 | /** |
672 | 671 | * @param string $haystack The haystack to look through. |
673 | 672 | * @return int|null |
674 | 673 | */ |
675 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
674 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
676 | 675 | $pos = $caseSensitive |
677 | 676 | ? strrpos($haystack, $needle, $offset) |
678 | 677 | : strripos($haystack, $needle, $offset); |
@@ -694,13 +693,13 @@ discard block |
||
694 | 693 | |
695 | 694 | // Decode flags, only look for none defaults. |
696 | 695 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
697 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
696 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
698 | 697 | |
699 | 698 | /** |
700 | 699 | * @param string $haystack The haystack to look through. |
701 | 700 | * @return string |
702 | 701 | */ |
703 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
702 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
704 | 703 | $result = $caseSensitive |
705 | 704 | ? strstr($haystack, $needle, $beforeNeedle) |
706 | 705 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -721,7 +720,7 @@ discard block |
||
721 | 720 | * @param string $haystack |
722 | 721 | * @return string |
723 | 722 | */ |
724 | - return function (string $haystack) use ($chars): string { |
|
723 | + return function(string $haystack) use ($chars): string { |
|
725 | 724 | $result = strpbrk($haystack, $chars); |
726 | 725 | return is_string($result) ? $result : ''; |
727 | 726 | }; |
@@ -740,7 +739,7 @@ discard block |
||
740 | 739 | * @param string $haystack |
741 | 740 | * @return string |
742 | 741 | */ |
743 | - return function (string $haystack) use ($char): string { |
|
742 | + return function(string $haystack) use ($char): string { |
|
744 | 743 | $result = strrchr($haystack, $char); |
745 | 744 | return is_string($result) ? $result : ''; |
746 | 745 | }; |
@@ -759,7 +758,7 @@ discard block |
||
759 | 758 | * @param string $haystack |
760 | 759 | * @return string |
761 | 760 | */ |
762 | - return function (string $haystack) use ($dictionary): string { |
|
761 | + return function(string $haystack) use ($dictionary): string { |
|
763 | 762 | $result = strtr($haystack, $dictionary); |
764 | 763 | return $result; |
765 | 764 | }; |
@@ -789,7 +788,7 @@ discard block |
||
789 | 788 | * @param string|null $value |
790 | 789 | * @return Closure|string |
791 | 790 | */ |
792 | - return function (?string $value = null) use ($initial) { |
|
791 | + return function(?string $value = null) use ($initial) { |
|
793 | 792 | if ($value) { |
794 | 793 | $initial .= $value; |
795 | 794 | } |
@@ -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 | } |
@@ -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 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param array<int|string, mixed> $source Array to filter |
250 | 250 | * @return array<int|string, mixed> Filtered array. |
251 | 251 | */ |
252 | - return function (array $source) use ($callables): array { |
|
252 | + return function(array $source) use ($callables): array { |
|
253 | 253 | return array_filter($source, Comp\groupAnd(...$callables)); |
254 | 254 | }; |
255 | 255 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param array<int|string, mixed> $source Array to filter |
268 | 268 | * @return array<int|string, mixed> Filtered array. |
269 | 269 | */ |
270 | - return function (array $source) use ($callables): array { |
|
270 | + return function(array $source) use ($callables): array { |
|
271 | 271 | return array_filter($source, Comp\groupOr(...$callables)); |
272 | 272 | }; |
273 | 273 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param array<int|string, mixed> $array The array to filter |
285 | 285 | * @return mixed|null The first element from the filtered array or null if filter returns empty |
286 | 286 | */ |
287 | - return function (array $array) use ($func) { |
|
287 | + return function(array $array) use ($func) { |
|
288 | 288 | return head(array_filter($array, $func)); |
289 | 289 | }; |
290 | 290 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param array<int|string, mixed> $array The array to filter |
302 | 302 | * @return mixed|null The last element from the filtered array. |
303 | 303 | */ |
304 | - return function (array $array) use ($func) { |
|
304 | + return function(array $array) use ($func) { |
|
305 | 305 | return tail(array_filter($array, $func)); |
306 | 306 | }; |
307 | 307 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param array<int|string, mixed> $array The array to filter then map. |
322 | 322 | * @return array<int|string, mixed> |
323 | 323 | */ |
324 | - return function (array $array) use ($filter, $map): array { |
|
324 | + return function(array $array) use ($filter, $map): array { |
|
325 | 325 | return array_map($map, array_filter($array, $filter)); |
326 | 326 | }; |
327 | 327 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * @param array<int|string, mixed> $array |
339 | 339 | * @return int Count |
340 | 340 | */ |
341 | - return function (array $array) use ($function) { |
|
341 | + return function(array $array) use ($function) { |
|
342 | 342 | return count(array_filter($array, $function)); |
343 | 343 | }; |
344 | 344 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param mixed[] $array |
358 | 358 | * @return array{0:mixed[], 1:mixed[]} |
359 | 359 | */ |
360 | - return function (array $array) use ($function): array { |
|
360 | + return function(array $array) use ($function): array { |
|
361 | 361 | return array_reduce( |
362 | 362 | $array, |
363 | 363 | /** |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | * @param mixed $element |
366 | 366 | * @return array{0:mixed[], 1:mixed[]} |
367 | 367 | */ |
368 | - function ($carry, $element) use ($function): array { |
|
368 | + function($carry, $element) use ($function): array { |
|
369 | 369 | $key = (bool) $function($element) ? 1 : 0; |
370 | - $carry[ $key ][] = $element; |
|
370 | + $carry[$key][] = $element; |
|
371 | 371 | return $carry; |
372 | 372 | }, |
373 | - array( array(), array() ) |
|
373 | + array(array(), array()) |
|
374 | 374 | ); |
375 | 375 | }; |
376 | 376 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param mixed[] $array The array to map |
400 | 400 | * @return mixed[] |
401 | 401 | */ |
402 | - return function (array $array) use ($func): array { |
|
402 | + return function(array $array) use ($func): array { |
|
403 | 403 | return array_map($func, $array); |
404 | 404 | }; |
405 | 405 | } |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | * @param mixed[] $array The array to map |
418 | 418 | * @return mixed[] |
419 | 419 | */ |
420 | - return function (array $array) use ($func): array { |
|
420 | + return function(array $array) use ($func): array { |
|
421 | 421 | return array_reduce( |
422 | 422 | array_keys($array), |
423 | - function ($carry, $key) use ($func, $array) { |
|
424 | - $carry[ $func($key) ] = $array[ $key ]; |
|
423 | + function($carry, $key) use ($func, $array) { |
|
424 | + $carry[$func($key)] = $array[$key]; |
|
425 | 425 | return $carry; |
426 | 426 | }, |
427 | 427 | array() |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * @param mixed[] $array The array to map |
443 | 443 | * @return mixed[] |
444 | 444 | */ |
445 | - return function (array $array) use ($func, $data): array { |
|
445 | + return function(array $array) use ($func, $data): array { |
|
446 | 446 | return array_map( |
447 | - function ($e) use ($data, $func) { |
|
447 | + function($e) use ($data, $func) { |
|
448 | 448 | return $func($e, ...$data); |
449 | 449 | }, |
450 | 450 | $array |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @param mixed[] $array |
466 | 466 | * @return mixed[] |
467 | 467 | */ |
468 | - return function (array $array) use ($n, $function): array { |
|
468 | + return function(array $array) use ($n, $function) : array { |
|
469 | 469 | return array_reduce( |
470 | 470 | $array, |
471 | 471 | /** |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param mixed $element |
474 | 474 | * @return mixed[] |
475 | 475 | */ |
476 | - function (array $carry, $element) use ($n, $function): array { |
|
476 | + function(array $carry, $element) use ($n, $function) : array { |
|
477 | 477 | if (is_array($element) && (is_null($n) || $n > 0)) { |
478 | 478 | $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element)); |
479 | 479 | } else { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param mixed[] $array The array to be grouped |
506 | 506 | * @return mixed[] Grouped array. |
507 | 507 | */ |
508 | - return function (array $array) use ($function): array { |
|
508 | + return function(array $array) use ($function): array { |
|
509 | 509 | return array_reduce( |
510 | 510 | $array, |
511 | 511 | /** |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | * @param mixed $element |
514 | 514 | * @return mixed[] |
515 | 515 | */ |
516 | - function ($carry, $item) use ($function): array { |
|
517 | - $carry[ call_user_func($function, $item) ][] = $item; |
|
516 | + function($carry, $item) use ($function): array { |
|
517 | + $carry[call_user_func($function, $item)][] = $item; |
|
518 | 518 | return $carry; |
519 | 519 | }, |
520 | 520 | array() |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * @param mixed[] $array Array to chunk |
536 | 536 | * @return mixed[] |
537 | 537 | */ |
538 | - return function (array $array) use ($count, $preserveKeys): array { |
|
538 | + return function(array $array) use ($count, $preserveKeys): array { |
|
539 | 539 | return array_chunk($array, max(1, $count), $preserveKeys); |
540 | 540 | }; |
541 | 541 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @param mixed[] $array |
554 | 554 | * @return mixed[] |
555 | 555 | */ |
556 | - return function (array $array) use ($column, $key): array { |
|
556 | + return function(array $array) use ($column, $key) : array { |
|
557 | 557 | return array_column($array, $column, $key); |
558 | 558 | }; |
559 | 559 | } |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @param mixed[] $array Array to flatten |
571 | 571 | * @return mixed[] |
572 | 572 | */ |
573 | - return function (array $array) use ($n): array { |
|
573 | + return function(array $array) use ($n) : array { |
|
574 | 574 | return array_reduce( |
575 | 575 | $array, |
576 | 576 | /** |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @param mixed|mixed[] $element |
579 | 579 | * @return array<int|string, mixed> |
580 | 580 | */ |
581 | - function (array $carry, $element) use ($n): array { |
|
581 | + function(array $carry, $element) use ($n) : array { |
|
582 | 582 | // Remove empty arrays. |
583 | 583 | if (is_array($element) && empty($element)) { |
584 | 584 | return $carry; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * @param mixed[] $array The array to have elements replaced from. |
610 | 610 | * @return mixed[] Array with replacements. |
611 | 611 | */ |
612 | - return function (array $array) use ($with): array { |
|
612 | + return function(array $array) use ($with): array { |
|
613 | 613 | return array_replace_recursive($array, ...$with); |
614 | 614 | }; |
615 | 615 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param mixed[] $array The array to have elements replaced from. |
627 | 627 | * @return mixed[] Array with replacements. |
628 | 628 | */ |
629 | - return function (array $array) use ($with): array { |
|
629 | + return function(array $array) use ($with): array { |
|
630 | 630 | return array_replace($array, ...$with); |
631 | 631 | }; |
632 | 632 | } |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | * @param mixed[] $array Array to do sum() on. |
644 | 644 | * @return Number The total. |
645 | 645 | */ |
646 | - return function (array $array) use ($function) { |
|
646 | + return function(array $array) use ($function) { |
|
647 | 647 | return array_sum(array_map($function, $array)); |
648 | 648 | }; |
649 | 649 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @param mixed[] $array |
665 | 665 | * @return object |
666 | 666 | */ |
667 | - return function (array $array) use ($object): object { |
|
667 | + return function(array $array) use ($object): object { |
|
668 | 668 | foreach ($array as $key => $value) { |
669 | 669 | $key = is_string($key) ? $key : (string) $key; |
670 | 670 | $object->{$key} = $value; |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param mixed $data |
693 | 693 | * @return string|null |
694 | 694 | */ |
695 | - return function ($data) use ($flags, $depth): ?string { |
|
695 | + return function($data) use ($flags, $depth): ?string { |
|
696 | 696 | return \json_encode($data, $flags, max(1, $depth)) ?: null; |
697 | 697 | }; |
698 | 698 | } |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * @param mixed[]$array The array to sort |
719 | 719 | * @return mixed[] The sorted array (new array) |
720 | 720 | */ |
721 | - return function (array $array) use ($flag) { |
|
721 | + return function(array $array) use ($flag) { |
|
722 | 722 | \sort($array, $flag); |
723 | 723 | return $array; |
724 | 724 | }; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | * @param mixed[]$array The array to sort |
738 | 738 | * @return mixed[] The sorted array (new array) |
739 | 739 | */ |
740 | - return function (array $array) use ($flag) { |
|
740 | + return function(array $array) use ($flag) { |
|
741 | 741 | \rsort($array, $flag); |
742 | 742 | return $array; |
743 | 743 | }; |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | * @param mixed[]$array The array to sort |
757 | 757 | * @return mixed[] The sorted array (new array) |
758 | 758 | */ |
759 | - return function (array $array) use ($flag) { |
|
759 | + return function(array $array) use ($flag) { |
|
760 | 760 | \ksort($array, $flag); |
761 | 761 | return $array; |
762 | 762 | }; |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @param mixed[]$array The array to sort |
775 | 775 | * @return mixed[] The sorted array (new array) |
776 | 776 | */ |
777 | - return function (array $array) use ($flag) { |
|
777 | + return function(array $array) use ($flag) { |
|
778 | 778 | \krsort($array, $flag); |
779 | 779 | return $array; |
780 | 780 | }; |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | * @param mixed[]$array The array to sort |
794 | 794 | * @return mixed[] The sorted array (new array) |
795 | 795 | */ |
796 | - return function (array $array) use ($flag) { |
|
796 | + return function(array $array) use ($flag) { |
|
797 | 797 | \asort($array, $flag); |
798 | 798 | return $array; |
799 | 799 | }; |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | * @param mixed[]$array The array to sort |
813 | 813 | * @return mixed[] The sorted array (new array) |
814 | 814 | */ |
815 | - return function (array $array) use ($flag) { |
|
815 | + return function(array $array) use ($flag) { |
|
816 | 816 | \arsort($array, $flag); |
817 | 817 | return $array; |
818 | 818 | }; |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * @param mixed[]$array The array to sort |
830 | 830 | * @return mixed[] The sorted array (new array) |
831 | 831 | */ |
832 | - return function (array $array) { |
|
832 | + return function(array $array) { |
|
833 | 833 | \natsort($array); |
834 | 834 | return $array; |
835 | 835 | }; |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | * @param mixed[]$array The array to sort |
847 | 847 | * @return mixed[] The sorted array (new array) |
848 | 848 | */ |
849 | - return function (array $array) { |
|
849 | + return function(array $array) { |
|
850 | 850 | \natcasesort($array); |
851 | 851 | return $array; |
852 | 852 | }; |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * @param mixed[] $array The array to sort |
865 | 865 | * @return mixed[] The sorted array (new array) |
866 | 866 | */ |
867 | - return function (array $array) use ($function) { |
|
867 | + return function(array $array) use ($function) { |
|
868 | 868 | \uksort($array, $function); |
869 | 869 | return $array; |
870 | 870 | }; |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * @param mixed[]$array The array to sort |
884 | 884 | * @return mixed[] The sorted array (new array) |
885 | 885 | */ |
886 | - return function (array $array) use ($function) { |
|
886 | + return function(array $array) use ($function) { |
|
887 | 887 | \uasort($array, $function); |
888 | 888 | return $array; |
889 | 889 | }; |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | * @param mixed[]$array The array to sort |
904 | 904 | * @return mixed[] The sorted array (new array) |
905 | 905 | */ |
906 | - return function (array $array) use ($function) { |
|
906 | + return function(array $array) use ($function) { |
|
907 | 907 | \usort($array, $function); |
908 | 908 | return $array; |
909 | 909 | }; |
@@ -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 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function sum($initial = 0): Closure |
85 | 85 | { |
86 | - if (! C\isNumber($initial)) { |
|
86 | + if (!C\isNumber($initial)) { |
|
87 | 87 | throw new InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
88 | 88 | } |
89 | 89 | |
@@ -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 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | function subtract($initial = 0): Closure |
108 | 108 | { |
109 | - if (! C\isNumber($initial)) { |
|
109 | + if (!C\isNumber($initial)) { |
|
110 | 110 | throw new InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
111 | 111 | } |
112 | 112 | |
@@ -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 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function multiply($initial = 1): Closure |
131 | 131 | { |
132 | - if (! C\isNumber($initial)) { |
|
132 | + if (!C\isNumber($initial)) { |
|
133 | 133 | throw new InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
134 | 134 | } |
135 | 135 | |
@@ -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 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | function divideBy($divisor = 1): Closure |
154 | 154 | { |
155 | - if (! C\isNumber($divisor)) { |
|
155 | + if (!C\isNumber($divisor)) { |
|
156 | 156 | throw new \InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
157 | 157 | } |
158 | 158 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param float $value |
161 | 161 | * @return float |
162 | 162 | */ |
163 | - return function ($value) use ($divisor): float { |
|
163 | + return function($value) use ($divisor): float { |
|
164 | 164 | return $value / $divisor; |
165 | 165 | }; |
166 | 166 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function divideInto($dividend = 1): Closure |
175 | 175 | { |
176 | - if (! C\isNumber($dividend)) { |
|
176 | + if (!C\isNumber($dividend)) { |
|
177 | 177 | throw new \InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param float $value |
182 | 182 | * @return float |
183 | 183 | */ |
184 | - return function ($value) use ($dividend): float { |
|
184 | + return function($value) use ($dividend): float { |
|
185 | 185 | return $dividend / $value; |
186 | 186 | }; |
187 | 187 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function remainderBy($divisor = 1): Closure |
196 | 196 | { |
197 | - if (! C\isNumber($divisor)) { |
|
197 | + if (!C\isNumber($divisor)) { |
|
198 | 198 | throw new \InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
199 | 199 | } |
200 | 200 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param float $value |
203 | 203 | * @return float |
204 | 204 | */ |
205 | - return function ($value) use ($divisor): float { |
|
205 | + return function($value) use ($divisor): float { |
|
206 | 206 | return $value % $divisor; |
207 | 207 | }; |
208 | 208 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function remainderInto($dividend = 1): Closure |
217 | 217 | { |
218 | - if (! C\isNumber($dividend)) { |
|
218 | + if (!C\isNumber($dividend)) { |
|
219 | 219 | throw new \InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
220 | 220 | } |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @param float $value |
224 | 224 | * @return float |
225 | 225 | */ |
226 | - return function ($value) use ($dividend): float { |
|
226 | + return function($value) use ($dividend): float { |
|
227 | 227 | return $dividend % $value; |
228 | 228 | }; |
229 | 229 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | function round($precision = 1): Closure |
238 | 238 | { |
239 | - if (! C\isNumber($precision)) { |
|
239 | + if (!C\isNumber($precision)) { |
|
240 | 240 | throw new \InvalidArgumentException(__FUNCTION__ . "only accepts a Number (Float or Int)"); |
241 | 241 | } |
242 | 242 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param Number $value |
245 | 245 | * @return float |
246 | 246 | */ |
247 | - return function ($value) use ($precision): float { |
|
248 | - if (! C\isNumber($value)) { |
|
247 | + return function($value) use ($precision): float { |
|
248 | + if (!C\isNumber($value)) { |
|
249 | 249 | throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )"); |
250 | 250 | } |
251 | 251 | return \round(\floatval($value), $precision); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param mixed The value passed into the functions |
49 | 49 | * @return mixed The final result. |
50 | 50 | */ |
51 | - return function ($e) use ($callables) { |
|
51 | + return function($e) use ($callables) { |
|
52 | 52 | foreach ($callables as $callable) { |
53 | 53 | $e = $callable($e); |
54 | 54 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param mixed The value passed into the functions |
70 | 70 | * @return mixed The final result. |
71 | 71 | */ |
72 | - return function ($e) use ($callables) { |
|
72 | + return function($e) use ($callables) { |
|
73 | 73 | foreach (\array_reverse($callables) as $callable) { |
74 | 74 | $e = $callable($e); |
75 | 75 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | * @param mixed The value passed into the functions |
91 | 91 | * @return mixed|null The final result or null. |
92 | 92 | */ |
93 | - return function ($e) use ($callables) { |
|
93 | + return function($e) use ($callables) { |
|
94 | 94 | foreach ($callables as $callable) { |
95 | - if (! is_null($e)) { |
|
95 | + if (!is_null($e)) { |
|
96 | 96 | $e = $callable($e); |
97 | 97 | } |
98 | 98 | } |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | * @param mixed $e The value being passed through the functions. |
116 | 116 | * @return mixed The final result. |
117 | 117 | */ |
118 | - return function ($e) use ($validator, $callables) { |
|
118 | + return function($e) use ($validator, $callables) { |
|
119 | 119 | foreach ($callables as $callable) { |
120 | 120 | // If invalid, abort and return null |
121 | - if (! $validator($e)) { |
|
121 | + if (!$validator($e)) { |
|
122 | 122 | return null; |
123 | 123 | } |
124 | 124 | // Run through callable. |
125 | 125 | $e = $callable($e); |
126 | 126 | |
127 | 127 | // Check results and bail if invalid type. |
128 | - if (! $validator($e)) { |
|
128 | + if (!$validator($e)) { |
|
129 | 129 | return null; |
130 | 130 | } |
131 | 131 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | * @param mixed $data The array or object to attempt to get param. |
172 | 172 | * @return mixed|null |
173 | 173 | */ |
174 | - return function ($data) use ($property) { |
|
174 | + return function($data) use ($property) { |
|
175 | 175 | if (is_array($data)) { |
176 | - return array_key_exists($property, $data) ? $data[ $property ] : null; |
|
176 | + return array_key_exists($property, $data) ? $data[$property] : null; |
|
177 | 177 | } elseif (is_object($data)) { |
178 | 178 | return property_exists($data, $property) ? $data->{$property} : null; |
179 | 179 | } else { |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param mixed[]|object $data The array or object to attempt to get param. |
197 | 197 | * @return mixed|null |
198 | 198 | */ |
199 | - return function ($data) use ($nodes) { |
|
199 | + return function($data) use ($nodes) { |
|
200 | 200 | foreach ($nodes as $node) { |
201 | 201 | $data = getProperty($node)($data); |
202 | 202 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param mixed $data The array or object to attempt to get param. |
222 | 222 | * @return mixed|null |
223 | 223 | */ |
224 | - return function ($data) use ($property): bool { |
|
224 | + return function($data) use ($property): bool { |
|
225 | 225 | if (is_array($data)) { |
226 | 226 | return array_key_exists($property, $data); |
227 | 227 | } elseif (is_object($data)) { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param mixed $data The array or object to attempt to get param. |
247 | 247 | * @return bool |
248 | 248 | */ |
249 | - return function ($data) use ($property, $value): bool { |
|
249 | + return function($data) use ($property, $value): bool { |
|
250 | 250 | return pipe( |
251 | 251 | getProperty($property), |
252 | 252 | \PinkCrab\FunctionConstructors\Comparisons\isEqualTo($value) |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | |
271 | 271 | // If passed store is not an array or object, throw exception. |
272 | - if (! isArrayAccess($store) && ! is_object($store)) { |
|
272 | + if (!isArrayAccess($store) && !is_object($store)) { |
|
273 | 273 | throw new TypeError('Only objects or arrays can be constructed using setProperty.'); |
274 | 274 | } |
275 | 275 | |
@@ -278,10 +278,10 @@ discard block |
||
278 | 278 | * @param mixed $value The value to set to keu. |
279 | 279 | * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore. |
280 | 280 | */ |
281 | - return function (string $property, $value) use ($store) { |
|
281 | + return function(string $property, $value) use ($store) { |
|
282 | 282 | if (isArrayAccess($store)) { |
283 | 283 | /** @phpstan-ignore-next-line */ |
284 | - $store[ $property ] = $value; |
|
284 | + $store[$property] = $value; |
|
285 | 285 | } else { |
286 | 286 | $store->{$property} = $value; |
287 | 287 | } |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * @param mixed $data The data to pass through the callable |
305 | 305 | * @return array |
306 | 306 | */ |
307 | - return function ($data) use ($key, $value): array { |
|
308 | - return array( $key => $value($data) ); |
|
307 | + return function($data) use ($key, $value): array { |
|
308 | + return array($key => $value($data)); |
|
309 | 309 | }; |
310 | 310 | } |
311 | 311 | |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | * @param callable(mixed):mixed ...$encoders encodeProperty() functions. |
323 | 323 | * @return Closure |
324 | 324 | */ |
325 | - return function (...$encoders) use ($dataType): Closure { |
|
325 | + return function(...$encoders) use ($dataType): Closure { |
|
326 | 326 | /** |
327 | 327 | * @param mixed $data The data to pass through the encoders. |
328 | 328 | * @return array<string,mixed>|object The encoded object/array. |
329 | 329 | */ |
330 | - return function ($data) use ($dataType, $encoders) { |
|
330 | + return function($data) use ($dataType, $encoders) { |
|
331 | 331 | foreach ($encoders as $encoder) { |
332 | 332 | $key = array_keys($encoder($data))[0]; |
333 | 333 | // throw exception if key is int |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param mixed ...$args |
358 | 358 | * @return mixed |
359 | 359 | */ |
360 | - return function (...$args) use ($fn) { |
|
360 | + return function(...$args) use ($fn) { |
|
361 | 361 | return $fn(...$args); |
362 | 362 | }; |
363 | 363 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param mixed $ignored Any values can be passed and ignored. |
375 | 375 | * @return mixed |
376 | 376 | */ |
377 | - return function (...$ignored) use ($value) { |
|
377 | + return function(...$ignored) use ($value) { |
|
378 | 378 | return $value; |
379 | 379 | }; |
380 | 380 | } |
@@ -391,18 +391,18 @@ discard block |
||
391 | 391 | * @param object $object |
392 | 392 | * @return array<string, mixed> |
393 | 393 | */ |
394 | - return function ($object): array { |
|
394 | + return function($object): array { |
|
395 | 395 | |
396 | 396 | // If not object, return empty array. |
397 | - if (! is_object($object)) { |
|
397 | + if (!is_object($object)) { |
|
398 | 398 | return array(); |
399 | 399 | } |
400 | 400 | |
401 | 401 | $objectVars = get_object_vars($object); |
402 | 402 | return array_reduce( |
403 | 403 | array_keys($objectVars), |
404 | - function (array $array, $key) use ($objectVars): array { |
|
405 | - $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ]; |
|
404 | + function(array $array, $key) use ($objectVars): array { |
|
405 | + $array[ltrim((string) $key, '_')] = $objectVars[$key]; |
|
406 | 406 | return $array; |
407 | 407 | }, |
408 | 408 | array() |