Passed
Pull Request — develop (#86)
by Glynn
02:39
created
src/objects.php 1 patch
Spacing   +17 added lines, -17 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
             $interface,
90 90
             class_implements($class, false) ?: array(),
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
      * @param object $object
106 106
      * @return array<string, mixed>
107 107
      */
108
-    return function ($object): array {
108
+    return function($object): array {
109 109
 
110 110
         // If not object, return empty array.
111
-        if (! is_object($object)) {
111
+        if (!is_object($object)) {
112 112
             return array();
113 113
         }
114 114
 
115 115
         $objectVars = get_object_vars($object);
116 116
         return array_reduce(
117 117
             array_keys($objectVars),
118
-            function (array $array, $key) use ($objectVars): array {
119
-                $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ];
118
+            function(array $array, $key) use ($objectVars): array {
119
+                $array[ltrim((string) $key, '_')] = $objectVars[$key];
120 120
                 return $array;
121 121
             },
122 122
             array()
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
      * @param object|class-string $object
139 139
      * @return bool
140 140
      */
141
-    return function ($object) use ($trait, $autoload): bool {
141
+    return function($object) use ($trait, $autoload): bool {
142 142
         // Throw type error if not object or class-string.
143
-        if (! is_object($object) && ! class_exists($object, false)) {
143
+        if (!is_object($object) && !class_exists($object, false)) {
144 144
             throw new InvalidArgumentException(__FUNCTION__ . ' only accepts an object or class-string');
145 145
         }
146 146
 
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
     $constructorArgs = $constructor->getConstructor() ? $constructor->getConstructor()->getParameters() : array();
169 169
     $constructorArgs = array_reduce(
170 170
         $constructorArgs,
171
-        function (array $args, \ReflectionParameter $param) use ($baseProperties): array {
171
+        function(array $args, \ReflectionParameter $param) use ($baseProperties): array {
172 172
             // If the param exists in base properties use that, else use the default value or null.
173
-            $args[ $param->getName() ] = \array_key_exists($param->getName(), $baseProperties)
174
-                ? $baseProperties[ $param->getName() ]
173
+            $args[$param->getName()] = \array_key_exists($param->getName(), $baseProperties)
174
+                ? $baseProperties[$param->getName()]
175 175
                 : ($param->isDefaultValueAvailable()
176 176
                     ? $param->getDefaultValue()
177 177
                     : null);
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
      * @param array<string, mixed> $properties
186 186
      * @return Class
187 187
      */
188
-    return function (array $properties = array()) use ($class, $constructorArgs) {
188
+    return function(array $properties = array()) use ($class, $constructorArgs) {
189 189
         // Loop through constructorArgs and replace with any passed properties.
190 190
         $constructorArgs = array_reduce(
191 191
             array_keys($constructorArgs),
192
-            function (array $args, string $key) use ($constructorArgs, $properties): array {
192
+            function(array $args, string $key) use ($constructorArgs, $properties): array {
193 193
                 $args[] = \array_key_exists($key, $properties)
194
-                    ? $properties[ $key ]
195
-                    : $constructorArgs[ $key ];
194
+                    ? $properties[$key]
195
+                    : $constructorArgs[$key];
196 196
                 return $args;
197 197
             },
198 198
             array()
Please login to merge, or discard this patch.
src/numbers.php 1 patch
Spacing   +29 added lines, -29 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 (null !== $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 (null !== $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($multiple): Closure
243 243
 {
244
-    if (! C\isNumber($multiple)) {
244
+    if (!C\isNumber($multiple)) {
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 ($multiple): bool {
254
-        if (! C\isNumber($value)) {
253
+    return function($value) use ($multiple): bool {
254
+        if (!C\isNumber($value)) {
255 255
             throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
256 256
         }
257 257
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      * @return bool
278 278
      * @throws InvalidArgumentException If neither int or float passed.
279 279
      */
280
-    return function (int $value) use ($factor): bool {
280
+    return function(int $value) use ($factor): bool {
281 281
         // Return false if 0
282 282
         if ($value === 0) {
283 283
             return false;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
  */
298 298
 function round($precision = 1): Closure
299 299
 {
300
-    if (! C\isNumber($precision)) {
300
+    if (!C\isNumber($precision)) {
301 301
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)');
302 302
     }
303 303
 
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
      * @return float
307 307
      * @throws InvalidArgumentException If neither int or float passed.
308 308
      */
309
-    return function ($value) use ($precision): float {
310
-        if (! C\isNumber($value)) {
309
+    return function($value) use ($precision): float {
310
+        if (!C\isNumber($value)) {
311 311
             throw new \InvalidArgumentException("Num\\round() only accepts a valid Number ( Int|Float -> Float )");
312 312
         }
313 313
         return \round(\floatval($value), $precision);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function power($exponent): Closure
325 325
 {
326
-    if (! C\isNumber($exponent)) {
326
+    if (!C\isNumber($exponent)) {
327 327
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the exponent');
328 328
     }
329 329
 
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
      * @return Number
333 333
      * @throws InvalidArgumentException If neither int or float passed.
334 334
      */
335
-    return function ($value) use ($exponent) {
336
-        if (! C\isNumber($value)) {
335
+    return function($value) use ($exponent) {
336
+        if (!C\isNumber($value)) {
337 337
             throw new \InvalidArgumentException('Num\\power() only accepts a valid Number ( Int|Float )');
338 338
         }
339 339
         return \pow($value, $exponent);
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
  */
350 350
 function root($root): Closure
351 351
 {
352
-    if (! C\isNumber($root)) {
352
+    if (!C\isNumber($root)) {
353 353
         throw new \InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int) for the root');
354 354
     }
355 355
 
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
      * @return Number
359 359
      * @throws InvalidArgumentException If neither int or float passed.
360 360
      */
361
-    return function ($value) use ($root) {
362
-        if (! C\isNumber($value)) {
361
+    return function($value) use ($root) {
362
+        if (!C\isNumber($value)) {
363 363
             throw new \InvalidArgumentException('Num\\root() only accepts a valid Number ( Int|Float )');
364 364
         }
365 365
         return pow($value, (1 / $root));
Please login to merge, or discard this patch.
src/procedural.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 use PinkCrab\FunctionConstructors\Arrays as Arr;
27 27
 
28
-if (! function_exists('stringContains')) {
28
+if (!function_exists('stringContains')) {
29 29
     /**
30 30
      * Checks if a string contains a sub string
31 31
      *
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     }
40 40
 }
41 41
 
42
-if (! function_exists('array_flatten')) {
42
+if (!function_exists('array_flatten')) {
43 43
     /**
44 44
      * Flattens an array to desired depth.
45 45
      * doesn't preserve keys
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 }
56 56
 
57
-if (! function_exists('toObject')) {
57
+if (!function_exists('toObject')) {
58 58
     /**
59 59
      * Simple mapper for turning arrays into stdClass objects.
60 60
      *
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     }
68 68
 }
69 69
 
70
-if (! function_exists('invokeCallable')) {
70
+if (!function_exists('invokeCallable')) {
71 71
     /**
72 72
      * Used to invoke a callable.
73 73
      *
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     }
82 82
 }
83 83
 
84
-if (! function_exists('isArrayAccess')) {
84
+if (!function_exists('isArrayAccess')) {
85 85
     /**
86 86
      * Checks if an array or an object which has array like access.
87 87
      *
Please login to merge, or discard this patch.
src/constants.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
  * Constants used for Str\wordCount() => str_word_count()
33 33
  * https://www.php.net/manual/en/function.str-word-count.php
34 34
  */
35
-if (! defined('WORD_COUNT_NUMBER_OF_WORDS')) {
35
+if (!defined('WORD_COUNT_NUMBER_OF_WORDS')) {
36 36
     define('WORD_COUNT_NUMBER_OF_WORDS', 0);
37 37
 }
38
-if (! defined('WORD_COUNT_ARRAY')) {
38
+if (!defined('WORD_COUNT_ARRAY')) {
39 39
     define('WORD_COUNT_ARRAY', 1);
40 40
 }
41
-if (! defined('WORD_COUNT_ASSOCIATIVE_ARRAY')) {
41
+if (!defined('WORD_COUNT_ASSOCIATIVE_ARRAY')) {
42 42
     define('WORD_COUNT_ASSOCIATIVE_ARRAY', 2);
43 43
 }
44 44
 
@@ -46,36 +46,36 @@  discard block
 block discarded – undo
46 46
  * Constants used for Strings\countChars() => count_chars()
47 47
  * https://www.php.net/manual/en/function.count-chars.php
48 48
  */
49
-if (! defined('CHAR_COUNT_ARRAY')) {
49
+if (!defined('CHAR_COUNT_ARRAY')) {
50 50
     define('CHAR_COUNT_ARRAY', 0);
51 51
 }
52 52
 
53
-if (! defined('CHAR_COUNT_ARRAY_UNIQUE')) {
53
+if (!defined('CHAR_COUNT_ARRAY_UNIQUE')) {
54 54
     define('CHAR_COUNT_ARRAY_UNIQUE', 1);
55 55
 }
56 56
 
57
-if (! defined('CHAR_COUNT_ARRAY_UNUSED')) {
57
+if (!defined('CHAR_COUNT_ARRAY_UNUSED')) {
58 58
     define('CHAR_COUNT_ARRAY_UNUSED', 2);
59 59
 }
60 60
 
61
-if (! defined('CHAR_COUNT_STRING_UNIQUE')) {
61
+if (!defined('CHAR_COUNT_STRING_UNIQUE')) {
62 62
     define('CHAR_COUNT_STRING_UNIQUE', 3);
63 63
 }
64 64
 
65
-if (! defined('CHAR_COUNT_STRING_UNUSED')) {
65
+if (!defined('CHAR_COUNT_STRING_UNUSED')) {
66 66
     define('CHAR_COUNT_STRING_UNUSED', 4);
67 67
 }
68 68
 
69 69
 // String function flags
70
-if (! defined('STRINGS_CASE_INSENSITIVE')) {
70
+if (!defined('STRINGS_CASE_INSENSITIVE')) {
71 71
     define('STRINGS_CASE_INSENSITIVE', 0x1);
72 72
 }
73
-if (! defined('STRINGS_CASE_SENSITIVE')) {
73
+if (!defined('STRINGS_CASE_SENSITIVE')) {
74 74
     define('STRINGS_CASE_SENSITIVE', 0x2);
75 75
 }
76
-if (! defined('STRINGS_BEFORE_NEEDLE')) {
76
+if (!defined('STRINGS_BEFORE_NEEDLE')) {
77 77
     define('STRINGS_BEFORE_NEEDLE', 0x4);
78 78
 }
79
-if (! defined('STRINGS_AFTER_NEEDLE')) {
79
+if (!defined('STRINGS_AFTER_NEEDLE')) {
80 80
     define('STRINGS_AFTER_NEEDLE', 0x8);
81 81
 }
Please login to merge, or discard this patch.
src/comparisons.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  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 {
48
+    return function($b) use ($a): bool {
49 49
         if (!sameScalar($b, $a)) {
50 50
             return false;
51 51
         }
@@ -83,7 +83,7 @@  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 {
86
+    return function($b) use ($a): bool {
87 87
         return !isEqualTo($a)($b);
88 88
     };
89 89
 }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param Number $b
102 102
      * @return bool
103 103
      */
104
-    return function ($b) use ($a): bool {
104
+    return function($b) use ($a): bool {
105 105
         return isEqualIn(array('integer', 'double'))(gettype($b))
106 106
             ? $a < $b : false;
107 107
     };
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param mixed $b
121 121
      * @return bool
122 122
      */
123
-    return function ($b) use ($a): bool {
123
+    return function($b) use ($a): bool {
124 124
         return isEqualIn(array('integer', 'double'))(gettype($b))
125 125
             ? $a > $b : false;
126 126
     };
@@ -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
@@ -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
 }
@@ -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 {
391
+    return function($value) use ($callable): bool {
392 392
         return !(bool) $callable($value);
393 393
     };
394 394
 }
Please login to merge, or discard this patch.
src/general.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @param mixed $e The value passed into the functions
50 50
      * @return mixed The final result.
51 51
      */
52
-    return function ($e) use ($callables) {
52
+    return function($e) use ($callables) {
53 53
         foreach ($callables as $callable) {
54 54
             $e = $callable($e);
55 55
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param mixed $e The value passed into the functions
71 71
      * @return mixed The final result.
72 72
      */
73
-    return function ($e) use ($callables) {
73
+    return function($e) use ($callables) {
74 74
         foreach (\array_reverse($callables) as $callable) {
75 75
             $e = $callable($e);
76 76
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param mixed $e The value passed into the functions
92 92
      * @return mixed|null The final result or null.
93 93
      */
94
-    return function ($e) use ($callables) {
94
+    return function($e) use ($callables) {
95 95
         foreach ($callables as $callable) {
96 96
             if (!is_null($e)) {
97 97
                 $e = $callable($e);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      * @param mixed $e The value being passed through the functions.
117 117
      * @return mixed The final result.
118 118
      */
119
-    return function ($e) use ($validator, $callables) {
119
+    return function($e) use ($validator, $callables) {
120 120
         foreach ($callables as $callable) {
121 121
             // If invalid, abort and return null
122 122
             if (!$validator($e)) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * @param mixed $data The array or object to attempt to get param.
173 173
      * @return mixed|null
174 174
      */
175
-    return function ($data) use ($property) {
175
+    return function($data) use ($property) {
176 176
         if (is_array($data)) {
177 177
             return array_key_exists($property, $data) ? $data[$property] : null;
178 178
         } elseif (is_object($data)) {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      * @param mixed[]|object $data The array or object to attempt to get param.
198 198
      * @return mixed|null
199 199
      */
200
-    return function ($data) use ($nodes) {
200
+    return function($data) use ($nodes) {
201 201
         foreach ($nodes as $node) {
202 202
             $data = getProperty($node)($data);
203 203
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * @param mixed $data The array or object to attempt to get param.
223 223
      * @return mixed|null
224 224
      */
225
-    return function ($data) use ($property): bool {
225
+    return function($data) use ($property): bool {
226 226
         if (is_array($data)) {
227 227
             return array_key_exists($property, $data);
228 228
         } elseif (is_object($data)) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * @param mixed $data The array or object to attempt to get param.
248 248
      * @return bool
249 249
      */
250
-    return function ($data) use ($property, $value): bool {
250
+    return function($data) use ($property, $value): bool {
251 251
         return pipe(
252 252
             $data,
253 253
             getProperty($property),
@@ -279,7 +279,7 @@  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 285
             $store[$property] = $value;
@@ -305,7 +305,7 @@  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 {
308
+    return function($data) use ($key, $value): array {
309 309
         return array($key => $value($data));
310 310
     };
311 311
 }
@@ -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
 }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      * @param  mixed $value
408 408
      * @return mixed
409 409
      */
410
-    return function ($value) use ($condition, $then) {
410
+    return function($value) use ($condition, $then) {
411 411
         return true === (bool) $condition($value)
412 412
             ? $then($value)
413 413
             : $value;
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
      * @param  mixed $value
431 431
      * @return mixed
432 432
      */
433
-    return function ($value) use ($condition, $then, $else) {
433
+    return function($value) use ($condition, $then, $else) {
434 434
         return true === (bool) $condition($value)
435 435
             ? $then($value)
436 436
             : $else($value);
Please login to merge, or discard this patch.
src/strings.php 1 patch
Spacing   +38 added lines, -38 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
 }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param string $string
69 69
      * @return string
70 70
      */
71
-    return function (string $string) use ($start, $finish): string {
71
+    return function(string $string) use ($start, $finish) : string {
72 72
         return !$finish
73 73
             ? substr($string, $start)
74 74
             : substr($string, $start, $finish);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param string $string
88 88
      * @return string
89 89
      */
90
-    return function (string $string) use ($prepend): string {
90
+    return function(string $string) use ($prepend): string {
91 91
         return \sprintf('%s%s', $prepend, $string);
92 92
     };
93 93
 }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @param string $string
105 105
      * @return string
106 106
      */
107
-    return function (string $string) use ($append): string {
107
+    return function(string $string) use ($append): string {
108 108
         return \sprintf('%s%s', $string, $append);
109 109
     };
110 110
 }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      * @param array<string, mixed> $values
122 122
      * @return string Will return original string if false.
123 123
      */
124
-    return function (array $values = array()) use ($template): string {
124
+    return function(array $values = array()) use ($template): string {
125 125
         return \vsprintf($template, $values);
126 126
     };
127 127
 }
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
      * @param string $replace value to replace with
139 139
      * @return Closure(string):string
140 140
      */
141
-    return function (string $replace) use ($find): Closure {
141
+    return function(string $replace) use ($find): Closure {
142 142
         /**
143 143
          * @param string $subject String to carry out find and replace.
144 144
          * @return string
145 145
          */
146
-        return function ($subject) use ($find, $replace): string {
146
+        return function($subject) use ($find, $replace): string {
147 147
             return \str_replace($find, $replace, $subject);
148 148
         };
149 149
     };
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param string $source
163 163
      * @return string
164 164
      */
165
-    return function ($source) use ($find, $replace): string {
165
+    return function($source) use ($find, $replace): string {
166 166
         return \str_replace($find, $replace, $source);
167 167
     };
168 168
 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param string $string
182 182
      * @return string
183 183
      */
184
-    return function (string $string) use ($replace, $offset, $length): string {
184
+    return function(string $string) use ($replace, $offset, $length) : string {
185 185
         return $length
186 186
             ? \substr_replace($string, $replace, $offset, $length)
187 187
             : \substr_replace($string, $replace, $offset);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @param string $source
201 201
      * @return bool
202 202
      */
203
-    return function (string $source) use ($find): bool {
203
+    return function(string $source) use ($find): bool {
204 204
         return (\substr($source, 0, \strlen($find)) === $find);
205 205
     };
206 206
 }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      * @param string $source
218 218
      * @return bool
219 219
      */
220
-    return function (string $source) use ($find): bool {
220
+    return function(string $source) use ($find): bool {
221 221
         if (\strlen($find) === 0) {
222 222
             return true;
223 223
         }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      * @param string $haystack String to look in.
238 238
      * @return bool
239 239
      */
240
-    return function (string $haystack) use ($needle): bool {
240
+    return function(string $haystack) use ($needle): bool {
241 241
         return \stringContains($haystack, $needle);
242 242
     };
243 243
 }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      * @param string $source String to look in.
255 255
      * @return bool
256 256
      */
257
-    return function (string $source) use ($pattern): bool {
257
+    return function(string $source) use ($pattern): bool {
258 258
         return (bool) \preg_match($pattern, $source);
259 259
     };
260 260
 }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @param string $name
272 272
      * @return string[]
273 273
      */
274
-    return function (string $string) use ($pattern): ?array {
274
+    return function(string $string) use ($pattern): ?array {
275 275
         return \preg_split($pattern, $string) ?: null;
276 276
     };
277 277
 }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @param string|int|float $number
291 291
      * @return string
292 292
      */
293
-    return function ($number) use ($precision, $point, $thousands): string {
293
+    return function($number) use ($precision, $point, $thousands): string {
294 294
         return \is_numeric($number)
295 295
             ? \number_format((float) $number, (int) $precision, $point, $thousands)
296 296
             : '';
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @param string $string The string to have char, slash escaped.
312 312
      * @return string
313 313
      */
314
-    return function (string $string) use ($charList): string {
314
+    return function(string $string) use ($charList): string {
315 315
         return \addcslashes($string, $charList);
316 316
     };
317 317
 }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      * @param string $string The string to be split
330 330
      * @return array<int, string>
331 331
      */
332
-    return function (string $string) use ($separator, $limit): array {
332
+    return function(string $string) use ($separator, $limit): array {
333 333
         $chunks = explode($separator, $string, $limit);
334 334
         return is_array($chunks) ? $chunks : array(); // @phpstan-ignore-line, inconsistent errors with differing php versions.
335 335
     };
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      * @param string $string The string to be split
348 348
      * @return array<int, string>
349 349
      */
350
-    return function (string $string) use ($length): array {
350
+    return function(string $string) use ($length): array {
351 351
         return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions.
352 352
     };
353 353
 }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      * @param string $string The string to be chunked
367 367
      * @return string
368 368
      */
369
-    return function (string $string) use ($length, $end): string {
369
+    return function(string $string) use ($length, $end): string {
370 370
         return \chunk_split($string, max(1, $length), $end);
371 371
     };
372 372
 }
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      * @param string $string The string to be wrapped
386 386
      * @return string
387 387
      */
388
-    return function (string $string) use ($width, $break, $cut): string {
388
+    return function(string $string) use ($width, $break, $cut): string {
389 389
         return \wordwrap($string, $width, $break, $cut);
390 390
     };
391 391
 }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      * @param string $string The string to have its char counted.
409 409
      * @return int[]|string
410 410
      */
411
-    return function (string $string) use ($mode) {
411
+    return function(string $string) use ($mode) {
412 412
         return \count_chars($string, $mode);
413 413
     };
414 414
 }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
      * @param string $haystack
428 428
      * @return int
429 429
      */
430
-    return function (string $haystack) use ($needle, $offset, $length): int {
430
+    return function(string $haystack) use ($needle, $offset, $length) : int {
431 431
         return $length
432 432
             ? \substr_count($haystack, $needle, $offset, $length)
433 433
             : \substr_count($haystack, $needle, $offset);
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
      * @param string $string The string to be trimmed
447 447
      * @return string
448 448
      */
449
-    return function (string $string) use ($mask): string {
449
+    return function(string $string) use ($mask): string {
450 450
         return \trim($string, $mask);
451 451
     };
452 452
 }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
      * @param string $string The string to be trimmed
464 464
      * @return string
465 465
      */
466
-    return function (string $string) use ($mask): string {
466
+    return function(string $string) use ($mask): string {
467 467
         return \ltrim($string, $mask);
468 468
     };
469 469
 }
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      * @param string $string The string to be trimmed
481 481
      * @return string
482 482
      */
483
-    return function (string $string) use ($mask): string {
483
+    return function(string $string) use ($mask): string {
484 484
         return \rtrim($string, $mask);
485 485
     };
486 486
 }
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      * @param string $comparisonString The string to compare against base.
500 500
      * @return Number
501 501
      */
502
-    return function (string $comparisonString) use ($base, $asPc) {
502
+    return function(string $comparisonString) use ($base, $asPc) {
503 503
         $pc       = 0.00;
504 504
         $matching = similar_text($base, $comparisonString, $pc);
505 505
         return $asPc ? $pc : $matching;
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      * @param string $string The string to pad out.
522 522
      * @return string
523 523
      */
524
-    return function (string $string) use ($length, $padContent, $type): string {
524
+    return function(string $string) use ($length, $padContent, $type): string {
525 525
         return \str_pad($string, $length, $padContent, $type);
526 526
     };
527 527
 }
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
      * @param string $string The string to repeat
539 539
      * @return string
540 540
      */
541
-    return function (string $string) use ($count): string {
541
+    return function(string $string) use ($count): string {
542 542
         return \str_repeat($string, $count);
543 543
     };
544 544
 }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      * @param string $string The string to pad out.
557 557
      * @return int|string[]
558 558
      */
559
-    return function (string $string) use ($format, $charList) {
559
+    return function(string $string) use ($format, $charList) {
560 560
         return $charList
561 561
             ? (\str_word_count($string, $format, $charList) ?: 0)
562 562
             : (\str_word_count($string, $format) ?: 0);
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
     // If using pre php7.4, cast to string.
580 580
     if (version_compare(PHP_VERSION, '7.4.0', '<') && is_array($allowedTags)) {
581
-        $allowedTags = implode('', array_map(function ($tag) {
581
+        $allowedTags = implode('', array_map(function($tag) {
582 582
             return "<{$tag}>"; // @phpstan-ignore-line
583 583
         }, array_filter($allowedTags, 'is_string')));
584 584
     }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
      * @param string $string The string to strip tags from.
591 591
      * @return string
592 592
      */
593
-    return function (string $string) use ($allowedTags): string {
593
+    return function(string $string) use ($allowedTags): string {
594 594
         return $allowedTags
595 595
             ? \strip_tags($string, $allowedTags) // @phpstan-ignore-line
596 596
             : \strip_tags($string);
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      * @param string $haystack The haystack to look through.
614 614
      * @return int|null
615 615
      */
616
-    return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int {
616
+    return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int {
617 617
         $pos = $caseSensitive
618 618
             ? strpos($haystack, $needle, $offset)
619 619
             : stripos($haystack, $needle, $offset);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
      * @param string $haystack The haystack to look through.
638 638
      * @return int|null
639 639
      */
640
-    return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int {
640
+    return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int {
641 641
         $pos = $caseSensitive
642 642
             ? strrpos($haystack, $needle, $offset)
643 643
             : strripos($haystack, $needle, $offset);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
      * @param string $haystack The haystack to look through.
665 665
      * @return string
666 666
      */
667
-    return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string {
667
+    return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string {
668 668
         $result = $caseSensitive
669 669
             ? strstr($haystack, $needle, $beforeNeedle)
670 670
             : stristr($haystack, $needle, $beforeNeedle);
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
      * @param string $haystack
686 686
      * @return string
687 687
      */
688
-    return function (string $haystack) use ($chars): string {
688
+    return function(string $haystack) use ($chars): string {
689 689
         $result = strpbrk($haystack, $chars);
690 690
         return is_string($result) ? $result : '';
691 691
     };
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
      * @param string $haystack
705 705
      * @return string
706 706
      */
707
-    return function (string $haystack) use ($char): string {
707
+    return function(string $haystack) use ($char): string {
708 708
         $result = strrchr($haystack, $char);
709 709
         return is_string($result) ? $result : '';
710 710
     };
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
      * @param string $haystack
724 724
      * @return string
725 725
      */
726
-    return function (string $haystack) use ($dictionary): string {
726
+    return function(string $haystack) use ($dictionary): string {
727 727
         $result = strtr($haystack, $dictionary);
728 728
         return $result;
729 729
     };
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
      * @param string|null $value
754 754
      * @return Closure|string
755 755
      */
756
-    return function (?string $value = null) use ($initial) {
756
+    return function(?string $value = null) use ($initial) {
757 757
         if ($value) {
758 758
             $initial .= $value;
759 759
         }
Please login to merge, or discard this patch.
src/arrays.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      * @param array<int|string, mixed> $array
47 47
      * @return array<int|string, mixed>
48 48
      */
49
-    return function (array $array) use ($value): array {
49
+    return function(array $array) use ($value): array {
50 50
         $array[] = $value;
51 51
         return $array;
52 52
     };
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param array<int|string, mixed> $array
65 65
      * @return array<int|string, mixed>
66 66
      */
67
-    return function (array $array) use ($value): array {
67
+    return function(array $array) use ($value): array {
68 68
         array_unshift($array, $value);
69 69
         return $array;
70 70
     };
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @return array New array with value on head.
86 86
      */
87 87
     // codecov:miss:next
88
-    return function ($value) use ($array): array {
88
+    return function($value) use ($array): array {
89 89
         array_unshift($array, $value);
90 90
         return $array;
91 91
     };
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param mixed $value Adds value end of array.
106 106
      * @return array<int|string, mixed> New array with value on tail.
107 107
      */
108
-    return function ($value) use ($array): array {
108
+    return function($value) use ($array): array {
109 109
         $array[] = $value;
110 110
         return $array;
111 111
     };
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param array<int|string, mixed> $array Array join
166 166
      * @return string
167 167
      */
168
-    return function (array $array) use ($glue): string {
168
+    return function(array $array) use ($glue) : string {
169 169
         return $glue ? \join($glue, $array) : \join($array);
170 170
     };
171 171
 }
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 function zip(array $additional, $default = null): Closure
182 182
 {
183 183
     $additional = array_values($additional);
184
-    return function (array $array) use ($additional, $default) {
184
+    return function(array $array) use ($additional, $default) {
185 185
         $array = array_values($array);
186 186
         return array_reduce(
187 187
             array_keys($array),
188
-            function ($carry, $key) use ($array, $additional, $default): array {
188
+            function($carry, $key) use ($array, $additional, $default): array {
189 189
                 $carry[] = array(
190 190
                     $array[$key],
191 191
                     array_key_exists($key, $additional) ? $additional[$key] : $default,
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      * @param mixed $value Adds value to inner array if value set, else returns.
219 219
      * @return mixed[]|Closure
220 220
      */
221
-    return function ($value = null) use ($inital) {
221
+    return function($value = null) use ($inital) {
222 222
         if ($value) {
223 223
             $inital[] = $value;
224 224
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @param mixed $value
244 244
      * @return mixed[]|Closure
245 245
      */
246
-    return function ($value = null) use ($validator, $inital) {
246
+    return function($value = null) use ($validator, $inital) {
247 247
         if (!is_null($value) && $validator($value)) {
248 248
             $inital[] = $value;
249 249
         }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
      * @param array<int|string, mixed> $source Array to filter
273 273
      * @return array<int|string, mixed> Filtered array.
274 274
      */
275
-    return function (array $source) use ($callable): array {
275
+    return function(array $source) use ($callable): array {
276 276
         return array_filter($source, $callable);
277 277
     };
278 278
 }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      * @param array<int|string, mixed> $source Array to filter
290 290
      * @return array<int|string, mixed> Filtered array.
291 291
      */
292
-    return function (array $source) use ($callable): array {
292
+    return function(array $source) use ($callable): array {
293 293
         return array_filter($source, $callable, \ARRAY_FILTER_USE_KEY);
294 294
     };
295 295
 }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      * @param array<int|string, mixed> $source Array to filter
308 308
      * @return array<int|string, mixed> Filtered array.
309 309
      */
310
-    return function (array $source) use ($callables): array {
310
+    return function(array $source) use ($callables): array {
311 311
         return array_filter($source, Comp\groupAnd(...$callables));
312 312
     };
313 313
 }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * @param array<int|string, mixed> $source Array to filter
326 326
      * @return array<int|string, mixed> Filtered array.
327 327
      */
328
-    return function (array $source) use ($callables): array {
328
+    return function(array $source) use ($callables): array {
329 329
         return array_filter($source, Comp\groupOr(...$callables));
330 330
     };
331 331
 }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      * @param array<int|string, mixed> $array The array to filter
343 343
      * @return mixed|null The first element from the filtered array or null if filter returns empty
344 344
      */
345
-    return function (array $array) use ($func) {
345
+    return function(array $array) use ($func) {
346 346
         foreach ($array as $value) {
347 347
             $result = $func($value);
348 348
             if (\is_bool($result) && $result) {
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
      * @param array<int|string, mixed> $array The array to filter
365 365
      * @return mixed|null The last element from the filtered array.
366 366
      */
367
-    return function (array $array) use ($func) {
367
+    return function(array $array) use ($func) {
368 368
         while ($value = array_pop($array)) {
369 369
             $result = $func($value);
370 370
             if (\is_bool($result) && $result) {
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
      * @param array<int|string, mixed> $array The array to filter then map.
390 390
      * @return array<int|string, mixed>
391 391
      */
392
-    return function (array $array) use ($filter, $map): array {
392
+    return function(array $array) use ($filter, $map): array {
393 393
         return array_map($map, array_filter($array, $filter));
394 394
     };
395 395
 }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
      * @param array<int|string, mixed> $array
407 407
      * @return int Count
408 408
      */
409
-    return function (array $array) use ($function) {
409
+    return function(array $array) use ($function) {
410 410
         return count(array_filter($array, $function));
411 411
     };
412 412
 }
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      * @param mixed[] $array
426 426
      * @return array{0:mixed[], 1:mixed[]}
427 427
      */
428
-    return function (array $array) use ($function): array {
428
+    return function(array $array) use ($function): array {
429 429
         return array_reduce(
430 430
             $array,
431 431
             /**
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
              * @param mixed $element
434 434
              * @return array{0:mixed[], 1:mixed[]}
435 435
              */
436
-            function ($carry, $element) use ($function): array {
437
-                $key             = (bool) $function($element) ? 1 : 0;
436
+            function($carry, $element) use ($function): array {
437
+                $key = (bool) $function($element) ? 1 : 0;
438 438
                 $carry[$key][] = $element;
439 439
                 return $carry;
440 440
             },
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      * @param mixed[] $array
456 456
      * @return bool
457 457
      */
458
-    return function (array $array) use ($function): bool {
458
+    return function(array $array) use ($function): bool {
459 459
         foreach ($array as $value) {
460 460
             if (false === $function($value)) {
461 461
                 return false;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
      * @param mixed[] $array
479 479
      * @return bool
480 480
      */
481
-    return function (array $array) use ($function): bool {
481
+    return function(array $array) use ($function): bool {
482 482
         foreach ($array as $value) {
483 483
             if (true === $function($value)) {
484 484
                 return true;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
      * @param mixed[] $array The array to map
510 510
      * @return mixed[]
511 511
      */
512
-    return function (array $array) use ($func): array {
512
+    return function(array $array) use ($func): array {
513 513
         return array_map($func, $array);
514 514
     };
515 515
 }
@@ -527,10 +527,10 @@  discard block
 block discarded – undo
527 527
      * @param mixed[] $array The array to map
528 528
      * @return mixed[]
529 529
      */
530
-    return function (array $array) use ($func): array {
530
+    return function(array $array) use ($func): array {
531 531
         return array_reduce(
532 532
             array_keys($array),
533
-            function ($carry, $key) use ($func, $array) {
533
+            function($carry, $key) use ($func, $array) {
534 534
                 $carry[$func($key)] = $array[$key];
535 535
                 return $carry;
536 536
             },
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
      * @param mixed[] $array The array to map
553 553
      * @return mixed[]
554 554
      */
555
-    return function (array $array) use ($func, $data): array {
555
+    return function(array $array) use ($func, $data): array {
556 556
         return array_map(
557
-            function ($e) use ($data, $func) {
557
+            function($e) use ($data, $func) {
558 558
                 return $func($e, ...$data);
559 559
             },
560 560
             $array
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
      * @param mixed[] $array The array to map
575 575
      * @return mixed[]
576 576
      */
577
-    return function (array $array) use ($func): array {
577
+    return function(array $array) use ($func): array {
578 578
         return array_map(
579
-            function ($key, $value) use ($func) {
579
+            function($key, $value) use ($func) {
580 580
                 return $func($value, $key);
581 581
             },
582 582
             $array,
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
      * @param mixed[] $array The array to map
598 598
      * @return void
599 599
      */
600
-    return function (array $array) use ($func): void {
600
+    return function(array $array) use ($func): void {
601 601
         array_map(
602
-            function ($key, $value) use ($func) {
602
+            function($key, $value) use ($func) {
603 603
                 $func($key, $value);
604 604
             },
605 605
             array_keys($array),
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
      * @param mixed[] $array
622 622
      * @return mixed[]
623 623
      */
624
-    return function (array $array) use ($n, $function): array {
624
+    return function(array $array) use ($n, $function) : array {
625 625
         return array_reduce(
626 626
             $array,
627 627
             /**
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
              * @param mixed $element
630 630
              * @return mixed[]
631 631
              */
632
-            function (array $carry, $element) use ($n, $function): array {
632
+            function(array $carry, $element) use ($n, $function) : array {
633 633
                 if (is_array($element) && (is_null($n) || $n > 0)) {
634 634
                     $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element));
635 635
                 } else {
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
      * @param mixed[] $array The array to be grouped
662 662
      * @return mixed[] Grouped array.
663 663
      */
664
-    return function (array $array) use ($function): array {
664
+    return function(array $array) use ($function): array {
665 665
         return array_reduce(
666 666
             $array,
667 667
             /**
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
              * @param mixed $element
670 670
              * @return mixed[]
671 671
              */
672
-            function ($carry, $item) use ($function): array {
672
+            function($carry, $item) use ($function): array {
673 673
                 $carry[call_user_func($function, $item)][] = $item;
674 674
                 return $carry;
675 675
             },
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
      * @param mixed[] $array Array to chunk
692 692
      * @return mixed[]
693 693
      */
694
-    return function (array $array) use ($count, $preserveKeys): array {
694
+    return function(array $array) use ($count, $preserveKeys): array {
695 695
         return array_chunk($array, max(1, $count), $preserveKeys);
696 696
     };
697 697
 }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
      * @param mixed[] $array
710 710
      * @return mixed[]
711 711
      */
712
-    return function (array $array) use ($column, $key): array {
712
+    return function(array $array) use ($column, $key) : array {
713 713
         return array_column($array, $column, $key);
714 714
     };
715 715
 }
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
      * @param mixed[] $array Array to flatten
727 727
      * @return mixed[]
728 728
      */
729
-    return function (array $array) use ($n): array {
729
+    return function(array $array) use ($n) : array {
730 730
         return array_reduce(
731 731
             $array,
732 732
             /**
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
              * @param mixed|mixed[] $element
735 735
              * @return array<int|string, mixed>
736 736
              */
737
-            function (array $carry, $element) use ($n): array {
737
+            function(array $carry, $element) use ($n) : array {
738 738
                 // Remove empty arrays.
739 739
                 if (is_array($element) && empty($element)) {
740 740
                     return $carry;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
      * @param mixed[] $array The array to have elements replaced from.
766 766
      * @return mixed[] Array with replacements.
767 767
      */
768
-    return function (array $array) use ($with): array {
768
+    return function(array $array) use ($with): array {
769 769
         return array_replace_recursive($array, ...$with);
770 770
     };
771 771
 }
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
      * @param mixed[] $array The array to have elements replaced from.
783 783
      * @return mixed[] Array with replacements.
784 784
      */
785
-    return function (array $array) use ($with): array {
785
+    return function(array $array) use ($with): array {
786 786
         return array_replace($array, ...$with);
787 787
     };
788 788
 }
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
      * @param mixed[] $array Array to do sum() on.
800 800
      * @return Number The total.
801 801
      */
802
-    return function (array $array) use ($function) {
802
+    return function(array $array) use ($function) {
803 803
         return array_sum(array_map($function, $array));
804 804
     };
805 805
 }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
      * @param mixed[] $array
827 827
      * @return object
828 828
      */
829
-    return function (array $array) use ($object) {
829
+    return function(array $array) use ($object) {
830 830
         foreach ($array as $key => $value) {
831 831
             // If key is not a string or numerical, skip it.
832 832
             if (!is_string($key) || is_numeric($key)) {
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
      * @param mixed $data
863 863
      * @return string|null
864 864
      */
865
-    return function ($data) use ($flags, $depth): ?string {
865
+    return function($data) use ($flags, $depth): ?string {
866 866
         return \json_encode($data, $flags, max(1, $depth)) ?: null;
867 867
     };
868 868
 }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
      *  @param mixed[]$array The array to sort
889 889
      *  @return mixed[] The sorted array (new array)
890 890
      */
891
-    return function (array $array) use ($flag) {
891
+    return function(array $array) use ($flag) {
892 892
         \sort($array, $flag);
893 893
         return $array;
894 894
     };
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
      *  @param mixed[]$array The array to sort
908 908
      *  @return mixed[] The sorted array (new array)
909 909
      */
910
-    return function (array $array) use ($flag) {
910
+    return function(array $array) use ($flag) {
911 911
         \rsort($array, $flag);
912 912
         return $array;
913 913
     };
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
      *  @param mixed[]$array The array to sort
927 927
      *  @return mixed[] The sorted array (new array)
928 928
      */
929
-    return function (array $array) use ($flag) {
929
+    return function(array $array) use ($flag) {
930 930
         \ksort($array, $flag);
931 931
         return $array;
932 932
     };
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
      *  @param mixed[]$array The array to sort
945 945
      *  @return mixed[] The sorted array (new array)
946 946
      */
947
-    return function (array $array) use ($flag) {
947
+    return function(array $array) use ($flag) {
948 948
         \krsort($array, $flag);
949 949
         return $array;
950 950
     };
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
      *  @param mixed[]$array The array to sort
964 964
      *  @return mixed[] The sorted array (new array)
965 965
      */
966
-    return function (array $array) use ($flag) {
966
+    return function(array $array) use ($flag) {
967 967
         \asort($array, $flag);
968 968
         return $array;
969 969
     };
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
      *  @param mixed[]$array The array to sort
983 983
      *  @return mixed[] The sorted array (new array)
984 984
      */
985
-    return function (array $array) use ($flag) {
985
+    return function(array $array) use ($flag) {
986 986
         \arsort($array, $flag);
987 987
         return $array;
988 988
     };
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
      *  @param mixed[]$array The array to sort
1000 1000
      *  @return mixed[] The sorted array (new array)
1001 1001
      */
1002
-    return function (array $array) {
1002
+    return function(array $array) {
1003 1003
         \natsort($array);
1004 1004
         return $array;
1005 1005
     };
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
      *  @param mixed[]$array The array to sort
1017 1017
      *  @return mixed[] The sorted array (new array)
1018 1018
      */
1019
-    return function (array $array) {
1019
+    return function(array $array) {
1020 1020
         \natcasesort($array);
1021 1021
         return $array;
1022 1022
     };
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
      *  @param mixed[] $array The array to sort
1035 1035
      *  @return mixed[] The sorted array (new array)
1036 1036
      */
1037
-    return function (array $array) use ($function) {
1037
+    return function(array $array) use ($function) {
1038 1038
         \uksort($array, $function);
1039 1039
         return $array;
1040 1040
     };
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
      *  @param mixed[]$array The array to sort
1054 1054
      *  @return mixed[] The sorted array (new array)
1055 1055
      */
1056
-    return function (array $array) use ($function) {
1056
+    return function(array $array) use ($function) {
1057 1057
         \uasort($array, $function);
1058 1058
         return $array;
1059 1059
     };
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
      *  @param mixed[]$array The array to sort
1074 1074
      *  @return mixed[] The sorted array (new array)
1075 1075
      */
1076
-    return function (array $array) use ($function) {
1076
+    return function(array $array) use ($function) {
1077 1077
         \usort($array, $function);
1078 1078
         return $array;
1079 1079
     };
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
  */
1090 1090
 function scan(callable $function, $initialValue): Closure
1091 1091
 {
1092
-    return function (array $array) use ($function, $initialValue) {
1092
+    return function(array $array) use ($function, $initialValue) {
1093 1093
         $carry[] = $initialValue;
1094 1094
         foreach ($array as $key => $value) {
1095 1095
             $initialValue = $function($initialValue, $value);
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
  */
1109 1109
 function scanR(callable $function, $initialValue): Closure
1110 1110
 {
1111
-    return function (array $array) use ($function, $initialValue) {
1111
+    return function(array $array) use ($function, $initialValue) {
1112 1112
         $carry[] = $initialValue;
1113 1113
         foreach (array_reverse($array) as $key => $value) {
1114 1114
             $initialValue = $function($initialValue, $value);
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
      * @param mixed[] $array
1132 1132
      * @return mixed
1133 1133
      */
1134
-    return function (array $array) use ($callable, $initial) {
1134
+    return function(array $array) use ($callable, $initial) {
1135 1135
         return array_reduce($array, $callable, $initial);
1136 1136
     };
1137 1137
 }
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
      * @param mixed[] $array
1150 1150
      * @return mixed
1151 1151
      */
1152
-    return function (array $array) use ($callable, $initial) {
1152
+    return function(array $array) use ($callable, $initial) {
1153 1153
         return array_reduce(\array_reverse($array), $callable, $initial);
1154 1154
     };
1155 1155
 }
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
      * @param mixed[] $array
1169 1169
      * @return mixed
1170 1170
      */
1171
-    return function (array $array) use ($callable, $initial) {
1171
+    return function(array $array) use ($callable, $initial) {
1172 1172
         foreach ($array as $key => $value) {
1173 1173
             $initial = $callable($initial, $key, $value);
1174 1174
         }
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
      * @param mixed[] $array
1195 1195
      * @return mixed[]
1196 1196
      */
1197
-    return function (array $array) use ($count) {
1197
+    return function(array $array) use ($count) {
1198 1198
         return \array_slice($array, 0, $count);
1199 1199
     };
1200 1200
 }
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 
1216 1216
     // If count is 0, return an empty array
1217 1217
     if ($count === 0) {
1218
-        return function (array $array) {
1218
+        return function(array $array) {
1219 1219
             return array();
1220 1220
         };
1221 1221
     }
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
      * @param mixed[] $array
1225 1225
      * @return mixed[]
1226 1226
      */
1227
-    return function (array $array) use ($count) {
1227
+    return function(array $array) use ($count) {
1228 1228
         return \array_slice($array, -$count);
1229 1229
     };
1230 1230
 }
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
      * @param mixed[] $array
1243 1243
      * @return mixed[]
1244 1244
      */
1245
-    return function (array $array) use ($conditional) {
1245
+    return function(array $array) use ($conditional) {
1246 1246
         $carry = array();
1247 1247
         foreach ($array as $key => $value) {
1248 1248
             if (true === $conditional($value)) {
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
      * @param mixed[] $array
1268 1268
      * @return mixed[]
1269 1269
      */
1270
-    return function (array $array) use ($conditional) {
1270
+    return function(array $array) use ($conditional) {
1271 1271
         $carry = array();
1272 1272
         foreach ($array as $key => $value) {
1273 1273
             if (false === $conditional($value)) {
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
      * @param mixed[] $array
1292 1292
      * @return mixed[]
1293 1293
      */
1294
-    return function (array $array) use ($indexes) {
1294
+    return function(array $array) use ($indexes) {
1295 1295
         return array_intersect_key($array, array_flip($indexes));
1296 1296
     };
1297 1297
 }
Please login to merge, or discard this patch.