As soon as PHP 8.5 becomes the minimum required version for this library:
https://www.php.net/releases/8.5/en.php#array-first-and-last-functions
Using array_pop() is changing the original array by removing the last item from it, which may cause unexpected behaviour. array_last() doesn't do this, so it should in theory also be faster