File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 11parameters :
22 ignoreErrors :
3+ -
4+ message : ' #^Function array_first not found\.$#'
5+ identifier : function.notFound
6+ count : 1
7+ path : src/Arr.php
8+
9+ -
10+ message : ' #^Function array_last not found\.$#'
11+ identifier : function.notFound
12+ count : 1
13+ path : src/Arr.php
14+
315 -
416 message : ' #^Parameter \#1 \$min \(0\) of function random_int expects lower number than parameter \#2 \$max \(int\<\-1, max\>\)\.$#'
517 identifier : argument.type
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public static function first(array $array):mixed{
3636 return null ;
3737 }
3838
39+ if (PHP_VERSION_ID >= 80500 ){
40+ return \array_first ($ array );
41+ }
42+
3943 return $ array [array_key_first ($ array )];
4044 }
4145
@@ -52,13 +56,17 @@ public static function last(array $array):mixed{
5256 return null ;
5357 }
5458
59+ if (PHP_VERSION_ID >= 80500 ){
60+ return \array_last ($ array );
61+ }
62+
5563 return $ array [array_key_last ($ array )];
5664 }
5765
5866 /**
5967 * Returns a random element of the given array, `null` if the given array is empty.
6068 *
61- * @see \random_int() - PHP <= 8.1
69+ * @see \random_int() - PHP 8.1
6270 * @see \Random\Randomizer::pickArrayKeys() - PHP >= 8.2
6371 *
6472 * @param array<string|int, mixed> $array
You can’t perform that action at this time.
0 commit comments