@@ -52,7 +52,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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() |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param int|null $value |
| 47 | 47 | * @return Closure(int|null):(Closure|int)|int |
| 48 | 48 | */ |
| 49 | - return function (?int $value = null) use ($initial) { |
|
| 49 | + return function(?int $value = null) use ($initial) { |
|
| 50 | 50 | if (null !== $value) { |
| 51 | 51 | $initial += $value; |
| 52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param float|null $value |
| 67 | 67 | * @return Closure(float|null):(Closure|float)|float |
| 68 | 68 | */ |
| 69 | - return function (?float $value = null) use ($initial) { |
|
| 69 | + return function(?float $value = null) use ($initial) { |
|
| 70 | 70 | if (null !== $value) { |
| 71 | 71 | $initial += $value; |
| 72 | 72 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function sum($initial = 0): Closure |
| 85 | 85 | { |
| 86 | - if (! C\isNumber($initial)) { |
|
| 86 | + if (!C\isNumber($initial)) { |
|
| 87 | 87 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param Number $value |
| 92 | 92 | * @return int|float |
| 93 | 93 | */ |
| 94 | - return function ($value) use ($initial) { |
|
| 94 | + return function($value) use ($initial) { |
|
| 95 | 95 | return $initial + $value; |
| 96 | 96 | }; |
| 97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | function subtract($initial = 0): Closure |
| 108 | 108 | { |
| 109 | - if (! C\isNumber($initial)) { |
|
| 109 | + if (!C\isNumber($initial)) { |
|
| 110 | 110 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param Number $value |
| 115 | 115 | * @return int|float |
| 116 | 116 | */ |
| 117 | - return function ($value) use ($initial) { |
|
| 117 | + return function($value) use ($initial) { |
|
| 118 | 118 | return $value - $initial; |
| 119 | 119 | }; |
| 120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | function multiply($initial = 1): Closure |
| 131 | 131 | { |
| 132 | - if (! C\isNumber($initial)) { |
|
| 132 | + if (!C\isNumber($initial)) { |
|
| 133 | 133 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Number (Float or Int)'); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param Number $value |
| 138 | 138 | * @return Number |
| 139 | 139 | */ |
| 140 | - return function ($value) use ($initial) { |
|
| 140 | + return function($value) use ($initial) { |
|
| 141 | 141 | return $value * $initial; |
| 142 | 142 | }; |
| 143 | 143 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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)); |
@@ -25,7 +25,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | * |
@@ -32,13 +32,13 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param mixed $b The values to compare with |
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | - return function ($b) use ($a): bool { |
|
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 139 | 139 | * @param Number $b The base value to compare with must be int or float. |
| 140 | 140 | * @return bool |
| 141 | 141 | */ |
| 142 | - return function ($b) use ($a): bool { |
|
| 142 | + return function($b) use ($a): bool { |
|
| 143 | 143 | return any(isEqualTo($a), isLessThan($a))($b); |
| 144 | 144 | }; |
| 145 | 145 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param Number $b |
| 158 | 158 | * @return bool |
| 159 | 159 | */ |
| 160 | - return function ($b) use ($a): bool { |
|
| 160 | + return function($b) use ($a): bool { |
|
| 161 | 161 | return any(isEqualTo($a), isGreaterThan($a))($b); |
| 162 | 162 | }; |
| 163 | 163 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param mixed[] $b The array of values which it could be |
| 175 | 175 | * @return bool |
| 176 | 176 | */ |
| 177 | - return function ($b) use ($a): ?bool { |
|
| 177 | + return function($b) use ($a): ?bool { |
|
| 178 | 178 | if ( |
| 179 | 179 | is_numeric($b) || is_bool($b) || |
| 180 | 180 | is_string($b) || is_array($b) |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return in_array( |
| 185 | 185 | (array) $b, |
| 186 | 186 | array_map( |
| 187 | - function ($e): array { |
|
| 187 | + function($e): array { |
|
| 188 | 188 | return (array) $e; |
| 189 | 189 | }, |
| 190 | 190 | $a |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | * @param mixed $value |
| 222 | 222 | * @return bool |
| 223 | 223 | */ |
| 224 | - return function ($value) use ($callables): bool { |
|
| 224 | + return function($value) use ($callables): bool { |
|
| 225 | 225 | return (bool) array_reduce( |
| 226 | 226 | $callables, |
| 227 | - function ($result, $callable) use ($value) { |
|
| 227 | + function($result, $callable) use ($value) { |
|
| 228 | 228 | return (is_bool($result) && $result === false) ? false : $callable($value); |
| 229 | 229 | }, |
| 230 | 230 | null |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | * @param mixed $value |
| 245 | 245 | * @return bool |
| 246 | 246 | */ |
| 247 | - return function ($value) use ($callables): bool { |
|
| 247 | + return function($value) use ($callables): bool { |
|
| 248 | 248 | return (bool) array_reduce( |
| 249 | 249 | $callables, |
| 250 | - function ($result, $callable) use ($value) { |
|
| 250 | + function($result, $callable) use ($value) { |
|
| 251 | 251 | return (is_bool($result) && $result === true) ? true : $callable($value); |
| 252 | 252 | }, |
| 253 | 253 | null |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @param mixed $value |
| 268 | 268 | * @return bool |
| 269 | 269 | */ |
| 270 | - return function ($value) use ($source) { |
|
| 270 | + return function($value) use ($source) { |
|
| 271 | 271 | return gettype($value) === $source; |
| 272 | 272 | }; |
| 273 | 273 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 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 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $string |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - return function (string $string) use ($opening, $closing): string { |
|
| 51 | + return function(string $string) use ($opening, $closing) : string { |
|
| 52 | 52 | return \sprintf('%s%s%s', $opening, $string, $closing ?? $opening); |
| 53 | 53 | }; |
| 54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 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 |
||
| 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 | }; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param mixed $value Adds value start of array. |
| 85 | 85 | * @return array New array with value on head. |
| 86 | 86 | */ |
| 87 | - return function ($value) use ($array): array { |
|
| 87 | + return function($value) use ($array): array { |
|
| 88 | 88 | array_unshift($array, $value); |
| 89 | 89 | return $array; |
| 90 | 90 | }; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param mixed $value Adds value end of array. |
| 105 | 105 | * @return array<int|string, mixed> New array with value on tail. |
| 106 | 106 | */ |
| 107 | - return function ($value) use ($array): array { |
|
| 107 | + return function($value) use ($array): array { |
|
| 108 | 108 | $array[] = $value; |
| 109 | 109 | return $array; |
| 110 | 110 | }; |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param array<int|string, mixed> $array Array join |
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | - return function (array $array) use ($glue): string { |
|
| 167 | + return function(array $array) use ($glue) : string { |
|
| 168 | 168 | return $glue ? \join($glue, $array) : \join($array); |
| 169 | 169 | }; |
| 170 | 170 | } |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | function zip(array $additional, $default = null): Closure |
| 181 | 181 | { |
| 182 | 182 | $additional = array_values($additional); |
| 183 | - return function (array $array) use ($additional, $default) { |
|
| 183 | + return function(array $array) use ($additional, $default) { |
|
| 184 | 184 | $array = array_values($array); |
| 185 | 185 | return array_reduce( |
| 186 | 186 | array_keys($array), |
| 187 | - function ($carry, $key) use ($array, $additional, $default): array { |
|
| 187 | + function($carry, $key) use ($array, $additional, $default): array { |
|
| 188 | 188 | $carry[] = array( |
| 189 | 189 | $array[$key], |
| 190 | 190 | array_key_exists($key, $additional) ? $additional[$key] : $default, |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param mixed $value Adds value to inner array if value set, else returns. |
| 218 | 218 | * @return mixed[]|Closure |
| 219 | 219 | */ |
| 220 | - return function ($value = null) use ($inital) { |
|
| 220 | + return function($value = null) use ($inital) { |
|
| 221 | 221 | if ($value) { |
| 222 | 222 | $inital[] = $value; |
| 223 | 223 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * @param mixed $value |
| 243 | 243 | * @return mixed[]|Closure |
| 244 | 244 | */ |
| 245 | - return function ($value = null) use ($validator, $inital) { |
|
| 245 | + return function($value = null) use ($validator, $inital) { |
|
| 246 | 246 | if (!is_null($value) && $validator($value)) { |
| 247 | 247 | $inital[] = $value; |
| 248 | 248 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param array<int|string, mixed> $source Array to filter |
| 272 | 272 | * @return array<int|string, mixed> Filtered array. |
| 273 | 273 | */ |
| 274 | - return function (array $source) use ($callable): array { |
|
| 274 | + return function(array $source) use ($callable): array { |
|
| 275 | 275 | return array_filter($source, $callable); |
| 276 | 276 | }; |
| 277 | 277 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @param array<int|string, mixed> $source Array to filter |
| 289 | 289 | * @return array<int|string, mixed> Filtered array. |
| 290 | 290 | */ |
| 291 | - return function (array $source) use ($callable): array { |
|
| 291 | + return function(array $source) use ($callable): array { |
|
| 292 | 292 | return array_filter($source, $callable, \ARRAY_FILTER_USE_KEY); |
| 293 | 293 | }; |
| 294 | 294 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param array<int|string, mixed> $source Array to filter |
| 307 | 307 | * @return array<int|string, mixed> Filtered array. |
| 308 | 308 | */ |
| 309 | - return function (array $source) use ($callables): array { |
|
| 309 | + return function(array $source) use ($callables): array { |
|
| 310 | 310 | return array_filter($source, Comp\groupAnd(...$callables)); |
| 311 | 311 | }; |
| 312 | 312 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @param array<int|string, mixed> $source Array to filter |
| 325 | 325 | * @return array<int|string, mixed> Filtered array. |
| 326 | 326 | */ |
| 327 | - return function (array $source) use ($callables): array { |
|
| 327 | + return function(array $source) use ($callables): array { |
|
| 328 | 328 | return array_filter($source, Comp\groupOr(...$callables)); |
| 329 | 329 | }; |
| 330 | 330 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param array<int|string, mixed> $array The array to filter |
| 342 | 342 | * @return mixed|null The first element from the filtered array or null if filter returns empty |
| 343 | 343 | */ |
| 344 | - return function (array $array) use ($func) { |
|
| 344 | + return function(array $array) use ($func) { |
|
| 345 | 345 | foreach ($array as $value) { |
| 346 | 346 | $result = $func($value); |
| 347 | 347 | if (\is_bool($result) && $result) { |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param array<int|string, mixed> $array The array to filter |
| 364 | 364 | * @return mixed|null The last element from the filtered array. |
| 365 | 365 | */ |
| 366 | - return function (array $array) use ($func) { |
|
| 366 | + return function(array $array) use ($func) { |
|
| 367 | 367 | while ($value = array_pop($array)) { |
| 368 | 368 | $result = $func($value); |
| 369 | 369 | if (\is_bool($result) && $result) { |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @param array<int|string, mixed> $array The array to filter then map. |
| 389 | 389 | * @return array<int|string, mixed> |
| 390 | 390 | */ |
| 391 | - return function (array $array) use ($filter, $map): array { |
|
| 391 | + return function(array $array) use ($filter, $map): array { |
|
| 392 | 392 | return array_map($map, array_filter($array, $filter)); |
| 393 | 393 | }; |
| 394 | 394 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * @param array<int|string, mixed> $array |
| 406 | 406 | * @return int Count |
| 407 | 407 | */ |
| 408 | - return function (array $array) use ($function) { |
|
| 408 | + return function(array $array) use ($function) { |
|
| 409 | 409 | return count(array_filter($array, $function)); |
| 410 | 410 | }; |
| 411 | 411 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param mixed[] $array |
| 425 | 425 | * @return array{0:mixed[], 1:mixed[]} |
| 426 | 426 | */ |
| 427 | - return function (array $array) use ($function): array { |
|
| 427 | + return function(array $array) use ($function): array { |
|
| 428 | 428 | return array_reduce( |
| 429 | 429 | $array, |
| 430 | 430 | /** |
@@ -432,8 +432,8 @@ discard block |
||
| 432 | 432 | * @param mixed $element |
| 433 | 433 | * @return array{0:mixed[], 1:mixed[]} |
| 434 | 434 | */ |
| 435 | - function ($carry, $element) use ($function): array { |
|
| 436 | - $key = (bool) $function($element) ? 1 : 0; |
|
| 435 | + function($carry, $element) use ($function): array { |
|
| 436 | + $key = (bool) $function($element) ? 1 : 0; |
|
| 437 | 437 | $carry[$key][] = $element; |
| 438 | 438 | return $carry; |
| 439 | 439 | }, |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * @param mixed[] $array |
| 455 | 455 | * @return bool |
| 456 | 456 | */ |
| 457 | - return function (array $array) use ($function): bool { |
|
| 457 | + return function(array $array) use ($function): bool { |
|
| 458 | 458 | foreach ($array as $value) { |
| 459 | 459 | if (false === $function($value)) { |
| 460 | 460 | return false; |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @param mixed[] $array |
| 478 | 478 | * @return bool |
| 479 | 479 | */ |
| 480 | - return function (array $array) use ($function): bool { |
|
| 480 | + return function(array $array) use ($function): bool { |
|
| 481 | 481 | foreach ($array as $value) { |
| 482 | 482 | if (true === $function($value)) { |
| 483 | 483 | return true; |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @param mixed[] $array The array to map |
| 509 | 509 | * @return mixed[] |
| 510 | 510 | */ |
| 511 | - return function (array $array) use ($func): array { |
|
| 511 | + return function(array $array) use ($func): array { |
|
| 512 | 512 | return array_map($func, $array); |
| 513 | 513 | }; |
| 514 | 514 | } |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * @param mixed[] $array The array to map |
| 527 | 527 | * @return mixed[] |
| 528 | 528 | */ |
| 529 | - return function (array $array) use ($func): array { |
|
| 529 | + return function(array $array) use ($func): array { |
|
| 530 | 530 | return array_reduce( |
| 531 | 531 | array_keys($array), |
| 532 | - function ($carry, $key) use ($func, $array) { |
|
| 532 | + function($carry, $key) use ($func, $array) { |
|
| 533 | 533 | $carry[$func($key)] = $array[$key]; |
| 534 | 534 | return $carry; |
| 535 | 535 | }, |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | * @param mixed[] $array The array to map |
| 552 | 552 | * @return mixed[] |
| 553 | 553 | */ |
| 554 | - return function (array $array) use ($func, $data): array { |
|
| 554 | + return function(array $array) use ($func, $data): array { |
|
| 555 | 555 | return array_map( |
| 556 | - function ($e) use ($data, $func) { |
|
| 556 | + function($e) use ($data, $func) { |
|
| 557 | 557 | return $func($e, ...$data); |
| 558 | 558 | }, |
| 559 | 559 | $array |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | * @param mixed[] $array The array to map |
| 574 | 574 | * @return mixed[] |
| 575 | 575 | */ |
| 576 | - return function (array $array) use ($func): array { |
|
| 576 | + return function(array $array) use ($func): array { |
|
| 577 | 577 | return array_map( |
| 578 | - function ($key, $value) use ($func) { |
|
| 578 | + function($key, $value) use ($func) { |
|
| 579 | 579 | return $func($value, $key); |
| 580 | 580 | }, |
| 581 | 581 | $array, |
@@ -596,9 +596,9 @@ discard block |
||
| 596 | 596 | * @param mixed[] $array The array to map |
| 597 | 597 | * @return void |
| 598 | 598 | */ |
| 599 | - return function (array $array) use ($func): void { |
|
| 599 | + return function(array $array) use ($func): void { |
|
| 600 | 600 | array_map( |
| 601 | - function ($key, $value) use ($func) { |
|
| 601 | + function($key, $value) use ($func) { |
|
| 602 | 602 | $func($key, $value); |
| 603 | 603 | }, |
| 604 | 604 | array_keys($array), |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | * @param mixed[] $array |
| 621 | 621 | * @return mixed[] |
| 622 | 622 | */ |
| 623 | - return function (array $array) use ($n, $function): array { |
|
| 623 | + return function(array $array) use ($n, $function) : array { |
|
| 624 | 624 | return array_reduce( |
| 625 | 625 | $array, |
| 626 | 626 | /** |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * @param mixed $element |
| 629 | 629 | * @return mixed[] |
| 630 | 630 | */ |
| 631 | - function (array $carry, $element) use ($n, $function): array { |
|
| 631 | + function(array $carry, $element) use ($n, $function) : array { |
|
| 632 | 632 | if (is_array($element) && (is_null($n) || $n > 0)) { |
| 633 | 633 | $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element)); |
| 634 | 634 | } else { |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | * @param mixed[] $array The array to be grouped |
| 661 | 661 | * @return mixed[] Grouped array. |
| 662 | 662 | */ |
| 663 | - return function (array $array) use ($function): array { |
|
| 663 | + return function(array $array) use ($function): array { |
|
| 664 | 664 | return array_reduce( |
| 665 | 665 | $array, |
| 666 | 666 | /** |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | * @param mixed $element |
| 669 | 669 | * @return mixed[] |
| 670 | 670 | */ |
| 671 | - function ($carry, $item) use ($function): array { |
|
| 671 | + function($carry, $item) use ($function): array { |
|
| 672 | 672 | $carry[call_user_func($function, $item)][] = $item; |
| 673 | 673 | return $carry; |
| 674 | 674 | }, |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * @param mixed[] $array Array to chunk |
| 691 | 691 | * @return mixed[] |
| 692 | 692 | */ |
| 693 | - return function (array $array) use ($count, $preserveKeys): array { |
|
| 693 | + return function(array $array) use ($count, $preserveKeys): array { |
|
| 694 | 694 | return array_chunk($array, max(1, $count), $preserveKeys); |
| 695 | 695 | }; |
| 696 | 696 | } |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * @param mixed[] $array |
| 709 | 709 | * @return mixed[] |
| 710 | 710 | */ |
| 711 | - return function (array $array) use ($column, $key): array { |
|
| 711 | + return function(array $array) use ($column, $key) : array { |
|
| 712 | 712 | return array_column($array, $column, $key); |
| 713 | 713 | }; |
| 714 | 714 | } |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * @param mixed[] $array Array to flatten |
| 726 | 726 | * @return mixed[] |
| 727 | 727 | */ |
| 728 | - return function (array $array) use ($n): array { |
|
| 728 | + return function(array $array) use ($n) : array { |
|
| 729 | 729 | return array_reduce( |
| 730 | 730 | $array, |
| 731 | 731 | /** |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | * @param mixed|mixed[] $element |
| 734 | 734 | * @return array<int|string, mixed> |
| 735 | 735 | */ |
| 736 | - function (array $carry, $element) use ($n): array { |
|
| 736 | + function(array $carry, $element) use ($n) : array { |
|
| 737 | 737 | // Remove empty arrays. |
| 738 | 738 | if (is_array($element) && empty($element)) { |
| 739 | 739 | return $carry; |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | * @param mixed[] $array The array to have elements replaced from. |
| 765 | 765 | * @return mixed[] Array with replacements. |
| 766 | 766 | */ |
| 767 | - return function (array $array) use ($with): array { |
|
| 767 | + return function(array $array) use ($with): array { |
|
| 768 | 768 | return array_replace_recursive($array, ...$with); |
| 769 | 769 | }; |
| 770 | 770 | } |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | * @param mixed[] $array The array to have elements replaced from. |
| 782 | 782 | * @return mixed[] Array with replacements. |
| 783 | 783 | */ |
| 784 | - return function (array $array) use ($with): array { |
|
| 784 | + return function(array $array) use ($with): array { |
|
| 785 | 785 | return array_replace($array, ...$with); |
| 786 | 786 | }; |
| 787 | 787 | } |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | * @param mixed[] $array Array to do sum() on. |
| 799 | 799 | * @return Number The total. |
| 800 | 800 | */ |
| 801 | - return function (array $array) use ($function) { |
|
| 801 | + return function(array $array) use ($function) { |
|
| 802 | 802 | return array_sum(array_map($function, $array)); |
| 803 | 803 | }; |
| 804 | 804 | } |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | * @param mixed[] $array |
| 826 | 826 | * @return object |
| 827 | 827 | */ |
| 828 | - return function (array $array) use ($object) { |
|
| 828 | + return function(array $array) use ($object) { |
|
| 829 | 829 | foreach ($array as $key => $value) { |
| 830 | 830 | // If key is not a string or numerical, skip it. |
| 831 | 831 | if (!is_string($key) || is_numeric($key)) { |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | * @param mixed $data |
| 862 | 862 | * @return string|null |
| 863 | 863 | */ |
| 864 | - return function ($data) use ($flags, $depth): ?string { |
|
| 864 | + return function($data) use ($flags, $depth): ?string { |
|
| 865 | 865 | return \json_encode($data, $flags, max(1, $depth)) ?: null; |
| 866 | 866 | }; |
| 867 | 867 | } |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @param mixed[]$array The array to sort |
| 888 | 888 | * @return mixed[] The sorted array (new array) |
| 889 | 889 | */ |
| 890 | - return function (array $array) use ($flag) { |
|
| 890 | + return function(array $array) use ($flag) { |
|
| 891 | 891 | \sort($array, $flag); |
| 892 | 892 | return $array; |
| 893 | 893 | }; |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | * @param mixed[]$array The array to sort |
| 907 | 907 | * @return mixed[] The sorted array (new array) |
| 908 | 908 | */ |
| 909 | - return function (array $array) use ($flag) { |
|
| 909 | + return function(array $array) use ($flag) { |
|
| 910 | 910 | \rsort($array, $flag); |
| 911 | 911 | return $array; |
| 912 | 912 | }; |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | * @param mixed[]$array The array to sort |
| 926 | 926 | * @return mixed[] The sorted array (new array) |
| 927 | 927 | */ |
| 928 | - return function (array $array) use ($flag) { |
|
| 928 | + return function(array $array) use ($flag) { |
|
| 929 | 929 | \ksort($array, $flag); |
| 930 | 930 | return $array; |
| 931 | 931 | }; |
@@ -943,7 +943,7 @@ discard block |
||
| 943 | 943 | * @param mixed[]$array The array to sort |
| 944 | 944 | * @return mixed[] The sorted array (new array) |
| 945 | 945 | */ |
| 946 | - return function (array $array) use ($flag) { |
|
| 946 | + return function(array $array) use ($flag) { |
|
| 947 | 947 | \krsort($array, $flag); |
| 948 | 948 | return $array; |
| 949 | 949 | }; |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | * @param mixed[]$array The array to sort |
| 963 | 963 | * @return mixed[] The sorted array (new array) |
| 964 | 964 | */ |
| 965 | - return function (array $array) use ($flag) { |
|
| 965 | + return function(array $array) use ($flag) { |
|
| 966 | 966 | \asort($array, $flag); |
| 967 | 967 | return $array; |
| 968 | 968 | }; |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | * @param mixed[]$array The array to sort |
| 982 | 982 | * @return mixed[] The sorted array (new array) |
| 983 | 983 | */ |
| 984 | - return function (array $array) use ($flag) { |
|
| 984 | + return function(array $array) use ($flag) { |
|
| 985 | 985 | \arsort($array, $flag); |
| 986 | 986 | return $array; |
| 987 | 987 | }; |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | * @param mixed[]$array The array to sort |
| 999 | 999 | * @return mixed[] The sorted array (new array) |
| 1000 | 1000 | */ |
| 1001 | - return function (array $array) { |
|
| 1001 | + return function(array $array) { |
|
| 1002 | 1002 | \natsort($array); |
| 1003 | 1003 | return $array; |
| 1004 | 1004 | }; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | * @param mixed[]$array The array to sort |
| 1016 | 1016 | * @return mixed[] The sorted array (new array) |
| 1017 | 1017 | */ |
| 1018 | - return function (array $array) { |
|
| 1018 | + return function(array $array) { |
|
| 1019 | 1019 | \natcasesort($array); |
| 1020 | 1020 | return $array; |
| 1021 | 1021 | }; |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | * @param mixed[] $array The array to sort |
| 1034 | 1034 | * @return mixed[] The sorted array (new array) |
| 1035 | 1035 | */ |
| 1036 | - return function (array $array) use ($function) { |
|
| 1036 | + return function(array $array) use ($function) { |
|
| 1037 | 1037 | \uksort($array, $function); |
| 1038 | 1038 | return $array; |
| 1039 | 1039 | }; |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | * @param mixed[]$array The array to sort |
| 1053 | 1053 | * @return mixed[] The sorted array (new array) |
| 1054 | 1054 | */ |
| 1055 | - return function (array $array) use ($function) { |
|
| 1055 | + return function(array $array) use ($function) { |
|
| 1056 | 1056 | \uasort($array, $function); |
| 1057 | 1057 | return $array; |
| 1058 | 1058 | }; |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | * @param mixed[]$array The array to sort |
| 1073 | 1073 | * @return mixed[] The sorted array (new array) |
| 1074 | 1074 | */ |
| 1075 | - return function (array $array) use ($function) { |
|
| 1075 | + return function(array $array) use ($function) { |
|
| 1076 | 1076 | \usort($array, $function); |
| 1077 | 1077 | return $array; |
| 1078 | 1078 | }; |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | */ |
| 1089 | 1089 | function scan(callable $function, $initialValue): Closure |
| 1090 | 1090 | { |
| 1091 | - return function (array $array) use ($function, $initialValue) { |
|
| 1091 | + return function(array $array) use ($function, $initialValue) { |
|
| 1092 | 1092 | $carry[] = $initialValue; |
| 1093 | 1093 | foreach ($array as $key => $value) { |
| 1094 | 1094 | $initialValue = $function($initialValue, $value); |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | */ |
| 1108 | 1108 | function scanR(callable $function, $initialValue): Closure |
| 1109 | 1109 | { |
| 1110 | - return function (array $array) use ($function, $initialValue) { |
|
| 1110 | + return function(array $array) use ($function, $initialValue) { |
|
| 1111 | 1111 | $carry[] = $initialValue; |
| 1112 | 1112 | foreach (array_reverse($array) as $key => $value) { |
| 1113 | 1113 | $initialValue = $function($initialValue, $value); |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | * @param mixed[] $array |
| 1131 | 1131 | * @return mixed |
| 1132 | 1132 | */ |
| 1133 | - return function (array $array) use ($callable, $initial) { |
|
| 1133 | + return function(array $array) use ($callable, $initial) { |
|
| 1134 | 1134 | return array_reduce($array, $callable, $initial); |
| 1135 | 1135 | }; |
| 1136 | 1136 | } |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | * @param mixed[] $array |
| 1149 | 1149 | * @return mixed |
| 1150 | 1150 | */ |
| 1151 | - return function (array $array) use ($callable, $initial) { |
|
| 1151 | + return function(array $array) use ($callable, $initial) { |
|
| 1152 | 1152 | return array_reduce(\array_reverse($array), $callable, $initial); |
| 1153 | 1153 | }; |
| 1154 | 1154 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | * @param mixed[] $array |
| 1168 | 1168 | * @return mixed |
| 1169 | 1169 | */ |
| 1170 | - return function (array $array) use ($callable, $initial) { |
|
| 1170 | + return function(array $array) use ($callable, $initial) { |
|
| 1171 | 1171 | foreach ($array as $key => $value) { |
| 1172 | 1172 | $initial = $callable($initial, $key, $value); |
| 1173 | 1173 | } |
@@ -1193,7 +1193,7 @@ discard block |
||
| 1193 | 1193 | * @param mixed[] $array |
| 1194 | 1194 | * @return mixed[] |
| 1195 | 1195 | */ |
| 1196 | - return function (array $array) use ($count) { |
|
| 1196 | + return function(array $array) use ($count) { |
|
| 1197 | 1197 | return \array_slice($array, 0, $count); |
| 1198 | 1198 | }; |
| 1199 | 1199 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | |
| 1215 | 1215 | // If count is 0, return an empty array |
| 1216 | 1216 | if ($count === 0) { |
| 1217 | - return function (array $array) { |
|
| 1217 | + return function(array $array) { |
|
| 1218 | 1218 | return array(); |
| 1219 | 1219 | }; |
| 1220 | 1220 | } |
@@ -1223,7 +1223,7 @@ discard block |
||
| 1223 | 1223 | * @param mixed[] $array |
| 1224 | 1224 | * @return mixed[] |
| 1225 | 1225 | */ |
| 1226 | - return function (array $array) use ($count) { |
|
| 1226 | + return function(array $array) use ($count) { |
|
| 1227 | 1227 | return \array_slice($array, -$count); |
| 1228 | 1228 | }; |
| 1229 | 1229 | } |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | * @param mixed[] $array |
| 1242 | 1242 | * @return mixed[] |
| 1243 | 1243 | */ |
| 1244 | - return function (array $array) use ($conditional) { |
|
| 1244 | + return function(array $array) use ($conditional) { |
|
| 1245 | 1245 | $carry = array(); |
| 1246 | 1246 | foreach ($array as $key => $value) { |
| 1247 | 1247 | if (true === $conditional($value)) { |
@@ -1266,7 +1266,7 @@ discard block |
||
| 1266 | 1266 | * @param mixed[] $array |
| 1267 | 1267 | * @return mixed[] |
| 1268 | 1268 | */ |
| 1269 | - return function (array $array) use ($conditional) { |
|
| 1269 | + return function(array $array) use ($conditional) { |
|
| 1270 | 1270 | $carry = array(); |
| 1271 | 1271 | foreach ($array as $key => $value) { |
| 1272 | 1272 | if (false === $conditional($value)) { |
@@ -1290,7 +1290,7 @@ discard block |
||
| 1290 | 1290 | * @param mixed[] $array |
| 1291 | 1291 | * @return mixed[] |
| 1292 | 1292 | */ |
| 1293 | - return function (array $array) use ($indexes) { |
|
| 1293 | + return function(array $array) use ($indexes) { |
|
| 1294 | 1294 | return array_intersect_key($array, array_flip($indexes)); |
| 1295 | 1295 | }; |
| 1296 | 1296 | } |