Passed
Pull Request — develop (#64)
by Glynn
02:33
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/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   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      * @param mixed The value passed into the functions
50 50
      * @return mixed The final result.
51 51
      */
52
-    return function ($e) use ($callables) {
52
+    return function($e) use ($callables) {
53 53
         foreach ($callables as $callable) {
54 54
             $e = $callable($e);
55 55
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      * @param mixed The value passed into the functions
71 71
      * @return mixed The final result.
72 72
      */
73
-    return function ($e) use ($callables) {
73
+    return function($e) use ($callables) {
74 74
         foreach (\array_reverse($callables) as $callable) {
75 75
             $e = $callable($e);
76 76
         }
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
      * @param mixed The value passed into the functions
92 92
      * @return mixed|null The final result or null.
93 93
      */
94
-    return function ($e) use ($callables) {
94
+    return function($e) use ($callables) {
95 95
         foreach ($callables as $callable) {
96
-            if (! is_null($e)) {
96
+            if (!is_null($e)) {
97 97
                 $e = $callable($e);
98 98
             }
99 99
         }
@@ -116,17 +116,17 @@  discard block
 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
-            if (! $validator($e)) {
122
+            if (!$validator($e)) {
123 123
                 return null;
124 124
             }
125 125
             // Run through callable.
126 126
             $e = $callable($e);
127 127
 
128 128
             // Check results and bail if invalid type.
129
-            if (! $validator($e)) {
129
+            if (!$validator($e)) {
130 130
                 return null;
131 131
             }
132 132
         }
@@ -172,9 +172,9 @@  discard block
 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
-            return array_key_exists($property, $data) ? $data[ $property ] : null;
177
+            return array_key_exists($property, $data) ? $data[$property] : null;
178 178
         } elseif (is_object($data)) {
179 179
             return property_exists($data, $property) ? $data->{$property} : null;
180 180
         } else {
@@ -197,7 +197,7 @@  discard block
 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),
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 {
273 273
 
274 274
     // If passed store is not an array or object, throw exception.
275
-    if (! isArrayAccess($store) && ! is_object($store)) {
275
+    if (!isArrayAccess($store) && !is_object($store)) {
276 276
         throw new TypeError('Only objects or arrays can be constructed using setProperty.');
277 277
     }
278 278
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
      * @param mixed $value The value to set to keu.
281 281
      * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore.
282 282
      */
283
-    return function ($value) use ($store, $property) {
283
+    return function($value) use ($store, $property) {
284 284
         if (isArrayAccess($store)) {
285 285
             /** @phpstan-ignore-next-line */
286
-            $store[ $property ] = $value;
286
+            $store[$property] = $value;
287 287
         } else {
288 288
             $store->{$property} = $value;
289 289
         }
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
      * @param mixed $data The data to pass through the callable
307 307
      * @return array
308 308
      */
309
-    return function ($data) use ($key, $value): array {
310
-        return array( $key => $value($data) );
309
+    return function($data) use ($key, $value): array {
310
+        return array($key => $value($data));
311 311
     };
312 312
 }
313 313
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
      * @param callable(mixed):mixed ...$encoders encodeProperty() functions.
325 325
      * @return Closure
326 326
      */
327
-    return function (...$encoders) use ($dataType): Closure {
327
+    return function(...$encoders) use ($dataType): Closure {
328 328
         /**
329 329
          * @param mixed $data The data to pass through the encoders.
330 330
          * @return array<string,mixed>|object The encoded object/array.
331 331
          */
332
-        return function ($data) use ($dataType, $encoders) {
332
+        return function($data) use ($dataType, $encoders) {
333 333
             foreach ($encoders as $encoder) {
334 334
                 $key = array_keys($encoder($data))[0];
335 335
                 // throw exception if key is int
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * @param mixed ...$args
357 357
      * @return mixed
358 358
      */
359
-    return function (...$args) use ($fn) {
359
+    return function(...$args) use ($fn) {
360 360
         return $fn(...$args);
361 361
     };
362 362
 }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * @param mixed $ignored Any values can be passed and ignored.
374 374
      * @return mixed
375 375
      */
376
-    return function (...$ignored) use ($value) {
376
+    return function(...$ignored) use ($value) {
377 377
         return $value;
378 378
     };
379 379
 }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      * @param  mixed $value
409 409
      * @return mixed
410 410
      */
411
-    return function ($value) use ($condition, $then) {
411
+    return function($value) use ($condition, $then) {
412 412
         return true === (bool) $condition($value)
413 413
             ? $then($value)
414 414
             : $value;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      * @param  mixed $value
432 432
      * @return mixed
433 433
      */
434
-    return function ($value) use ($condition, $then, $else) {
434
+    return function($value) use ($condition, $then, $else) {
435 435
         return true === (bool) $condition($value)
436 436
             ? $then($value)
437 437
             : $else($value);
Please login to merge, or discard this patch.
src/strings.php 1 patch
Spacing   +43 added lines, -43 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,8 +68,8 @@  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 {
72
-        return ! $finish
71
+    return function(string $string) use ($start, $finish) : string {
72
+        return !$finish
73 73
             ? substr($string, $start)
74 74
             : substr($string, $start, $finish);
75 75
     };
@@ -87,7 +87,7 @@  discard block
 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 : []; // @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
 }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 function countChars(int $mode = 1): Closure
401 401
 {
402 402
     // Throw an exception if the mode is not supported.
403
-    if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) {
403
+    if (!in_array($mode, array(0, 1, 2, 3, 4), true)) {
404 404
         throw new \InvalidArgumentException('Invalid mode');
405 405
     }
406 406
 
@@ -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;
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
      * @param string $comparisonString The string to act as the base.
521 521
      * @return Number
522 522
      */
523
-    return function (string $base) use ($comparisonString, $asPc) {
523
+    return function(string $base) use ($comparisonString, $asPc) {
524 524
         $pc       = 0.00;
525 525
         $matching = similar_text($base, $comparisonString, $pc);
526 526
         return $asPc ? $pc : $matching;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      * @param string $string The string to pad out.
542 542
      * @return string
543 543
      */
544
-    return function (string $string) use ($length, $padContent, $type): string {
544
+    return function(string $string) use ($length, $padContent, $type): string {
545 545
         return \str_pad($string, $length, $padContent, $type);
546 546
     };
547 547
 }
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
      * @param string $string The string to repeat
559 559
      * @return string
560 560
      */
561
-    return function (string $string) use ($count): string {
561
+    return function(string $string) use ($count): string {
562 562
         return \str_repeat($string, $count);
563 563
     };
564 564
 }
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
      * @param string $string The string to pad out.
577 577
      * @return int|string[]
578 578
      */
579
-    return function (string $string) use ($format, $charList) {
579
+    return function(string $string) use ($format, $charList) {
580 580
         return $charList
581 581
             ? (\str_word_count($string, $format, $charList) ?: 0)
582 582
             : (\str_word_count($string, $format) ?: 0);
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
      * @param string $string The string to strip tags from.
596 596
      * @return string
597 597
      */
598
-    return function (string $string) use ($allowedTags): string {
598
+    return function(string $string) use ($allowedTags) : string {
599 599
         return $allowedTags
600 600
             ? \strip_tags($string, $allowedTags)
601 601
             : \strip_tags($string);
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
  */
613 613
 function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure
614 614
 {
615
-    $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
615
+    $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
616 616
 
617 617
     /**
618 618
      * @param string $haystack The haystack to look through.
619 619
      * @return int|null
620 620
      */
621
-    return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int {
621
+    return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int {
622 622
         $pos = $caseSensitive
623 623
             ? strpos($haystack, $needle, $offset)
624 624
             : stripos($haystack, $needle, $offset);
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
  */
637 637
 function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure
638 638
 {
639
-    $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
639
+    $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
640 640
 
641 641
     /**
642 642
      * @param string $haystack The haystack to look through.
643 643
      * @return int|null
644 644
      */
645
-    return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int {
645
+    return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int {
646 646
         $pos = $caseSensitive
647 647
             ? strrpos($haystack, $needle, $offset)
648 648
             : strripos($haystack, $needle, $offset);
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
 
665 665
     // Decode flags, only look for none defaults.
666 666
     $beforeNeedle  = (bool) ($flags & STRINGS_BEFORE_NEEDLE);
667
-    $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
667
+    $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed
668 668
 
669 669
     /**
670 670
      * @param string $haystack The haystack to look through.
671 671
      * @return string
672 672
      */
673
-    return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string {
673
+    return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string {
674 674
         $result = $caseSensitive
675 675
             ? strstr($haystack, $needle, $beforeNeedle)
676 676
             : stristr($haystack, $needle, $beforeNeedle);
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
      * @param string $haystack
692 692
      * @return string
693 693
      */
694
-    return function (string $haystack) use ($chars): string {
694
+    return function(string $haystack) use ($chars): string {
695 695
         $result = strpbrk($haystack, $chars);
696 696
         return is_string($result) ? $result : '';
697 697
     };
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
      * @param string $haystack
711 711
      * @return string
712 712
      */
713
-    return function (string $haystack) use ($char): string {
713
+    return function(string $haystack) use ($char): string {
714 714
         $result = strrchr($haystack, $char);
715 715
         return is_string($result) ? $result : '';
716 716
     };
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
      * @param string $haystack
730 730
      * @return string
731 731
      */
732
-    return function (string $haystack) use ($dictionary): string {
732
+    return function(string $haystack) use ($dictionary): string {
733 733
         $result = strtr($haystack, $dictionary);
734 734
         return $result;
735 735
     };
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
      * @param string|null $value
760 760
      * @return Closure|string
761 761
      */
762
-    return function (?string $value = null) use ($initial) {
762
+    return function(?string $value = null) use ($initial) {
763 763
         if ($value) {
764 764
             $initial .= $value;
765 765
         }
Please login to merge, or discard this patch.
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/arrays.php 1 patch
Spacing   +77 added lines, -77 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
 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @param array<int|string, mixed> $source Array to filter
249 249
      * @return array<int|string, mixed> Filtered array.
250 250
      */
251
-    return function (array $source) use ($callables): array {
251
+    return function(array $source) use ($callables): array {
252 252
         return array_filter($source, Comp\groupAnd(...$callables));
253 253
     };
254 254
 }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      * @param array<int|string, mixed> $source Array to filter
267 267
      * @return array<int|string, mixed> Filtered array.
268 268
      */
269
-    return function (array $source) use ($callables): array {
269
+    return function(array $source) use ($callables): array {
270 270
         return array_filter($source, Comp\groupOr(...$callables));
271 271
     };
272 272
 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      * @param array<int|string, mixed> $array The array to filter
284 284
      * @return mixed|null The first element from the filtered array or null if filter returns empty
285 285
      */
286
-    return function (array $array) use ($func) {
286
+    return function(array $array) use ($func) {
287 287
         return head(array_filter($array, $func));
288 288
     };
289 289
 }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      * @param array<int|string, mixed> $array The array to filter
301 301
      * @return mixed|null The last element from the filtered array.
302 302
      */
303
-    return function (array $array) use ($func) {
303
+    return function(array $array) use ($func) {
304 304
         return tail(array_filter($array, $func));
305 305
     };
306 306
 }
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      * @param array<int|string, mixed> $array The array to filter then map.
321 321
      * @return array<int|string, mixed>
322 322
      */
323
-    return function (array $array) use ($filter, $map): array {
323
+    return function(array $array) use ($filter, $map): array {
324 324
         return array_map($map, array_filter($array, $filter));
325 325
     };
326 326
 }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      * @param array<int|string, mixed> $array
338 338
      * @return int Count
339 339
      */
340
-    return function (array $array) use ($function) {
340
+    return function(array $array) use ($function) {
341 341
         return count(array_filter($array, $function));
342 342
     };
343 343
 }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * @param mixed[] $array
357 357
      * @return array{0:mixed[], 1:mixed[]}
358 358
      */
359
-    return function (array $array) use ($function): array {
359
+    return function(array $array) use ($function): array {
360 360
         return array_reduce(
361 361
             $array,
362 362
             /**
@@ -364,12 +364,12 @@  discard block
 block discarded – undo
364 364
              * @param mixed $element
365 365
              * @return array{0:mixed[], 1:mixed[]}
366 366
              */
367
-            function ($carry, $element) use ($function): array {
367
+            function($carry, $element) use ($function): array {
368 368
                 $key             = (bool) $function($element) ? 1 : 0;
369
-                $carry[ $key ][] = $element;
369
+                $carry[$key][] = $element;
370 370
                 return $carry;
371 371
             },
372
-            array( array(), array() )
372
+            array(array(), array())
373 373
         );
374 374
     };
375 375
 }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      * @param mixed[] $array
387 387
      * @return bool
388 388
      */
389
-    return function (array $array) use ($function): bool {
389
+    return function(array $array) use ($function): bool {
390 390
         foreach ($array as $value) {
391 391
             if (false === $function($value)) {
392 392
                 return false;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      * @param mixed[] $array
410 410
      * @return bool
411 411
      */
412
-    return function (array $array) use ($function): bool {
412
+    return function(array $array) use ($function): bool {
413 413
         foreach ($array as $value) {
414 414
             if (true === $function($value)) {
415 415
                 return true;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      * @param mixed[] $array The array to map
441 441
      * @return mixed[]
442 442
      */
443
-    return function (array $array) use ($func): array {
443
+    return function(array $array) use ($func): array {
444 444
         return array_map($func, $array);
445 445
     };
446 446
 }
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
      * @param mixed[] $array The array to map
459 459
      * @return mixed[]
460 460
      */
461
-    return function (array $array) use ($func): array {
461
+    return function(array $array) use ($func): array {
462 462
         return array_reduce(
463 463
             array_keys($array),
464
-            function ($carry, $key) use ($func, $array) {
465
-                $carry[ $func($key) ] = $array[ $key ];
464
+            function($carry, $key) use ($func, $array) {
465
+                $carry[$func($key)] = $array[$key];
466 466
                 return $carry;
467 467
             },
468 468
             array()
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
      * @param mixed[] $array The array to map
484 484
      * @return mixed[]
485 485
      */
486
-    return function (array $array) use ($func, $data): array {
486
+    return function(array $array) use ($func, $data): array {
487 487
         return array_map(
488
-            function ($e) use ($data, $func) {
488
+            function($e) use ($data, $func) {
489 489
                 return $func($e, ...$data);
490 490
             },
491 491
             $array
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
      * @param mixed[] $array The array to map
506 506
      * @return mixed[]
507 507
      */
508
-    return function (array $array) use ($func): array {
508
+    return function(array $array) use ($func): array {
509 509
         return array_map(
510
-            function ($key, $value) use ($func) {
510
+            function($key, $value) use ($func) {
511 511
                 return $func($value, $key);
512 512
             },
513 513
             $array,
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
      * @param mixed[] $array The array to map
529 529
      * @return void
530 530
      */
531
-    return function (array $array) use ($func): void {
531
+    return function(array $array) use ($func): void {
532 532
         array_map(
533
-            function ($key, $value) use ($func) {
533
+            function($key, $value) use ($func) {
534 534
                 $func($key, $value);
535 535
             },
536 536
             array_keys($array),
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
      * @param mixed[] $array
553 553
      * @return mixed[]
554 554
      */
555
-    return function (array $array) use ($n, $function): array {
555
+    return function(array $array) use ($n, $function) : array {
556 556
         return array_reduce(
557 557
             $array,
558 558
             /**
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
              * @param mixed $element
561 561
              * @return mixed[]
562 562
              */
563
-            function (array $carry, $element) use ($n, $function): array {
563
+            function(array $carry, $element) use ($n, $function) : array {
564 564
                 if (is_array($element) && (is_null($n) || $n > 0)) {
565 565
                     $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element));
566 566
                 } else {
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
      * @param mixed[] $array The array to be grouped
593 593
      * @return mixed[] Grouped array.
594 594
      */
595
-    return function (array $array) use ($function): array {
595
+    return function(array $array) use ($function): array {
596 596
         return array_reduce(
597 597
             $array,
598 598
             /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
              * @param mixed $element
601 601
              * @return mixed[]
602 602
              */
603
-            function ($carry, $item) use ($function): array {
604
-                $carry[ call_user_func($function, $item) ][] = $item;
603
+            function($carry, $item) use ($function): array {
604
+                $carry[call_user_func($function, $item)][] = $item;
605 605
                 return $carry;
606 606
             },
607 607
             array()
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
      * @param mixed[] $array Array to chunk
623 623
      * @return mixed[]
624 624
      */
625
-    return function (array $array) use ($count, $preserveKeys): array {
625
+    return function(array $array) use ($count, $preserveKeys): array {
626 626
         return array_chunk($array, max(1, $count), $preserveKeys);
627 627
     };
628 628
 }
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @param mixed[] $array
641 641
      * @return mixed[]
642 642
      */
643
-    return function (array $array) use ($column, $key): array {
643
+    return function(array $array) use ($column, $key) : array {
644 644
         return array_column($array, $column, $key);
645 645
     };
646 646
 }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
      * @param mixed[] $array Array to flatten
658 658
      * @return mixed[]
659 659
      */
660
-    return function (array $array) use ($n): array {
660
+    return function(array $array) use ($n) : array {
661 661
         return array_reduce(
662 662
             $array,
663 663
             /**
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
              * @param mixed|mixed[] $element
666 666
              * @return array<int|string, mixed>
667 667
              */
668
-            function (array $carry, $element) use ($n): array {
668
+            function(array $carry, $element) use ($n) : array {
669 669
                 // Remove empty arrays.
670 670
                 if (is_array($element) && empty($element)) {
671 671
                     return $carry;
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
      * @param mixed[] $array The array to have elements replaced from.
697 697
      * @return mixed[] Array with replacements.
698 698
      */
699
-    return function (array $array) use ($with): array {
699
+    return function(array $array) use ($with): array {
700 700
         return array_replace_recursive($array, ...$with);
701 701
     };
702 702
 }
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
      * @param mixed[] $array The array to have elements replaced from.
714 714
      * @return mixed[] Array with replacements.
715 715
      */
716
-    return function (array $array) use ($with): array {
716
+    return function(array $array) use ($with): array {
717 717
         return array_replace($array, ...$with);
718 718
     };
719 719
 }
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
      * @param mixed[] $array Array to do sum() on.
731 731
      * @return Number The total.
732 732
      */
733
-    return function (array $array) use ($function) {
733
+    return function(array $array) use ($function) {
734 734
         return array_sum(array_map($function, $array));
735 735
     };
736 736
 }
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
     $object = $object ?? new stdClass();
750 750
 
751 751
     // Throws an exception if $object is not an object.
752
-    if (! is_object($object)) {
752
+    if (!is_object($object)) {
753 753
         throw new \InvalidArgumentException('Object must be an object.');
754 754
     }
755 755
 
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
      * @param mixed[] $array
758 758
      * @return object
759 759
      */
760
-    return function (array $array) use ($object) {
760
+    return function(array $array) use ($object) {
761 761
         foreach ($array as $key => $value) {
762 762
             // If key is not a string or numerical, skip it.
763
-            if (! is_string($key) || is_numeric($key)) {
763
+            if (!is_string($key) || is_numeric($key)) {
764 764
                 continue;
765 765
             }
766 766
 
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
      * @param mixed $data
794 794
      * @return string|null
795 795
      */
796
-    return function ($data) use ($flags, $depth): ?string {
796
+    return function($data) use ($flags, $depth): ?string {
797 797
         return \json_encode($data, $flags, max(1, $depth)) ?: null;
798 798
     };
799 799
 }
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
      *  @param mixed[]$array The array to sort
820 820
      *  @return mixed[] The sorted array (new array)
821 821
      */
822
-    return function (array $array) use ($flag) {
822
+    return function(array $array) use ($flag) {
823 823
         \sort($array, $flag);
824 824
         return $array;
825 825
     };
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
      *  @param mixed[]$array The array to sort
839 839
      *  @return mixed[] The sorted array (new array)
840 840
      */
841
-    return function (array $array) use ($flag) {
841
+    return function(array $array) use ($flag) {
842 842
         \rsort($array, $flag);
843 843
         return $array;
844 844
     };
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
      *  @param mixed[]$array The array to sort
858 858
      *  @return mixed[] The sorted array (new array)
859 859
      */
860
-    return function (array $array) use ($flag) {
860
+    return function(array $array) use ($flag) {
861 861
         \ksort($array, $flag);
862 862
         return $array;
863 863
     };
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
      *  @param mixed[]$array The array to sort
876 876
      *  @return mixed[] The sorted array (new array)
877 877
      */
878
-    return function (array $array) use ($flag) {
878
+    return function(array $array) use ($flag) {
879 879
         \krsort($array, $flag);
880 880
         return $array;
881 881
     };
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
      *  @param mixed[]$array The array to sort
895 895
      *  @return mixed[] The sorted array (new array)
896 896
      */
897
-    return function (array $array) use ($flag) {
897
+    return function(array $array) use ($flag) {
898 898
         \asort($array, $flag);
899 899
         return $array;
900 900
     };
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
      *  @param mixed[]$array The array to sort
914 914
      *  @return mixed[] The sorted array (new array)
915 915
      */
916
-    return function (array $array) use ($flag) {
916
+    return function(array $array) use ($flag) {
917 917
         \arsort($array, $flag);
918 918
         return $array;
919 919
     };
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
      *  @param mixed[]$array The array to sort
931 931
      *  @return mixed[] The sorted array (new array)
932 932
      */
933
-    return function (array $array) {
933
+    return function(array $array) {
934 934
         \natsort($array);
935 935
         return $array;
936 936
     };
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
      *  @param mixed[]$array The array to sort
948 948
      *  @return mixed[] The sorted array (new array)
949 949
      */
950
-    return function (array $array) {
950
+    return function(array $array) {
951 951
         \natcasesort($array);
952 952
         return $array;
953 953
     };
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
      *  @param mixed[] $array The array to sort
966 966
      *  @return mixed[] The sorted array (new array)
967 967
      */
968
-    return function (array $array) use ($function) {
968
+    return function(array $array) use ($function) {
969 969
         \uksort($array, $function);
970 970
         return $array;
971 971
     };
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
      *  @param mixed[]$array The array to sort
985 985
      *  @return mixed[] The sorted array (new array)
986 986
      */
987
-    return function (array $array) use ($function) {
987
+    return function(array $array) use ($function) {
988 988
         \uasort($array, $function);
989 989
         return $array;
990 990
     };
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      *  @param mixed[]$array The array to sort
1005 1005
      *  @return mixed[] The sorted array (new array)
1006 1006
      */
1007
-    return function (array $array) use ($function) {
1007
+    return function(array $array) use ($function) {
1008 1008
         \usort($array, $function);
1009 1009
         return $array;
1010 1010
     };
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
  */
1020 1020
 function scan(callable $function, $initialValue): Closure
1021 1021
 {
1022
-    return function (array $array) use ($function, $initialValue) {
1022
+    return function(array $array) use ($function, $initialValue) {
1023 1023
         $carry[] = $initialValue;
1024 1024
         foreach ($array as $key => $value) {
1025 1025
             $initialValue = $function($initialValue, $value);
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
  */
1039 1039
 function scanR(callable $function, $initialValue): Closure
1040 1040
 {
1041
-    return function (array $array) use ($function, $initialValue) {
1041
+    return function(array $array) use ($function, $initialValue) {
1042 1042
         $carry[] = $initialValue;
1043 1043
         foreach (array_reverse($array) as $key => $value) {
1044 1044
             $initialValue = $function($initialValue, $value);
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
      * @param mixed[] $array
1062 1062
      * @return mixed
1063 1063
      */
1064
-    return function (array $array) use ($callable, $initial) {
1064
+    return function(array $array) use ($callable, $initial) {
1065 1065
         return array_reduce($array, $callable, $initial);
1066 1066
     };
1067 1067
 }
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
      * @param mixed[] $array
1080 1080
      * @return mixed
1081 1081
      */
1082
-    return function (array $array) use ($callable, $initial) {
1082
+    return function(array $array) use ($callable, $initial) {
1083 1083
         return array_reduce(\array_reverse($array), $callable, $initial);
1084 1084
     };
1085 1085
 }
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
      * @param mixed[] $array
1099 1099
      * @return mixed
1100 1100
      */
1101
-    return function (array $array) use ($callable, $initial) {
1101
+    return function(array $array) use ($callable, $initial) {
1102 1102
         foreach ($array as $key => $value) {
1103 1103
             $initial = $callable($initial, $key, $value);
1104 1104
         }
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
      * @param mixed[] $array
1125 1125
      * @return mixed[]
1126 1126
      */
1127
-    return function (array $array) use ($count) {
1127
+    return function(array $array) use ($count) {
1128 1128
         return \array_slice($array, 0, $count);
1129 1129
     };
1130 1130
 }
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
     // If count is 0, return an empty array
1147 1147
     if ($count === 0) {
1148
-        return function (array $array) {
1148
+        return function(array $array) {
1149 1149
             return array();
1150 1150
         };
1151 1151
     }
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
      * @param mixed[] $array
1155 1155
      * @return mixed[]
1156 1156
      */
1157
-    return function (array $array) use ($count) {
1157
+    return function(array $array) use ($count) {
1158 1158
         return \array_slice($array, - $count);
1159 1159
     };
1160 1160
 }
@@ -1172,13 +1172,13 @@  discard block
 block discarded – undo
1172 1172
      * @param mixed[] $array
1173 1173
      * @return mixed[]
1174 1174
      */
1175
-    return function (array $array) use ($conditional) {
1175
+    return function(array $array) use ($conditional) {
1176 1176
         $carry = array();
1177 1177
         foreach ($array as $key => $value) {
1178 1178
             if (true === $conditional($value)) {
1179 1179
                 break;
1180 1180
             }
1181
-            $carry[ $key ] = $value;
1181
+            $carry[$key] = $value;
1182 1182
         }
1183 1183
         return $carry;
1184 1184
     };
@@ -1197,13 +1197,13 @@  discard block
 block discarded – undo
1197 1197
      * @param mixed[] $array
1198 1198
      * @return mixed[]
1199 1199
      */
1200
-    return function (array $array) use ($conditional) {
1200
+    return function(array $array) use ($conditional) {
1201 1201
         $carry = array();
1202 1202
         foreach ($array as $key => $value) {
1203 1203
             if (false === $conditional($value)) {
1204 1204
                 break;
1205 1205
             }
1206
-            $carry[ $key ] = $value;
1206
+            $carry[$key] = $value;
1207 1207
         }
1208 1208
         return $carry;
1209 1209
     };
Please login to merge, or discard this patch.