@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $value = str_replace($val, (string) $key, $value); |
92 | 92 | } |
93 | 93 | |
94 | - return (string)preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
94 | + return (string) preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string|array<mixed> $needles |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public static function contains(string $value, string|array $needles): bool |
|
210 | + public static function contains(string $value, string | array $needles): bool |
|
211 | 211 | { |
212 | 212 | if (!is_array($needles)) { |
213 | 213 | $needles = [$needles]; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param string|array<mixed> $needles |
229 | 229 | * @return bool |
230 | 230 | */ |
231 | - public static function endsWith(string $value, string|array $needles): bool |
|
231 | + public static function endsWith(string $value, string | array $needles): bool |
|
232 | 232 | { |
233 | 233 | if (!is_array($needles)) { |
234 | 234 | $needles = [$needles]; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string|array<mixed> $needles |
250 | 250 | * @return bool |
251 | 251 | */ |
252 | - public static function startsWith(string $value, string|array $needles): bool |
|
252 | + public static function startsWith(string $value, string | array $needles): bool |
|
253 | 253 | { |
254 | 254 | if (!is_array($needles)) { |
255 | 255 | $needles = [$needles]; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | // pattern such as "library/*", making any string check convenient. |
320 | 320 | $cleanQuoted = str_replace('\*', '.*', $quoted); |
321 | 321 | |
322 | - return (bool)preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
322 | + return (bool) preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param string $encode |
329 | 329 | * @return int |
330 | 330 | */ |
331 | - public static function length(string|int $value, string $encode = 'UTF-8'): int |
|
331 | + public static function length(string | int $value, string $encode = 'UTF-8'): int |
|
332 | 332 | { |
333 | 333 | if (!is_string($value)) { |
334 | 334 | $value = (string) $value; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @return string |
350 | 350 | */ |
351 | 351 | public static function pad( |
352 | - string|int $value, |
|
352 | + string | int $value, |
|
353 | 353 | int $length, |
354 | 354 | string $padStr = ' ', |
355 | 355 | int $type = STR_PAD_BOTH |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return string |
372 | 372 | */ |
373 | 373 | public static function padLeft( |
374 | - string|int $value, |
|
374 | + string | int $value, |
|
375 | 375 | int $length, |
376 | 376 | string $padStr = ' ' |
377 | 377 | ): string { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @return string |
387 | 387 | */ |
388 | 388 | public static function padRight( |
389 | - string|int $value, |
|
389 | + string | int $value, |
|
390 | 390 | int $length, |
391 | 391 | string $padStr = ' ' |
392 | 392 | ): string { |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param int $length |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public static function repeat(string|int $value, int $length = 1): string |
|
402 | + public static function repeat(string | int $value, int $length = 1): string |
|
403 | 403 | { |
404 | 404 | if (!is_string($value)) { |
405 | 405 | $value = (string) $value; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public static function isAscii(string $value): bool |
633 | 633 | { |
634 | - return (bool)!preg_match('/[^\x00-\x7F]/S', $value); |
|
634 | + return (bool) !preg_match('/[^\x00-\x7F]/S', $value); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $bytes = random_bytes((int) ceil($length / 2)); |
666 | 666 | |
667 | - return (string)substr(bin2hex($bytes), 0, $length); |
|
667 | + return (string) substr(bin2hex($bytes), 0, $length); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | // handle boolean, array, & html special chars |
682 | - array_walk($attributes, function (&$value, $key) { |
|
682 | + array_walk($attributes, function(&$value, $key) { |
|
683 | 683 | $value = is_bool($value) ? $value ? 'true' : 'false' : $value; |
684 | 684 | $value = is_array($value) ? implode(' ', $value) : $value; |
685 | 685 | $value = trim($value); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | }); |
688 | 688 | |
689 | 689 | // remove empty elements |
690 | - $emptyAttributes = array_filter($attributes, function ($value) { |
|
690 | + $emptyAttributes = array_filter($attributes, function($value) { |
|
691 | 691 | return strlen($value) > 0; |
692 | 692 | }); |
693 | 693 | |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | $pool = '2345679ACDEFHJKLMNPRSTUVWXYZ'; |
763 | 763 | break; |
764 | 764 | default: |
765 | - $pool = (string)$type; |
|
765 | + $pool = (string) $type; |
|
766 | 766 | $utf8 = !self::isAscii($pool); |
767 | 767 | break; |
768 | 768 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $ignoreKeys = $firstKey === 0; |
867 | 867 | |
868 | 868 | return sprintf('[%s]', implode(', ', array_map( |
869 | - function ($key, $value) use ($ignoreKeys) { |
|
869 | + function($key, $value) use ($ignoreKeys) { |
|
870 | 870 | return $ignoreKeys |
871 | 871 | ? self::stringify($value) |
872 | 872 | : sprintf( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public static function call(callable|array $callback, mixed ...$args): mixed |
|
64 | + public static function call(callable | array $callback, mixed ...$args): mixed |
|
65 | 65 | { |
66 | 66 | if (is_string($callback)) { |
67 | 67 | // className::method |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return mixed |
97 | 97 | */ |
98 | - public static function callArray(callable|array $callback, array $args): mixed |
|
98 | + public static function callArray(callable | array $callback, array $args): mixed |
|
99 | 99 | { |
100 | 100 | return self::call($callback, ...$args); |
101 | 101 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | if (array_key_exists('size', $matches)) { |
72 | 72 | $value = floatval(strtoupper($matches['size'])); |
73 | 73 | } |
74 | - return (int)($value * pow(1024, $units[$unit])); |
|
74 | + return (int) ($value * pow(1024, $units[$unit])); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array<mixed> |
69 | 69 | */ |
70 | 70 | public static function toArray( |
71 | - array|object|string $object, |
|
71 | + array | object | string $object, |
|
72 | 72 | array $properties = [], |
73 | 73 | bool $recursive = true |
74 | 74 | ): array { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $result = $object->toArray(); |
108 | 108 | } else { |
109 | 109 | $result = []; |
110 | - foreach ((array)$object as $key => $value) { |
|
110 | + foreach ((array) $object as $key => $value) { |
|
111 | 111 | $result[$key] = $value; |
112 | 112 | } |
113 | 113 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public static function merge(array ...$args): array |
129 | 129 | { |
130 | - $res = (array)array_shift($args); |
|
130 | + $res = (array) array_shift($args); |
|
131 | 131 | while (count($args) > 0) { |
132 | 132 | $next = array_shift($args); |
133 | 133 | foreach ($next as $key => $value) { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public static function getValue( |
163 | 163 | mixed $object, |
164 | - int|string|Closure|array $key, |
|
164 | + int | string | Closure | array $key, |
|
165 | 165 | mixed $default = null |
166 | 166 | ): mixed { |
167 | 167 | if ($key instanceof Closure) { |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed|null |
227 | 227 | */ |
228 | - public static function remove(array &$array, string|int $key, mixed $default = null): mixed |
|
228 | + public static function remove(array &$array, string | int $key, mixed $default = null): mixed |
|
229 | 229 | { |
230 | 230 | if (isset($array[$key]) || array_key_exists($key, $array)) { |
231 | 231 | $value = $array[$key]; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param array<int, int|string>|string|int $keys |
245 | 245 | * @return array<mixed> |
246 | 246 | */ |
247 | - public static function except(array $array, array|string|int $keys): array |
|
247 | + public static function except(array $array, array | string | int $keys): array |
|
248 | 248 | { |
249 | 249 | static::forget($array, $keys); |
250 | 250 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param array<int, int|string>|string|int $keys |
258 | 258 | * @return void |
259 | 259 | */ |
260 | - public static function forget(array &$array, array|string|int $keys): void |
|
260 | + public static function forget(array &$array, array | string | int $keys): void |
|
261 | 261 | { |
262 | 262 | $original = &$array; |
263 | 263 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param mixed $default |
302 | 302 | * @return mixed |
303 | 303 | */ |
304 | - public static function pull(array &$array, string|int $key, mixed $default = null): mixed |
|
304 | + public static function pull(array &$array, string | int $key, mixed $default = null): mixed |
|
305 | 305 | { |
306 | 306 | $value = static::get($array, $key, $default); |
307 | 307 | |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public static function index( |
334 | 334 | array $array, |
335 | - string|int|Closure|array|null $key = null, |
|
336 | - string|int|array|null $groups = [] |
|
335 | + string | int | Closure | array | null $key = null, |
|
336 | + string | int | array | null $groups = [] |
|
337 | 337 | ): array { |
338 | 338 | $result = []; |
339 | 339 | if (!is_array($groups)) { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public static function getColumn( |
382 | 382 | array $array, |
383 | - int|string|Closure $name, |
|
383 | + int | string | Closure $name, |
|
384 | 384 | bool $keepKeys = true |
385 | 385 | ): array { |
386 | 386 | $result = []; |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public static function map( |
415 | 415 | array $array, |
416 | - string|Closure $from, |
|
417 | - string|Closure $to, |
|
418 | - string|array|Closure|null $group = null |
|
416 | + string | Closure $from, |
|
417 | + string | Closure $to, |
|
418 | + string | array | Closure | null $group = null |
|
419 | 419 | ): array { |
420 | 420 | $result = []; |
421 | 421 | foreach ($array as $element) { |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | */ |
475 | 475 | public static function multisort( |
476 | 476 | array &$array, |
477 | - string|Closure|array $key, |
|
478 | - int|array $direction = SORT_ASC, |
|
479 | - int|array $sortFlag = SORT_REGULAR |
|
477 | + string | Closure | array $key, |
|
478 | + int | array $direction = SORT_ASC, |
|
479 | + int | array $sortFlag = SORT_REGULAR |
|
480 | 480 | ): void { |
481 | 481 | $keys = is_array($key) ? $key : [$key]; |
482 | 482 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | return; |
485 | 485 | } |
486 | 486 | |
487 | - $count = count($keys); |
|
487 | + $count = count($keys); |
|
488 | 488 | if (is_scalar($direction)) { |
489 | 489 | $direction = array_fill(0, $count, $direction); |
490 | 490 | } elseif (count($direction) !== $count) { |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * @param bool $strict |
606 | 606 | * @return bool |
607 | 607 | */ |
608 | - public static function isIn(mixed $needle, array|Traversable $array, bool $strict = false): bool |
|
608 | + public static function isIn(mixed $needle, array | Traversable $array, bool $strict = false): bool |
|
609 | 609 | { |
610 | 610 | if ($array instanceof Traversable) { |
611 | 611 | $array = iterator_to_array($array); |
@@ -645,8 +645,8 @@ discard block |
||
645 | 645 | * @return bool |
646 | 646 | */ |
647 | 647 | public static function isSubset( |
648 | - array|Traversable $needles, |
|
649 | - array|Traversable $array, |
|
648 | + array | Traversable $needles, |
|
649 | + array | Traversable $array, |
|
650 | 650 | bool $strict = false |
651 | 651 | ): bool { |
652 | 652 | foreach ($needles as $needle) { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | * @param string|int $key |
758 | 758 | * @return bool |
759 | 759 | */ |
760 | - public static function exists(array|ArrayAccess $array, string|int $key): bool |
|
760 | + public static function exists(array | ArrayAccess $array, string | int $key): bool |
|
761 | 761 | { |
762 | 762 | if (is_array($array)) { |
763 | 763 | return array_key_exists($key, $array); |
@@ -775,8 +775,8 @@ discard block |
||
775 | 775 | * @return mixed |
776 | 776 | */ |
777 | 777 | public static function get( |
778 | - array|ArrayAccess $array, |
|
779 | - string|int|null $key = null, |
|
778 | + array | ArrayAccess $array, |
|
779 | + string | int | null $key = null, |
|
780 | 780 | mixed $default = null |
781 | 781 | ): mixed { |
782 | 782 | if ($key === null) { |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @param string|int $key |
811 | 811 | * @return bool |
812 | 812 | */ |
813 | - public static function has(array|ArrayAccess $array, string|int $key): bool |
|
813 | + public static function has(array | ArrayAccess $array, string | int $key): bool |
|
814 | 814 | { |
815 | 815 | if (empty($array)) { |
816 | 816 | return false; |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | */ |
928 | 928 | public static function similar( |
929 | 929 | string $need, |
930 | - array|Traversable $array, |
|
930 | + array | Traversable $array, |
|
931 | 931 | int $percentage = 45 |
932 | 932 | ): array { |
933 | 933 | if (empty($need)) { |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | $max = 0; |
958 | 958 | foreach ($array as $key => $value) { |
959 | 959 | if (!$expectInt || !is_numeric($key)) { |
960 | - $width = mb_strlen((string)$key, 'UTF-8'); |
|
960 | + $width = mb_strlen((string) $key, 'UTF-8'); |
|
961 | 961 | if ($width > $max) { |
962 | 962 | $max = $width; |
963 | 963 | } |
@@ -1064,8 +1064,8 @@ discard block |
||
1064 | 1064 | */ |
1065 | 1065 | public static function pluck( |
1066 | 1066 | array $array, |
1067 | - string|int $value, |
|
1068 | - string|int|null $key = null |
|
1067 | + string | int $value, |
|
1068 | + string | int | null $key = null |
|
1069 | 1069 | ): array { |
1070 | 1070 | $results = []; |
1071 | 1071 | foreach ($array as $item) { |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | } else { |
1082 | 1082 | $itemKey = static::get($item, $key); |
1083 | 1083 | if (is_object($itemKey) && $itemKey instanceof Stringable) { |
1084 | - $itemKey = (string)$itemKey; |
|
1084 | + $itemKey = (string) $itemKey; |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | $results[$itemKey] = $itemValue; |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | $keys = array_rand($array, $number); |
1186 | 1186 | |
1187 | 1187 | $results = []; |
1188 | - foreach ((array)$keys as $key) { |
|
1188 | + foreach ((array) $keys as $key) { |
|
1189 | 1189 | $results[] = $array[$key]; |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1234,18 +1234,18 @@ discard block |
||
1234 | 1234 | if (preg_match('/^\-\w=/', $arg)) { |
1235 | 1235 | $normalized = array_merge( |
1236 | 1236 | $normalized, |
1237 | - (array)explode('=', $arg) |
|
1237 | + (array) explode('=', $arg) |
|
1238 | 1238 | ); |
1239 | 1239 | } elseif (preg_match('/^\-\w{2,}/', $arg)) { |
1240 | 1240 | $splitArgs = implode(' -', str_split(ltrim($arg, '-'))); |
1241 | 1241 | $normalized = array_merge( |
1242 | 1242 | $normalized, |
1243 | - (array)explode(' ', '-' . $splitArgs) |
|
1243 | + (array) explode(' ', '-' . $splitArgs) |
|
1244 | 1244 | ); |
1245 | 1245 | } elseif (preg_match('/^\-\-([^\s\=]+)\=/', $arg)) { |
1246 | 1246 | $normalized = array_merge( |
1247 | 1247 | $normalized, |
1248 | - (array)explode('=', $arg) |
|
1248 | + (array) explode('=', $arg) |
|
1249 | 1249 | ); |
1250 | 1250 | } else { |
1251 | 1251 | $normalized[] = $arg; |
@@ -68,7 +68,7 @@ |
||
68 | 68 | bool $assoc = false, |
69 | 69 | int $depth = 512, |
70 | 70 | int $options = 0 |
71 | - ): array|object|bool|null { |
|
71 | + ): array | object | bool | null { |
|
72 | 72 | if ($depth < 1 || $depth > PHP_INT_MAX) { |
73 | 73 | $depth = 512; |
74 | 74 | } |