@@ -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; |
@@ -58,8 +58,7 @@ |
||
58 | 58 | * @class Arr |
59 | 59 | * @package Platine\Stdlib\Helper |
60 | 60 | */ |
61 | -class Arr |
|
62 | -{ |
|
61 | +class Arr { |
|
63 | 62 | /** |
64 | 63 | * Convert an array, object or string to array |
65 | 64 | * @param array<mixed>|object|string $object |
@@ -62,8 +62,7 @@ |
||
62 | 62 | * @class Uuid |
63 | 63 | * @package Platine\Stdlib\Helper |
64 | 64 | */ |
65 | -class Uuid |
|
66 | -{ |
|
65 | +class Uuid { |
|
67 | 66 | /** |
68 | 67 | * Generate UUID v3 |
69 | 68 | * @param string $namespace |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * @class Env |
51 | 51 | * @package Platine\Stdlib\Helper |
52 | 52 | */ |
53 | -class Env |
|
54 | -{ |
|
53 | +class Env { |
|
55 | 54 | /** |
56 | 55 | * Whether the application is running on CLI |
57 | 56 | * @return bool |
@@ -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 | } |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * @class Json |
53 | 53 | * @package Platine\Stdlib\Helper |
54 | 54 | */ |
55 | -class Json |
|
56 | -{ |
|
55 | +class Json { |
|
57 | 56 | /** |
58 | 57 | * Decode JSON string |
59 | 58 | * @param string $json |