Passed
Pull Request — develop (#27)
by Glynn
04:10 queued 12s
created
src/procedural.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
      *
Please login to merge, or discard this patch.
src/strings.php 1 patch
Spacing   +46 added lines, -47 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/comparisons.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/general.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             $data,
252 252
             getProperty($property),
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 {
272 272
 
273 273
     // If passed store is not an array or object, throw exception.
274
-    if (! isArrayAccess($store) && ! is_object($store)) {
274
+    if (!isArrayAccess($store) && !is_object($store)) {
275 275
         throw new TypeError('Only objects or arrays can be constructed using setProperty.');
276 276
     }
277 277
 
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
      * @param mixed $value The value to set to keu.
280 280
      * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore.
281 281
      */
282
-    return function ($value) use ($store, $property) {
282
+    return function($value) use ($store, $property) {
283 283
         if (isArrayAccess($store)) {
284 284
             /** @phpstan-ignore-next-line */
285
-            $store[ $property ] = $value;
285
+            $store[$property] = $value;
286 286
         } else {
287 287
             $store->{$property} = $value;
288 288
         }
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
      * @param mixed $data The data to pass through the callable
306 306
      * @return array
307 307
      */
308
-    return function ($data) use ($key, $value): array {
309
-        return array( $key => $value($data) );
308
+    return function($data) use ($key, $value): array {
309
+        return array($key => $value($data));
310 310
     };
311 311
 }
312 312
 
@@ -323,12 +323,12 @@  discard block
 block discarded – undo
323 323
      * @param callable(mixed):mixed ...$encoders encodeProperty() functions.
324 324
      * @return Closure
325 325
      */
326
-    return function (...$encoders) use ($dataType): Closure {
326
+    return function(...$encoders) use ($dataType): Closure {
327 327
         /**
328 328
          * @param mixed $data The data to pass through the encoders.
329 329
          * @return array<string,mixed>|object The encoded object/array.
330 330
          */
331
-        return function ($data) use ($dataType, $encoders) {
331
+        return function($data) use ($dataType, $encoders) {
332 332
             foreach ($encoders as $encoder) {
333 333
                 $key = array_keys($encoder($data))[0];
334 334
                 // throw exception if key is int
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      * @param mixed ...$args
356 356
      * @return mixed
357 357
      */
358
-    return function (...$args) use ($fn) {
358
+    return function(...$args) use ($fn) {
359 359
         return $fn(...$args);
360 360
     };
361 361
 }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
      * @param mixed $ignored Any values can be passed and ignored.
373 373
      * @return mixed
374 374
      */
375
-    return function (...$ignored) use ($value) {
375
+    return function(...$ignored) use ($value) {
376 376
         return $value;
377 377
     };
378 378
 }
@@ -389,18 +389,18 @@  discard block
 block discarded – undo
389 389
      * @param object $object
390 390
      * @return array<string, mixed>
391 391
      */
392
-    return function ($object): array {
392
+    return function($object): array {
393 393
 
394 394
         // If not object, return empty array.
395
-        if (! is_object($object)) {
395
+        if (!is_object($object)) {
396 396
             return array();
397 397
         }
398 398
 
399 399
         $objectVars = get_object_vars($object);
400 400
         return array_reduce(
401 401
             array_keys($objectVars),
402
-            function (array $array, $key) use ($objectVars): array {
403
-                $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ];
402
+            function(array $array, $key) use ($objectVars): array {
403
+                $array[ltrim((string) $key, '_')] = $objectVars[$key];
404 404
                 return $array;
405 405
             },
406 406
             array()
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      * @param  mixed $value
423 423
      * @return mixed
424 424
      */
425
-    return function ($value) use ($condition, $then) {
425
+    return function($value) use ($condition, $then) {
426 426
         return true === (bool) $condition($value)
427 427
             ? $then($value)
428 428
             : $value;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      * @param  mixed $value
446 446
      * @return mixed
447 447
      */
448
-    return function ($value) use ($condition, $then, $else) {
448
+    return function($value) use ($condition, $then, $else) {
449 449
         return true === (bool) $condition($value)
450 450
             ? $then($value)
451 451
             : $else($value);
Please login to merge, or discard this patch.
src/objects.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     if (is_object($class)) {
53 53
         $class = get_class($class);
54 54
     }
55
-    if (! class_exists($class)) {
55
+    if (!class_exists($class)) {
56 56
         throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name');
57 57
     }
58 58
 
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
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
         }
67
-        if (! class_exists($value)) {
67
+        if (!class_exists($value)) {
68 68
             throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name');
69 69
         }
70 70
         return is_a($value, $class, true);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
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
             $class,
90 90
             class_implements($interface, false) ?: array(),
Please login to merge, or discard this patch.
src/arrays.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     };
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
  */
919 919
 function scan(callable $function, $initialValue): Closure
920 920
 {
921
-    return function (array $array) use ($function, $initialValue) {
921
+    return function(array $array) use ($function, $initialValue) {
922 922
         $carry[] = $initialValue;
923 923
         foreach ($array as $key => $value) {
924 924
             $initialValue = $function($initialValue, $value);
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
  */
938 938
 function scanR(callable $function, $initialValue): Closure
939 939
 {
940
-    return function (array $array) use ($function, $initialValue) {
940
+    return function(array $array) use ($function, $initialValue) {
941 941
         $carry[] = $initialValue;
942 942
         foreach (array_reverse($array) as $key => $value) {
943 943
             $initialValue = $function($initialValue, $value);
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
      * @param mixed[] $array
961 961
      * @return mixed
962 962
      */
963
-    return function (array $array) use ($callable, $initial) {
963
+    return function(array $array) use ($callable, $initial) {
964 964
         return array_reduce($array, $callable, $initial);
965 965
     };
966 966
 }
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
      * @param mixed[] $array
979 979
      * @return mixed
980 980
      */
981
-    return function (array $array) use ($callable, $initial) {
981
+    return function(array $array) use ($callable, $initial) {
982 982
         return array_reduce(\array_reverse($array), $callable, $initial);
983 983
     };
984 984
 }
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
      * @param mixed[] $array
998 998
      * @return mixed
999 999
      */
1000
-    return function (array $array) use ($callable, $initial) {
1000
+    return function(array $array) use ($callable, $initial) {
1001 1001
         foreach ($array as $key => $value) {
1002 1002
             $initial = $callable($initial, $key, $value);
1003 1003
         }
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
      * @param mixed[] $array
1024 1024
      * @return mixed[]
1025 1025
      */
1026
-    return function (array $array) use ($count) {
1026
+    return function(array $array) use ($count) {
1027 1027
         return \array_slice($array, 0, $count);
1028 1028
     };
1029 1029
 }
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
     // If count is 0, return an empty array
1046 1046
     if ($count === 0) {
1047
-        return function (array $array) {
1047
+        return function(array $array) {
1048 1048
             return [];
1049 1049
         };
1050 1050
     }
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
      * @param mixed[] $array
1054 1054
      * @return mixed[]
1055 1055
      */
1056
-    return function (array $array) use ($count) {
1056
+    return function(array $array) use ($count) {
1057 1057
         return \array_slice($array, - $count);
1058 1058
     };
1059 1059
 }
@@ -1071,13 +1071,13 @@  discard block
 block discarded – undo
1071 1071
      * @param mixed[] $array
1072 1072
      * @return mixed[]
1073 1073
      */
1074
-    return function (array $array) use ($conditional) {
1074
+    return function(array $array) use ($conditional) {
1075 1075
         $carry = array();
1076 1076
         foreach ($array as $key => $value) {
1077 1077
             if (true === $conditional($value)) {
1078 1078
                 break;
1079 1079
             }
1080
-            $carry[ $key ] = $value;
1080
+            $carry[$key] = $value;
1081 1081
         }
1082 1082
         return $carry;
1083 1083
     };
@@ -1096,13 +1096,13 @@  discard block
 block discarded – undo
1096 1096
      * @param mixed[] $array
1097 1097
      * @return mixed[]
1098 1098
      */
1099
-    return function (array $array) use ($conditional) {
1099
+    return function(array $array) use ($conditional) {
1100 1100
         $carry = array();
1101 1101
         foreach ($array as $key => $value) {
1102 1102
             if (false === $conditional($value)) {
1103 1103
                 break;
1104 1104
             }
1105
-            $carry[ $key ] = $value;
1105
+            $carry[$key] = $value;
1106 1106
         }
1107 1107
         return $carry;
1108 1108
     };
Please login to merge, or discard this patch.
src/numbers.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
  */
154 154
 function divideBy($divisor = 1): Closure
155 155
 {
156
-    if (! C\isNumber($divisor)) {
156
+    if (!C\isNumber($divisor)) {
157 157
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
158 158
     }
159 159
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
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
 }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  */
176 176
 function divideInto($dividend = 1): Closure
177 177
 {
178
-    if (! C\isNumber($dividend)) {
178
+    if (!C\isNumber($dividend)) {
179 179
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
180 180
     }
181 181
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
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
 }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
  */
198 198
 function remainderBy($divisor = 1): Closure
199 199
 {
200
-    if (! C\isNumber($divisor)) {
200
+    if (!C\isNumber($divisor)) {
201 201
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
202 202
     }
203 203
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
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
 }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function remainderInto($dividend = 1): Closure
221 221
 {
222
-    if (! C\isNumber($dividend)) {
222
+    if (!C\isNumber($dividend)) {
223 223
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
224 224
     }
225 225
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
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
 }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  */
242 242
 function isMultipleOf($factor): Closure
243 243
 {
244
-    if (! C\isNumber($factor)) {
244
+    if (!C\isNumber($factor)) {
245 245
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
246 246
     }
247 247
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
      * @return bool
251 251
      * @throws InvalidArgumentException If neither int or float passed.
252 252
      */
253
-    return function ($value) use ($factor): bool {
254
-        if (! C\isNumber($value)) {
253
+    return function($value) use ($factor): bool {
254
+        if (!C\isNumber($value)) {
255 255
             throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
256 256
         }
257 257
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function round($precision = 1): Closure
276 276
 {
277
-    if (! C\isNumber($precision)) {
277
+    if (!C\isNumber($precision)) {
278 278
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
279 279
     }
280 280
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
      * @return float
284 284
      * @throws InvalidArgumentException If neither int or float passed.
285 285
      */
286
-    return function ($value) use ($precision): float {
287
-        if (! C\isNumber($value)) {
286
+    return function($value) use ($precision): float {
287
+        if (!C\isNumber($value)) {
288 288
             throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )");
289 289
         }
290 290
         return \round(\floatval($value), $precision);
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
  */
301 301
 function power($exponent): Closure
302 302
 {
303
-    if (! C\isNumber($exponent)) {
303
+    if (!C\isNumber($exponent)) {
304 304
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the exponent');
305 305
     }
306 306
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
      * @return Number
310 310
      * @throws InvalidArgumentException If neither int or float passed.
311 311
      */
312
-    return function ($value) use ($exponent) {
313
-        if (! C\isNumber($value)) {
312
+    return function($value) use ($exponent) {
313
+        if (!C\isNumber($value)) {
314 314
             throw new \InvalidArgumentException('Num\\power() only accepts a valid Number ( Int|Float )');
315 315
         }
316 316
         return \pow($value, $exponent);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  */
327 327
 function root($root): Closure
328 328
 {
329
-    if (! C\isNumber($root)) {
329
+    if (!C\isNumber($root)) {
330 330
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the root');
331 331
     }
332 332
 
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
      * @return Number
336 336
      * @throws InvalidArgumentException If neither int or float passed.
337 337
      */
338
-    return function ($value) use ($root) {
339
-        if (! C\isNumber($value)) {
338
+    return function($value) use ($root) {
339
+        if (!C\isNumber($value)) {
340 340
             throw new \InvalidArgumentException('Num\\root() only accepts a valid Number ( Int|Float )');
341 341
         }
342 342
         return pow($value, (1 / $root));
Please login to merge, or discard this patch.