Skip to content

Commit 5790e0f

Browse files
committed
:octocat:
1 parent 98dab1e commit 5790e0f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

phpstan-baseline.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
parameters:
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

src/Arr.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)