Skip to content

Commit

Permalink
PHP 8.1 minimum version prep
Browse files Browse the repository at this point in the history
  • Loading branch information
rotimi committed Mar 14, 2024
1 parent 4b15feb commit f0b4cce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/NumericsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ protected function itemFromString(string $str): float|int
{
if( str_contains($str, '.') ) {

return ( (float) ($str.'') );
return ( (float) ($str) );
}

return ( (int) ($str.'') );
return ( (int) ($str) );
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
* @param bool $access_private_or_protected true if value associated with private or protected property should be returned.
* If false is specified and you try to access a private or protected property, a
* \RuntimeException will be thrown.
* @return mixed
*
* @throws InvalidArgumentException
* @throws RuntimeException
* @throws ReflectionException
*
* @noinspection DuplicatedCode
*/
function get_object_property_value(object $obj, string|int $property, mixed $default_val=null, bool $access_private_or_protected=false)
function get_object_property_value(object $obj, string|int $property, mixed $default_val=null, bool $access_private_or_protected=false): mixed
{
$property = ''.$property;
$return_val = $default_val;
Expand Down Expand Up @@ -128,7 +127,7 @@ function object_has_property(object $obj, string|int $property): bool
*
* @throws LengthException
*/
function random_array_key(array $array)
function random_array_key(array $array): string|int|null
{
if( \count($array) <= 0 ) {

Expand Down Expand Up @@ -177,7 +176,7 @@ function random_array_key(array $array)

// fallback to array_rand since an error / exception occurred
// while trying to use random_int
$random_key = \array_rand($array);
$random_key = \array_rand($array, 1);
}

return $random_key;
Expand Down

0 comments on commit f0b4cce

Please sign in to comment.