@@ -45,8 +45,8 @@ 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 { |
|
| 49 | - if (! sameScalar($b, $a)) { |
|
| 48 | + return function($b) use ($a): bool { |
|
| 49 | + if (!sameScalar($b, $a)) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | * @param mixed $b The values to compare with |
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | - return function ($b) use ($a): bool { |
|
| 87 | - return ! isEqualTo($a)($b); |
|
| 86 | + return function($b) use ($a): bool { |
|
| 87 | + return !isEqualTo($a)($b); |
|
| 88 | 88 | }; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @param Number $b |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - return function ($b) use ($a): bool { |
|
| 105 | - return isEqualIn(array( 'integer', 'double' ))(gettype($b)) |
|
| 104 | + return function($b) use ($a): bool { |
|
| 105 | + return isEqualIn(array('integer', 'double'))(gettype($b)) |
|
| 106 | 106 | ? $a < $b : false; |
| 107 | 107 | }; |
| 108 | 108 | } |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * @param mixed $b |
| 121 | 121 | * @return bool |
| 122 | 122 | */ |
| 123 | - return function ($b) use ($a): bool { |
|
| 124 | - return isEqualIn(array( 'integer', 'double' ))(gettype($b)) |
|
| 123 | + return function($b) use ($a): bool { |
|
| 124 | + return isEqualIn(array('integer', 'double'))(gettype($b)) |
|
| 125 | 125 | ? $a > $b : false; |
| 126 | 126 | }; |
| 127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 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 |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | function notEmpty($value): bool |
| 208 | 208 | { |
| 209 | - return ! empty($value); |
|
| 209 | + return !empty($value); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -221,10 +221,10 @@ discard block |
||
| 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 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | function allTrue(bool ...$variables): bool |
| 299 | 299 | { |
| 300 | 300 | foreach ($variables as $value) { |
| 301 | - if (! is_bool($value) || $value !== true) { |
|
| 301 | + if (!is_bool($value) || $value !== true) { |
|
| 302 | 302 | return false; |
| 303 | 303 | } |
| 304 | 304 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @param mixed $value |
| 389 | 389 | * @return bool |
| 390 | 390 | */ |
| 391 | - return function ($value) use ($callable): bool { |
|
| 392 | - return ! (bool) $callable($value); |
|
| 391 | + return function($value) use ($callable): bool { |
|
| 392 | + return !(bool) $callable($value); |
|
| 393 | 393 | }; |
| 394 | 394 | } |
@@ -264,7 +264,7 @@ |
||
| 264 | 264 | * Only works for public or dynamic properties. |
| 265 | 265 | * |
| 266 | 266 | * @param array<string,mixed>|ArrayObject<string,mixed>|object $store |
| 267 | - * @param string $property The property key. |
|
| 267 | + * @param string $property The property key. |
|
| 268 | 268 | * @return Closure(mixed):(array<string,mixed>|ArrayObject<string,mixed>|object) |
| 269 | 269 | */ |
| 270 | 270 | function setProperty($store, string $property): Closure |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param mixed The value passed into the functions |
| 50 | 50 | * @return mixed The final result. |
| 51 | 51 | */ |
| 52 | - return function ($e) use ($callables) { |
|
| 52 | + return function($e) use ($callables) { |
|
| 53 | 53 | foreach ($callables as $callable) { |
| 54 | 54 | $e = $callable($e); |
| 55 | 55 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param mixed The value passed into the functions |
| 71 | 71 | * @return mixed The final result. |
| 72 | 72 | */ |
| 73 | - return function ($e) use ($callables) { |
|
| 73 | + return function($e) use ($callables) { |
|
| 74 | 74 | foreach (\array_reverse($callables) as $callable) { |
| 75 | 75 | $e = $callable($e); |
| 76 | 76 | } |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | * @param mixed The value passed into the functions |
| 92 | 92 | * @return mixed|null The final result or null. |
| 93 | 93 | */ |
| 94 | - return function ($e) use ($callables) { |
|
| 94 | + return function($e) use ($callables) { |
|
| 95 | 95 | foreach ($callables as $callable) { |
| 96 | - if (! is_null($e)) { |
|
| 96 | + if (!is_null($e)) { |
|
| 97 | 97 | $e = $callable($e); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | * @param mixed $e The value being passed through the functions. |
| 117 | 117 | * @return mixed The final result. |
| 118 | 118 | */ |
| 119 | - return function ($e) use ($validator, $callables) { |
|
| 119 | + return function($e) use ($validator, $callables) { |
|
| 120 | 120 | foreach ($callables as $callable) { |
| 121 | 121 | // If invalid, abort and return null |
| 122 | - if (! $validator($e)) { |
|
| 122 | + if (!$validator($e)) { |
|
| 123 | 123 | return null; |
| 124 | 124 | } |
| 125 | 125 | // Run through callable. |
| 126 | 126 | $e = $callable($e); |
| 127 | 127 | |
| 128 | 128 | // Check results and bail if invalid type. |
| 129 | - if (! $validator($e)) { |
|
| 129 | + if (!$validator($e)) { |
|
| 130 | 130 | return null; |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @param mixed $data The array or object to attempt to get param. |
| 173 | 173 | * @return mixed|null |
| 174 | 174 | */ |
| 175 | - return function ($data) use ($property) { |
|
| 175 | + return function($data) use ($property) { |
|
| 176 | 176 | if (is_array($data)) { |
| 177 | - return array_key_exists($property, $data) ? $data[ $property ] : null; |
|
| 177 | + return array_key_exists($property, $data) ? $data[$property] : null; |
|
| 178 | 178 | } elseif (is_object($data)) { |
| 179 | 179 | return property_exists($data, $property) ? $data->{$property} : null; |
| 180 | 180 | } else { |
@@ -197,7 +197,7 @@ discard block |
||
| 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), |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | function setProperty($store, string $property): Closure |
| 272 | 272 | { |
| 273 | 273 | // If passed store is not an array or object, throw exception. |
| 274 | - if (! isArrayAccess($store) && ! is_object($store)) { |
|
| 274 | + if (!isArrayAccess($store) && !is_object($store)) { |
|
| 275 | 275 | throw new TypeError('Only objects or arrays can be constructed using setProperty.'); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * @param mixed $value The value to set to keu. |
| 280 | 280 | * @return array<string,mixed>|ArrayObject<string,mixed>|object The datastore. |
| 281 | 281 | */ |
| 282 | - return function ($value) use ($store, $property) { |
|
| 282 | + return function($value) use ($store, $property) { |
|
| 283 | 283 | if (isArrayAccess($store)) { |
| 284 | 284 | /** @phpstan-ignore-next-line */ |
| 285 | - $store[ $property ] = $value; |
|
| 285 | + $store[$property] = $value; |
|
| 286 | 286 | } else { |
| 287 | 287 | $store->{$property} = $value; |
| 288 | 288 | } |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | * @param mixed $data The data to pass through the callable |
| 306 | 306 | * @return array |
| 307 | 307 | */ |
| 308 | - return function ($data) use ($key, $value): array { |
|
| 309 | - return array( $key => $value($data) ); |
|
| 308 | + return function($data) use ($key, $value): array { |
|
| 309 | + return array($key => $value($data)); |
|
| 310 | 310 | }; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -323,12 +323,12 @@ discard block |
||
| 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); |
@@ -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 | } |
@@ -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,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param string $string |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - return function (string $string) use ($start, $finish): string { |
|
| 72 | - return ! $finish |
|
| 71 | + return function(string $string) use ($start, $finish) : string { |
|
| 72 | + return !$finish |
|
| 73 | 73 | ? substr($string, $start) |
| 74 | 74 | : substr($string, $start, $finish); |
| 75 | 75 | }; |
@@ -87,7 +87,7 @@ discard block |
||
| 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 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | function countChars(int $mode = 1): Closure |
| 401 | 401 | { |
| 402 | 402 | // Throw an exception if the mode is not supported. |
| 403 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
| 403 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
| 404 | 404 | throw new \InvalidArgumentException('Invalid mode'); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -408,7 +408,7 @@ discard block |
||
| 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; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param string $string The string to pad out. |
| 551 | 551 | * @return string |
| 552 | 552 | */ |
| 553 | - return function (string $string) use ($length, $padContent, $type): string { |
|
| 553 | + return function(string $string) use ($length, $padContent, $type): string { |
|
| 554 | 554 | return \str_pad($string, $length, $padContent, $type); |
| 555 | 555 | }; |
| 556 | 556 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | * @param string $string The string to repeat |
| 568 | 568 | * @return string |
| 569 | 569 | */ |
| 570 | - return function (string $string) use ($count): string { |
|
| 570 | + return function(string $string) use ($count): string { |
|
| 571 | 571 | return \str_repeat($string, $count); |
| 572 | 572 | }; |
| 573 | 573 | } |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @param string $string The string to pad out. |
| 586 | 586 | * @return int|string[] |
| 587 | 587 | */ |
| 588 | - return function (string $string) use ($format, $charList) { |
|
| 588 | + return function(string $string) use ($format, $charList) { |
|
| 589 | 589 | return $charList |
| 590 | 590 | ? (\str_word_count($string, $format, $charList) ?: 0) |
| 591 | 591 | : (\str_word_count($string, $format) ?: 0); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param string $string The string to strip tags from. |
| 605 | 605 | * @return string |
| 606 | 606 | */ |
| 607 | - return function (string $string) use ($allowedTags): string { |
|
| 607 | + return function(string $string) use ($allowedTags) : string { |
|
| 608 | 608 | return $allowedTags |
| 609 | 609 | ? \strip_tags($string, $allowedTags) |
| 610 | 610 | : \strip_tags($string); |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 623 | 623 | { |
| 624 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 624 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 625 | 625 | |
| 626 | 626 | /** |
| 627 | 627 | * @param string $haystack The haystack to look through. |
| 628 | 628 | * @return int|null |
| 629 | 629 | */ |
| 630 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 630 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 631 | 631 | $pos = $caseSensitive |
| 632 | 632 | ? strpos($haystack, $needle, $offset) |
| 633 | 633 | : stripos($haystack, $needle, $offset); |
@@ -645,13 +645,13 @@ discard block |
||
| 645 | 645 | */ |
| 646 | 646 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 647 | 647 | { |
| 648 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 648 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 649 | 649 | |
| 650 | 650 | /** |
| 651 | 651 | * @param string $haystack The haystack to look through. |
| 652 | 652 | * @return int|null |
| 653 | 653 | */ |
| 654 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 654 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 655 | 655 | $pos = $caseSensitive |
| 656 | 656 | ? strrpos($haystack, $needle, $offset) |
| 657 | 657 | : strripos($haystack, $needle, $offset); |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | { |
| 673 | 673 | // Decode flags, only look for none defaults. |
| 674 | 674 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
| 675 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 675 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | 678 | * @param string $haystack The haystack to look through. |
| 679 | 679 | * @return string |
| 680 | 680 | */ |
| 681 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 681 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 682 | 682 | $result = $caseSensitive |
| 683 | 683 | ? strstr($haystack, $needle, $beforeNeedle) |
| 684 | 684 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | * @param string $haystack |
| 700 | 700 | * @return string |
| 701 | 701 | */ |
| 702 | - return function (string $haystack) use ($chars): string { |
|
| 702 | + return function(string $haystack) use ($chars): string { |
|
| 703 | 703 | $result = strpbrk($haystack, $chars); |
| 704 | 704 | return is_string($result) ? $result : ''; |
| 705 | 705 | }; |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param string $haystack |
| 719 | 719 | * @return string |
| 720 | 720 | */ |
| 721 | - return function (string $haystack) use ($char): string { |
|
| 721 | + return function(string $haystack) use ($char): string { |
|
| 722 | 722 | $result = strrchr($haystack, $char); |
| 723 | 723 | return is_string($result) ? $result : ''; |
| 724 | 724 | }; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * @param string $haystack |
| 738 | 738 | * @return string |
| 739 | 739 | */ |
| 740 | - return function (string $haystack) use ($dictionary): string { |
|
| 740 | + return function(string $haystack) use ($dictionary): string { |
|
| 741 | 741 | $result = strtr($haystack, $dictionary); |
| 742 | 742 | return $result; |
| 743 | 743 | }; |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | * @param string|null $value |
| 768 | 768 | * @return Closure|string |
| 769 | 769 | */ |
| 770 | - return function (?string $value = null) use ($initial) { |
|
| 770 | + return function(?string $value = null) use ($initial) { |
|
| 771 | 771 | if ($value) { |
| 772 | 772 | $initial .= $value; |
| 773 | 773 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param mixed $value Adds value start of array. |
| 47 | 47 | * @return array New array with value on head. |
| 48 | 48 | */ |
| 49 | - return function ($value) use ($array): array { |
|
| 49 | + return function($value) use ($array): array { |
|
| 50 | 50 | array_unshift($array, $value); |
| 51 | 51 | return $array; |
| 52 | 52 | }; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param mixed $value Adds value end of array. |
| 65 | 65 | * @return array<int|string, mixed> New array with value on tail. |
| 66 | 66 | */ |
| 67 | - return function ($value) use ($array): array { |
|
| 67 | + return function($value) use ($array): array { |
|
| 68 | 68 | $array[] = $value; |
| 69 | 69 | return $array; |
| 70 | 70 | }; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param array<int|string, mixed> $array Array join |
| 125 | 125 | * @return string. |
| 126 | 126 | */ |
| 127 | - return function (array $array) use ($glue): string { |
|
| 127 | + return function(array $array) use ($glue) : string { |
|
| 128 | 128 | return $glue ? \join($glue, $array) : \join($array); |
| 129 | 129 | }; |
| 130 | 130 | } |
@@ -140,11 +140,11 @@ discard block |
||
| 140 | 140 | function zip(array $additional, $default = null): Closure |
| 141 | 141 | { |
| 142 | 142 | $additional = array_values($additional); |
| 143 | - return function (array $array) use ($additional, $default) { |
|
| 143 | + return function(array $array) use ($additional, $default) { |
|
| 144 | 144 | $array = array_values($array); |
| 145 | 145 | return array_reduce( |
| 146 | 146 | array_keys($array), |
| 147 | - function ($carry, $key) use ($array, $additional, $default): array { |
|
| 147 | + function($carry, $key) use ($array, $additional, $default): array { |
|
| 148 | 148 | $carry[] = array( |
| 149 | 149 | $array[$key], |
| 150 | 150 | array_key_exists($key, $additional) ? $additional[$key] : $default, |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @param mixed $value Adds value to inner array if value set, else returns. |
| 178 | 178 | * @return mixed[]|Closure |
| 179 | 179 | */ |
| 180 | - return function ($value = null) use ($inital) { |
|
| 180 | + return function($value = null) use ($inital) { |
|
| 181 | 181 | if ($value) { |
| 182 | 182 | $inital[] = $value; |
| 183 | 183 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @param mixed $value |
| 203 | 203 | * @return mixed[]|Closure |
| 204 | 204 | */ |
| 205 | - return function ($value = null) use ($validator, $inital) { |
|
| 205 | + return function($value = null) use ($validator, $inital) { |
|
| 206 | 206 | if (!is_null($value) && $validator($value)) { |
| 207 | 207 | $inital[] = $value; |
| 208 | 208 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param array<int|string, mixed> $source Array to filter |
| 232 | 232 | * @return array<int|string, mixed> Filtered array. |
| 233 | 233 | */ |
| 234 | - return function (array $source) use ($callable): array { |
|
| 234 | + return function(array $source) use ($callable): array { |
|
| 235 | 235 | return array_filter($source, $callable); |
| 236 | 236 | }; |
| 237 | 237 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @param array<int|string, mixed> $source Array to filter |
| 249 | 249 | * @return array<int|string, mixed> Filtered array. |
| 250 | 250 | */ |
| 251 | - return function (array $source) use ($callable): array { |
|
| 251 | + return function(array $source) use ($callable): array { |
|
| 252 | 252 | return array_filter($source, $callable, \ARRAY_FILTER_USE_KEY); |
| 253 | 253 | }; |
| 254 | 254 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param array<int|string, mixed> $source Array to filter |
| 267 | 267 | * @return array<int|string, mixed> Filtered array. |
| 268 | 268 | */ |
| 269 | - return function (array $source) use ($callables): array { |
|
| 269 | + return function(array $source) use ($callables): array { |
|
| 270 | 270 | return array_filter($source, Comp\groupAnd(...$callables)); |
| 271 | 271 | }; |
| 272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param array<int|string, mixed> $source Array to filter |
| 285 | 285 | * @return array<int|string, mixed> Filtered array. |
| 286 | 286 | */ |
| 287 | - return function (array $source) use ($callables): array { |
|
| 287 | + return function(array $source) use ($callables): array { |
|
| 288 | 288 | return array_filter($source, Comp\groupOr(...$callables)); |
| 289 | 289 | }; |
| 290 | 290 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param array<int|string, mixed> $array The array to filter |
| 302 | 302 | * @return mixed|null The first element from the filtered array or null if filter returns empty |
| 303 | 303 | */ |
| 304 | - return function (array $array) use ($func) { |
|
| 304 | + return function(array $array) use ($func) { |
|
| 305 | 305 | return head(array_filter($array, $func)); |
| 306 | 306 | }; |
| 307 | 307 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @param array<int|string, mixed> $array The array to filter |
| 319 | 319 | * @return mixed|null The last element from the filtered array. |
| 320 | 320 | */ |
| 321 | - return function (array $array) use ($func) { |
|
| 321 | + return function(array $array) use ($func) { |
|
| 322 | 322 | return last(array_filter($array, $func)); |
| 323 | 323 | }; |
| 324 | 324 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | * @param array<int|string, mixed> $array The array to filter then map. |
| 339 | 339 | * @return array<int|string, mixed> |
| 340 | 340 | */ |
| 341 | - return function (array $array) use ($filter, $map): array { |
|
| 341 | + return function(array $array) use ($filter, $map): array { |
|
| 342 | 342 | return array_map($map, array_filter($array, $filter)); |
| 343 | 343 | }; |
| 344 | 344 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @param array<int|string, mixed> $array |
| 356 | 356 | * @return int Count |
| 357 | 357 | */ |
| 358 | - return function (array $array) use ($function) { |
|
| 358 | + return function(array $array) use ($function) { |
|
| 359 | 359 | return count(array_filter($array, $function)); |
| 360 | 360 | }; |
| 361 | 361 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @param mixed[] $array |
| 375 | 375 | * @return array{0:mixed[], 1:mixed[]} |
| 376 | 376 | */ |
| 377 | - return function (array $array) use ($function): array { |
|
| 377 | + return function(array $array) use ($function): array { |
|
| 378 | 378 | return array_reduce( |
| 379 | 379 | $array, |
| 380 | 380 | /** |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * @param mixed $element |
| 383 | 383 | * @return array{0:mixed[], 1:mixed[]} |
| 384 | 384 | */ |
| 385 | - function ($carry, $element) use ($function): array { |
|
| 386 | - $key = (bool) $function($element) ? 1 : 0; |
|
| 385 | + function($carry, $element) use ($function): array { |
|
| 386 | + $key = (bool) $function($element) ? 1 : 0; |
|
| 387 | 387 | $carry[$key][] = $element; |
| 388 | 388 | return $carry; |
| 389 | 389 | }, |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @param mixed[] $array |
| 405 | 405 | * @return bool |
| 406 | 406 | */ |
| 407 | - return function (array $array) use ($function): bool { |
|
| 407 | + return function(array $array) use ($function): bool { |
|
| 408 | 408 | foreach ($array as $value) { |
| 409 | 409 | if (false === $function($value)) { |
| 410 | 410 | return false; |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @param mixed[] $array |
| 428 | 428 | * @return bool |
| 429 | 429 | */ |
| 430 | - return function (array $array) use ($function): bool { |
|
| 430 | + return function(array $array) use ($function): bool { |
|
| 431 | 431 | foreach ($array as $value) { |
| 432 | 432 | if (true === $function($value)) { |
| 433 | 433 | return true; |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param mixed[] $array The array to map |
| 459 | 459 | * @return mixed[] |
| 460 | 460 | */ |
| 461 | - return function (array $array) use ($func): array { |
|
| 461 | + return function(array $array) use ($func): array { |
|
| 462 | 462 | return array_map($func, $array); |
| 463 | 463 | }; |
| 464 | 464 | } |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | * @param mixed[] $array The array to map |
| 477 | 477 | * @return mixed[] |
| 478 | 478 | */ |
| 479 | - return function (array $array) use ($func): array { |
|
| 479 | + return function(array $array) use ($func): array { |
|
| 480 | 480 | return array_reduce( |
| 481 | 481 | array_keys($array), |
| 482 | - function ($carry, $key) use ($func, $array) { |
|
| 482 | + function($carry, $key) use ($func, $array) { |
|
| 483 | 483 | $carry[$func($key)] = $array[$key]; |
| 484 | 484 | return $carry; |
| 485 | 485 | }, |
@@ -501,9 +501,9 @@ discard block |
||
| 501 | 501 | * @param mixed[] $array The array to map |
| 502 | 502 | * @return mixed[] |
| 503 | 503 | */ |
| 504 | - return function (array $array) use ($func, $data): array { |
|
| 504 | + return function(array $array) use ($func, $data): array { |
|
| 505 | 505 | return array_map( |
| 506 | - function ($e) use ($data, $func) { |
|
| 506 | + function($e) use ($data, $func) { |
|
| 507 | 507 | return $func($e, ...$data); |
| 508 | 508 | }, |
| 509 | 509 | $array |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | * @param mixed[] $array The array to map |
| 524 | 524 | * @return mixed[] |
| 525 | 525 | */ |
| 526 | - return function (array $array) use ($func): array { |
|
| 526 | + return function(array $array) use ($func): array { |
|
| 527 | 527 | return array_map( |
| 528 | - function ($key, $value) use ($func) { |
|
| 528 | + function($key, $value) use ($func) { |
|
| 529 | 529 | return $func($value, $key); |
| 530 | 530 | }, |
| 531 | 531 | $array, |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | * @param mixed[] $array The array to map |
| 547 | 547 | * @return void |
| 548 | 548 | */ |
| 549 | - return function (array $array) use ($func): void { |
|
| 549 | + return function(array $array) use ($func): void { |
|
| 550 | 550 | array_map( |
| 551 | - function ($key, $value) use ($func) { |
|
| 551 | + function($key, $value) use ($func) { |
|
| 552 | 552 | $func($key, $value); |
| 553 | 553 | }, |
| 554 | 554 | array_keys($array), |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * @param mixed[] $array |
| 571 | 571 | * @return mixed[] |
| 572 | 572 | */ |
| 573 | - return function (array $array) use ($n, $function): array { |
|
| 573 | + return function(array $array) use ($n, $function) : array { |
|
| 574 | 574 | return array_reduce( |
| 575 | 575 | $array, |
| 576 | 576 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @param mixed $element |
| 579 | 579 | * @return mixed[] |
| 580 | 580 | */ |
| 581 | - function (array $carry, $element) use ($n, $function): array { |
|
| 581 | + function(array $carry, $element) use ($n, $function) : array { |
|
| 582 | 582 | if (is_array($element) && (is_null($n) || $n > 0)) { |
| 583 | 583 | $carry = array_merge($carry, flatMap($function, $n ? $n - 1 : null)($element)); |
| 584 | 584 | } else { |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @param mixed[] $array The array to be grouped |
| 611 | 611 | * @return mixed[] Grouped array. |
| 612 | 612 | */ |
| 613 | - return function (array $array) use ($function): array { |
|
| 613 | + return function(array $array) use ($function): array { |
|
| 614 | 614 | return array_reduce( |
| 615 | 615 | $array, |
| 616 | 616 | /** |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | * @param mixed $element |
| 619 | 619 | * @return mixed[] |
| 620 | 620 | */ |
| 621 | - function ($carry, $item) use ($function): array { |
|
| 621 | + function($carry, $item) use ($function): array { |
|
| 622 | 622 | $carry[call_user_func($function, $item)][] = $item; |
| 623 | 623 | return $carry; |
| 624 | 624 | }, |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | * @param mixed[] $array Array to chunk |
| 641 | 641 | * @return mixed[] |
| 642 | 642 | */ |
| 643 | - return function (array $array) use ($count, $preserveKeys): array { |
|
| 643 | + return function(array $array) use ($count, $preserveKeys): array { |
|
| 644 | 644 | return array_chunk($array, max(1, $count), $preserveKeys); |
| 645 | 645 | }; |
| 646 | 646 | } |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | * @param mixed[] $array |
| 659 | 659 | * @return mixed[] |
| 660 | 660 | */ |
| 661 | - return function (array $array) use ($column, $key): array { |
|
| 661 | + return function(array $array) use ($column, $key) : array { |
|
| 662 | 662 | return array_column($array, $column, $key); |
| 663 | 663 | }; |
| 664 | 664 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * @param mixed[] $array Array to flatten |
| 676 | 676 | * @return mixed[] |
| 677 | 677 | */ |
| 678 | - return function (array $array) use ($n): array { |
|
| 678 | + return function(array $array) use ($n) : array { |
|
| 679 | 679 | return array_reduce( |
| 680 | 680 | $array, |
| 681 | 681 | /** |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | * @param mixed|mixed[] $element |
| 684 | 684 | * @return array<int|string, mixed> |
| 685 | 685 | */ |
| 686 | - function (array $carry, $element) use ($n): array { |
|
| 686 | + function(array $carry, $element) use ($n) : array { |
|
| 687 | 687 | // Remove empty arrays. |
| 688 | 688 | if (is_array($element) && empty($element)) { |
| 689 | 689 | return $carry; |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | * @param mixed[] $array The array to have elements replaced from. |
| 715 | 715 | * @return mixed[] Array with replacements. |
| 716 | 716 | */ |
| 717 | - return function (array $array) use ($with): array { |
|
| 717 | + return function(array $array) use ($with): array { |
|
| 718 | 718 | return array_replace_recursive($array, ...$with); |
| 719 | 719 | }; |
| 720 | 720 | } |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | * @param mixed[] $array The array to have elements replaced from. |
| 732 | 732 | * @return mixed[] Array with replacements. |
| 733 | 733 | */ |
| 734 | - return function (array $array) use ($with): array { |
|
| 734 | + return function(array $array) use ($with): array { |
|
| 735 | 735 | return array_replace($array, ...$with); |
| 736 | 736 | }; |
| 737 | 737 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | * @param mixed[] $array Array to do sum() on. |
| 749 | 749 | * @return Number The total. |
| 750 | 750 | */ |
| 751 | - return function (array $array) use ($function) { |
|
| 751 | + return function(array $array) use ($function) { |
|
| 752 | 752 | return array_sum(array_map($function, $array)); |
| 753 | 753 | }; |
| 754 | 754 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | * @param mixed[] $array |
| 776 | 776 | * @return object |
| 777 | 777 | */ |
| 778 | - return function (array $array) use ($object) { |
|
| 778 | + return function(array $array) use ($object) { |
|
| 779 | 779 | foreach ($array as $key => $value) { |
| 780 | 780 | // If key is not a string or numerical, skip it. |
| 781 | 781 | if (!is_string($key) || is_numeric($key)) { |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | * @param mixed $data |
| 812 | 812 | * @return string|null |
| 813 | 813 | */ |
| 814 | - return function ($data) use ($flags, $depth): ?string { |
|
| 814 | + return function($data) use ($flags, $depth): ?string { |
|
| 815 | 815 | return \json_encode($data, $flags, max(1, $depth)) ?: null; |
| 816 | 816 | }; |
| 817 | 817 | } |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | * @param mixed[]$array The array to sort |
| 838 | 838 | * @return mixed[] The sorted array (new array) |
| 839 | 839 | */ |
| 840 | - return function (array $array) use ($flag) { |
|
| 840 | + return function(array $array) use ($flag) { |
|
| 841 | 841 | \sort($array, $flag); |
| 842 | 842 | return $array; |
| 843 | 843 | }; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | * @param mixed[]$array The array to sort |
| 857 | 857 | * @return mixed[] The sorted array (new array) |
| 858 | 858 | */ |
| 859 | - return function (array $array) use ($flag) { |
|
| 859 | + return function(array $array) use ($flag) { |
|
| 860 | 860 | \rsort($array, $flag); |
| 861 | 861 | return $array; |
| 862 | 862 | }; |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | * @param mixed[]$array The array to sort |
| 876 | 876 | * @return mixed[] The sorted array (new array) |
| 877 | 877 | */ |
| 878 | - return function (array $array) use ($flag) { |
|
| 878 | + return function(array $array) use ($flag) { |
|
| 879 | 879 | \ksort($array, $flag); |
| 880 | 880 | return $array; |
| 881 | 881 | }; |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | * @param mixed[]$array The array to sort |
| 894 | 894 | * @return mixed[] The sorted array (new array) |
| 895 | 895 | */ |
| 896 | - return function (array $array) use ($flag) { |
|
| 896 | + return function(array $array) use ($flag) { |
|
| 897 | 897 | \krsort($array, $flag); |
| 898 | 898 | return $array; |
| 899 | 899 | }; |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * @param mixed[]$array The array to sort |
| 913 | 913 | * @return mixed[] The sorted array (new array) |
| 914 | 914 | */ |
| 915 | - return function (array $array) use ($flag) { |
|
| 915 | + return function(array $array) use ($flag) { |
|
| 916 | 916 | \asort($array, $flag); |
| 917 | 917 | return $array; |
| 918 | 918 | }; |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * @param mixed[]$array The array to sort |
| 932 | 932 | * @return mixed[] The sorted array (new array) |
| 933 | 933 | */ |
| 934 | - return function (array $array) use ($flag) { |
|
| 934 | + return function(array $array) use ($flag) { |
|
| 935 | 935 | \arsort($array, $flag); |
| 936 | 936 | return $array; |
| 937 | 937 | }; |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | * @param mixed[]$array The array to sort |
| 949 | 949 | * @return mixed[] The sorted array (new array) |
| 950 | 950 | */ |
| 951 | - return function (array $array) { |
|
| 951 | + return function(array $array) { |
|
| 952 | 952 | \natsort($array); |
| 953 | 953 | return $array; |
| 954 | 954 | }; |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | * @param mixed[]$array The array to sort |
| 966 | 966 | * @return mixed[] The sorted array (new array) |
| 967 | 967 | */ |
| 968 | - return function (array $array) { |
|
| 968 | + return function(array $array) { |
|
| 969 | 969 | \natcasesort($array); |
| 970 | 970 | return $array; |
| 971 | 971 | }; |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | * @param mixed[] $array The array to sort |
| 984 | 984 | * @return mixed[] The sorted array (new array) |
| 985 | 985 | */ |
| 986 | - return function (array $array) use ($function) { |
|
| 986 | + return function(array $array) use ($function) { |
|
| 987 | 987 | \uksort($array, $function); |
| 988 | 988 | return $array; |
| 989 | 989 | }; |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | * @param mixed[]$array The array to sort |
| 1003 | 1003 | * @return mixed[] The sorted array (new array) |
| 1004 | 1004 | */ |
| 1005 | - return function (array $array) use ($function) { |
|
| 1005 | + return function(array $array) use ($function) { |
|
| 1006 | 1006 | \uasort($array, $function); |
| 1007 | 1007 | return $array; |
| 1008 | 1008 | }; |
@@ -1022,7 +1022,7 @@ discard block |
||
| 1022 | 1022 | * @param mixed[]$array The array to sort |
| 1023 | 1023 | * @return mixed[] The sorted array (new array) |
| 1024 | 1024 | */ |
| 1025 | - return function (array $array) use ($function) { |
|
| 1025 | + return function(array $array) use ($function) { |
|
| 1026 | 1026 | \usort($array, $function); |
| 1027 | 1027 | return $array; |
| 1028 | 1028 | }; |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | */ |
| 1039 | 1039 | function scan(callable $function, $initialValue): Closure |
| 1040 | 1040 | { |
| 1041 | - return function (array $array) use ($function, $initialValue) { |
|
| 1041 | + return function(array $array) use ($function, $initialValue) { |
|
| 1042 | 1042 | $carry[] = $initialValue; |
| 1043 | 1043 | foreach ($array as $key => $value) { |
| 1044 | 1044 | $initialValue = $function($initialValue, $value); |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | */ |
| 1058 | 1058 | function scanR(callable $function, $initialValue): Closure |
| 1059 | 1059 | { |
| 1060 | - return function (array $array) use ($function, $initialValue) { |
|
| 1060 | + return function(array $array) use ($function, $initialValue) { |
|
| 1061 | 1061 | $carry[] = $initialValue; |
| 1062 | 1062 | foreach (array_reverse($array) as $key => $value) { |
| 1063 | 1063 | $initialValue = $function($initialValue, $value); |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | * @param mixed[] $array |
| 1081 | 1081 | * @return mixed |
| 1082 | 1082 | */ |
| 1083 | - return function (array $array) use ($callable, $initial) { |
|
| 1083 | + return function(array $array) use ($callable, $initial) { |
|
| 1084 | 1084 | return array_reduce($array, $callable, $initial); |
| 1085 | 1085 | }; |
| 1086 | 1086 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
| 1098 | 1098 | * @param mixed[] $array |
| 1099 | 1099 | * @return mixed |
| 1100 | 1100 | */ |
| 1101 | - return function (array $array) use ($callable, $initial) { |
|
| 1101 | + return function(array $array) use ($callable, $initial) { |
|
| 1102 | 1102 | return array_reduce(\array_reverse($array), $callable, $initial); |
| 1103 | 1103 | }; |
| 1104 | 1104 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | * @param mixed[] $array |
| 1118 | 1118 | * @return mixed |
| 1119 | 1119 | */ |
| 1120 | - return function (array $array) use ($callable, $initial) { |
|
| 1120 | + return function(array $array) use ($callable, $initial) { |
|
| 1121 | 1121 | foreach ($array as $key => $value) { |
| 1122 | 1122 | $initial = $callable($initial, $key, $value); |
| 1123 | 1123 | } |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | * @param mixed[] $array |
| 1144 | 1144 | * @return mixed[] |
| 1145 | 1145 | */ |
| 1146 | - return function (array $array) use ($count) { |
|
| 1146 | + return function(array $array) use ($count) { |
|
| 1147 | 1147 | return \array_slice($array, 0, $count); |
| 1148 | 1148 | }; |
| 1149 | 1149 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | // If count is 0, return an empty array |
| 1166 | 1166 | if ($count === 0) { |
| 1167 | - return function (array $array) { |
|
| 1167 | + return function(array $array) { |
|
| 1168 | 1168 | return array(); |
| 1169 | 1169 | }; |
| 1170 | 1170 | } |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * @param mixed[] $array |
| 1174 | 1174 | * @return mixed[] |
| 1175 | 1175 | */ |
| 1176 | - return function (array $array) use ($count) { |
|
| 1176 | + return function(array $array) use ($count) { |
|
| 1177 | 1177 | return \array_slice($array, -$count); |
| 1178 | 1178 | }; |
| 1179 | 1179 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @param mixed[] $array |
| 1192 | 1192 | * @return mixed[] |
| 1193 | 1193 | */ |
| 1194 | - return function (array $array) use ($conditional) { |
|
| 1194 | + return function(array $array) use ($conditional) { |
|
| 1195 | 1195 | $carry = array(); |
| 1196 | 1196 | foreach ($array as $key => $value) { |
| 1197 | 1197 | if (true === $conditional($value)) { |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | * @param mixed[] $array |
| 1217 | 1217 | * @return mixed[] |
| 1218 | 1218 | */ |
| 1219 | - return function (array $array) use ($conditional) { |
|
| 1219 | + return function(array $array) use ($conditional) { |
|
| 1220 | 1220 | $carry = array(); |
| 1221 | 1221 | foreach ($array as $key => $value) { |
| 1222 | 1222 | if (false === $conditional($value)) { |