Last active
February 22, 2022 14:07
-
-
Save vudaltsov/f100dab5a0067092653350b0af99025b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @psalm-pure | |
* @template T | |
* @template TArray of array<T> | |
* @param TArray $values | |
* @return (TArray is non-empty-array<T> ? T : ?T) | |
*/ | |
function array_value_first(array $values): mixed | |
{ | |
$key = array_key_first($values); | |
if ($key === null) { | |
return null; | |
} | |
return $values[$key]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment