Passed
Push — develop ( 9835b3...f6fd1b )
by Glynn
01:19 queued 13s
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/arrays.php 1 patch
Spacing   +65 added lines, -65 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
      * @param mixed $value Adds value start of array.
86 86
      * @return array New array with value on head.
87 87
      */
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
         return head(array_filter($array, $func));
347 347
     };
348 348
 }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      * @param array<int|string, mixed> $array The array to filter
360 360
      * @return mixed|null The last element from the filtered array.
361 361
      */
362
-    return function (array $array) use ($func) {
362
+    return function(array $array) use ($func) {
363 363
         return last(array_filter($array, $func));
364 364
     };
365 365
 }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      * @param array<int|string, mixed> $array The array to filter then map.
380 380
      * @return array<int|string, mixed>
381 381
      */
382
-    return function (array $array) use ($filter, $map): array {
382
+    return function(array $array) use ($filter, $map): array {
383 383
         return array_map($map, array_filter($array, $filter));
384 384
     };
385 385
 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
      * @param array<int|string, mixed> $array
397 397
      * @return int Count
398 398
      */
399
-    return function (array $array) use ($function) {
399
+    return function(array $array) use ($function) {
400 400
         return count(array_filter($array, $function));
401 401
     };
402 402
 }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
      * @param mixed[] $array
416 416
      * @return array{0:mixed[], 1:mixed[]}
417 417
      */
418
-    return function (array $array) use ($function): array {
418
+    return function(array $array) use ($function): array {
419 419
         return array_reduce(
420 420
             $array,
421 421
             /**
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
              * @param mixed $element
424 424
              * @return array{0:mixed[], 1:mixed[]}
425 425
              */
426
-            function ($carry, $element) use ($function): array {
427
-                $key             = (bool) $function($element) ? 1 : 0;
426
+            function($carry, $element) use ($function): array {
427
+                $key = (bool) $function($element) ? 1 : 0;
428 428
                 $carry[$key][] = $element;
429 429
                 return $carry;
430 430
             },
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
      * @param mixed[] $array
446 446
      * @return bool
447 447
      */
448
-    return function (array $array) use ($function): bool {
448
+    return function(array $array) use ($function): bool {
449 449
         foreach ($array as $value) {
450 450
             if (false === $function($value)) {
451 451
                 return false;
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
      * @param mixed[] $array
469 469
      * @return bool
470 470
      */
471
-    return function (array $array) use ($function): bool {
471
+    return function(array $array) use ($function): bool {
472 472
         foreach ($array as $value) {
473 473
             if (true === $function($value)) {
474 474
                 return true;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      * @param mixed[] $array The array to map
500 500
      * @return mixed[]
501 501
      */
502
-    return function (array $array) use ($func): array {
502
+    return function(array $array) use ($func): array {
503 503
         return array_map($func, $array);
504 504
     };
505 505
 }
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
      * @param mixed[] $array The array to map
518 518
      * @return mixed[]
519 519
      */
520
-    return function (array $array) use ($func): array {
520
+    return function(array $array) use ($func): array {
521 521
         return array_reduce(
522 522
             array_keys($array),
523
-            function ($carry, $key) use ($func, $array) {
523
+            function($carry, $key) use ($func, $array) {
524 524
                 $carry[$func($key)] = $array[$key];
525 525
                 return $carry;
526 526
             },
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
      * @param mixed[] $array The array to map
543 543
      * @return mixed[]
544 544
      */
545
-    return function (array $array) use ($func, $data): array {
545
+    return function(array $array) use ($func, $data): array {
546 546
         return array_map(
547
-            function ($e) use ($data, $func) {
547
+            function($e) use ($data, $func) {
548 548
                 return $func($e, ...$data);
549 549
             },
550 550
             $array
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
      * @param mixed[] $array The array to map
565 565
      * @return mixed[]
566 566
      */
567
-    return function (array $array) use ($func): array {
567
+    return function(array $array) use ($func): array {
568 568
         return array_map(
569
-            function ($key, $value) use ($func) {
569
+            function($key, $value) use ($func) {
570 570
                 return $func($value, $key);
571 571
             },
572 572
             $array,
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
      * @param mixed[] $array The array to map
588 588
      * @return void
589 589
      */
590
-    return function (array $array) use ($func): void {
590
+    return function(array $array) use ($func): void {
591 591
         array_map(
592
-            function ($key, $value) use ($func) {
592
+            function($key, $value) use ($func) {
593 593
                 $func($key, $value);
594 594
             },
595 595
             array_keys($array),
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
      * @param mixed[] $array
612 612
      * @return mixed[]
613 613
      */
614
-    return function (array $array) use ($n, $function): array {
614
+    return function(array $array) use ($n, $function) : array {
615 615
         return array_reduce(
616 616
             $array,
617 617
             /**
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
              * @param mixed $element
620 620
              * @return mixed[]
621 621
              */
622
-            function (array $carry, $element) use ($n, $function): array {
622
+            function(array $carry, $element) use ($n, $function) : array {
623 623
                 if (is_array($element) && (is_null($n) || $n > 0)) {
624 624
                     $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element));
625 625
                 } else {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      * @param mixed[] $array The array to be grouped
652 652
      * @return mixed[] Grouped array.
653 653
      */
654
-    return function (array $array) use ($function): array {
654
+    return function(array $array) use ($function): array {
655 655
         return array_reduce(
656 656
             $array,
657 657
             /**
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
              * @param mixed $element
660 660
              * @return mixed[]
661 661
              */
662
-            function ($carry, $item) use ($function): array {
662
+            function($carry, $item) use ($function): array {
663 663
                 $carry[call_user_func($function, $item)][] = $item;
664 664
                 return $carry;
665 665
             },
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
      * @param mixed[] $array Array to chunk
682 682
      * @return mixed[]
683 683
      */
684
-    return function (array $array) use ($count, $preserveKeys): array {
684
+    return function(array $array) use ($count, $preserveKeys): array {
685 685
         return array_chunk($array, max(1, $count), $preserveKeys);
686 686
     };
687 687
 }
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
      * @param mixed[] $array
700 700
      * @return mixed[]
701 701
      */
702
-    return function (array $array) use ($column, $key): array {
702
+    return function(array $array) use ($column, $key) : array {
703 703
         return array_column($array, $column, $key);
704 704
     };
705 705
 }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
      * @param mixed[] $array Array to flatten
717 717
      * @return mixed[]
718 718
      */
719
-    return function (array $array) use ($n): array {
719
+    return function(array $array) use ($n) : array {
720 720
         return array_reduce(
721 721
             $array,
722 722
             /**
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
              * @param mixed|mixed[] $element
725 725
              * @return array<int|string, mixed>
726 726
              */
727
-            function (array $carry, $element) use ($n): array {
727
+            function(array $carry, $element) use ($n) : array {
728 728
                 // Remove empty arrays.
729 729
                 if (is_array($element) && empty($element)) {
730 730
                     return $carry;
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
      * @param mixed[] $array The array to have elements replaced from.
756 756
      * @return mixed[] Array with replacements.
757 757
      */
758
-    return function (array $array) use ($with): array {
758
+    return function(array $array) use ($with): array {
759 759
         return array_replace_recursive($array, ...$with);
760 760
     };
761 761
 }
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
      * @param mixed[] $array The array to have elements replaced from.
773 773
      * @return mixed[] Array with replacements.
774 774
      */
775
-    return function (array $array) use ($with): array {
775
+    return function(array $array) use ($with): array {
776 776
         return array_replace($array, ...$with);
777 777
     };
778 778
 }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
      * @param mixed[] $array Array to do sum() on.
790 790
      * @return Number The total.
791 791
      */
792
-    return function (array $array) use ($function) {
792
+    return function(array $array) use ($function) {
793 793
         return array_sum(array_map($function, $array));
794 794
     };
795 795
 }
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
      * @param mixed[] $array
817 817
      * @return object
818 818
      */
819
-    return function (array $array) use ($object) {
819
+    return function(array $array) use ($object) {
820 820
         foreach ($array as $key => $value) {
821 821
             // If key is not a string or numerical, skip it.
822 822
             if (!is_string($key) || is_numeric($key)) {
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
      * @param mixed $data
853 853
      * @return string|null
854 854
      */
855
-    return function ($data) use ($flags, $depth): ?string {
855
+    return function($data) use ($flags, $depth): ?string {
856 856
         return \json_encode($data, $flags, max(1, $depth)) ?: null;
857 857
     };
858 858
 }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
      *  @param mixed[]$array The array to sort
879 879
      *  @return mixed[] The sorted array (new array)
880 880
      */
881
-    return function (array $array) use ($flag) {
881
+    return function(array $array) use ($flag) {
882 882
         \sort($array, $flag);
883 883
         return $array;
884 884
     };
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
      *  @param mixed[]$array The array to sort
898 898
      *  @return mixed[] The sorted array (new array)
899 899
      */
900
-    return function (array $array) use ($flag) {
900
+    return function(array $array) use ($flag) {
901 901
         \rsort($array, $flag);
902 902
         return $array;
903 903
     };
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
      *  @param mixed[]$array The array to sort
917 917
      *  @return mixed[] The sorted array (new array)
918 918
      */
919
-    return function (array $array) use ($flag) {
919
+    return function(array $array) use ($flag) {
920 920
         \ksort($array, $flag);
921 921
         return $array;
922 922
     };
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
      *  @param mixed[]$array The array to sort
935 935
      *  @return mixed[] The sorted array (new array)
936 936
      */
937
-    return function (array $array) use ($flag) {
937
+    return function(array $array) use ($flag) {
938 938
         \krsort($array, $flag);
939 939
         return $array;
940 940
     };
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
      *  @param mixed[]$array The array to sort
954 954
      *  @return mixed[] The sorted array (new array)
955 955
      */
956
-    return function (array $array) use ($flag) {
956
+    return function(array $array) use ($flag) {
957 957
         \asort($array, $flag);
958 958
         return $array;
959 959
     };
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
      *  @param mixed[]$array The array to sort
973 973
      *  @return mixed[] The sorted array (new array)
974 974
      */
975
-    return function (array $array) use ($flag) {
975
+    return function(array $array) use ($flag) {
976 976
         \arsort($array, $flag);
977 977
         return $array;
978 978
     };
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
      *  @param mixed[]$array The array to sort
990 990
      *  @return mixed[] The sorted array (new array)
991 991
      */
992
-    return function (array $array) {
992
+    return function(array $array) {
993 993
         \natsort($array);
994 994
         return $array;
995 995
     };
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
      *  @param mixed[]$array The array to sort
1007 1007
      *  @return mixed[] The sorted array (new array)
1008 1008
      */
1009
-    return function (array $array) {
1009
+    return function(array $array) {
1010 1010
         \natcasesort($array);
1011 1011
         return $array;
1012 1012
     };
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
      *  @param mixed[] $array The array to sort
1025 1025
      *  @return mixed[] The sorted array (new array)
1026 1026
      */
1027
-    return function (array $array) use ($function) {
1027
+    return function(array $array) use ($function) {
1028 1028
         \uksort($array, $function);
1029 1029
         return $array;
1030 1030
     };
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
      *  @param mixed[]$array The array to sort
1044 1044
      *  @return mixed[] The sorted array (new array)
1045 1045
      */
1046
-    return function (array $array) use ($function) {
1046
+    return function(array $array) use ($function) {
1047 1047
         \uasort($array, $function);
1048 1048
         return $array;
1049 1049
     };
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
      *  @param mixed[]$array The array to sort
1064 1064
      *  @return mixed[] The sorted array (new array)
1065 1065
      */
1066
-    return function (array $array) use ($function) {
1066
+    return function(array $array) use ($function) {
1067 1067
         \usort($array, $function);
1068 1068
         return $array;
1069 1069
     };
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
  */
1080 1080
 function scan(callable $function, $initialValue): Closure
1081 1081
 {
1082
-    return function (array $array) use ($function, $initialValue) {
1082
+    return function(array $array) use ($function, $initialValue) {
1083 1083
         $carry[] = $initialValue;
1084 1084
         foreach ($array as $key => $value) {
1085 1085
             $initialValue = $function($initialValue, $value);
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
  */
1099 1099
 function scanR(callable $function, $initialValue): Closure
1100 1100
 {
1101
-    return function (array $array) use ($function, $initialValue) {
1101
+    return function(array $array) use ($function, $initialValue) {
1102 1102
         $carry[] = $initialValue;
1103 1103
         foreach (array_reverse($array) as $key => $value) {
1104 1104
             $initialValue = $function($initialValue, $value);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
      * @param mixed[] $array
1122 1122
      * @return mixed
1123 1123
      */
1124
-    return function (array $array) use ($callable, $initial) {
1124
+    return function(array $array) use ($callable, $initial) {
1125 1125
         return array_reduce($array, $callable, $initial);
1126 1126
     };
1127 1127
 }
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
      * @param mixed[] $array
1140 1140
      * @return mixed
1141 1141
      */
1142
-    return function (array $array) use ($callable, $initial) {
1142
+    return function(array $array) use ($callable, $initial) {
1143 1143
         return array_reduce(\array_reverse($array), $callable, $initial);
1144 1144
     };
1145 1145
 }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
      * @param mixed[] $array
1159 1159
      * @return mixed
1160 1160
      */
1161
-    return function (array $array) use ($callable, $initial) {
1161
+    return function(array $array) use ($callable, $initial) {
1162 1162
         foreach ($array as $key => $value) {
1163 1163
             $initial = $callable($initial, $key, $value);
1164 1164
         }
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      * @param mixed[] $array
1185 1185
      * @return mixed[]
1186 1186
      */
1187
-    return function (array $array) use ($count) {
1187
+    return function(array $array) use ($count) {
1188 1188
         return \array_slice($array, 0, $count);
1189 1189
     };
1190 1190
 }
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 
1206 1206
     // If count is 0, return an empty array
1207 1207
     if ($count === 0) {
1208
-        return function (array $array) {
1208
+        return function(array $array) {
1209 1209
             return array();
1210 1210
         };
1211 1211
     }
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
      * @param mixed[] $array
1215 1215
      * @return mixed[]
1216 1216
      */
1217
-    return function (array $array) use ($count) {
1217
+    return function(array $array) use ($count) {
1218 1218
         return \array_slice($array, -$count);
1219 1219
     };
1220 1220
 }
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
      * @param mixed[] $array
1233 1233
      * @return mixed[]
1234 1234
      */
1235
-    return function (array $array) use ($conditional) {
1235
+    return function(array $array) use ($conditional) {
1236 1236
         $carry = array();
1237 1237
         foreach ($array as $key => $value) {
1238 1238
             if (true === $conditional($value)) {
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
      * @param mixed[] $array
1258 1258
      * @return mixed[]
1259 1259
      */
1260
-    return function (array $array) use ($conditional) {
1260
+    return function(array $array) use ($conditional) {
1261 1261
         $carry = array();
1262 1262
         foreach ($array as $key => $value) {
1263 1263
             if (false === $conditional($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.