[wp-trac] [WordPress Trac] #63853: Add PHP 8.5 compat array functions: `array_first` and `array_last`

WordPress Trac noreply at wordpress.org
Thu Aug 21 03:20:22 UTC 2025


#63853: Add PHP 8.5 compat array functions: `array_first` and `array_last`
-------------------------------+--------------------------------
 Reporter:  TobiasBg           |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  6.9
Component:  General            |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  needs-patch php85  |     Focuses:  php-compatibility
-------------------------------+--------------------------------

Comment (by peterwilsoncc):

 @tusharbharti Thank you, that would be very helpful.

 > If the values passed to the parameters are empty-ish like null, 0 ,
 false etc, should the function return null ( by allowing empty-ish value
 to be passed ) or throw error when trying to access the key for these.

 In PHP the new functions are type strict so the compatibility
 implementations should be too. If you define the functions as `function
 array_*( array $array )` then that will trigger the fatal error.

 > If any error occurs while trying to get the first/last key of the array
 or trying to get the value from the array, should the function handle
 these errors or this is left for consumers to handle.

 Being type strict, this should be a use case that needs to be covered.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63853#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list