[wp-trac] [WordPress Trac] #45055: Introduce new PHP cross-version compatibility functions, `array_key_first()`, `array_key_last()`

WordPress Trac noreply at wordpress.org
Tue Jan 29 14:52:30 UTC 2019


#45055: Introduce new PHP cross-version compatibility functions,
`array_key_first()`, `array_key_last()`
-----------------------------+-----------------------------
 Reporter:  desrosj          |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  General          |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  php73 has-patch  |     Focuses:
-----------------------------+-----------------------------
Changes (by ayeshrajans):

 * keywords:  php73 needs-patch => php73 has-patch
 * version:   => trunk


Comment:

 I also think it's a good idea to add the polyfills, but also to search
 existing `current()`, `reset()`, and `key()` calls to make use of this
 function. I know PHP 7.3 users will appreciate it too.

 Patch from @manzoorwanijk is a good start, but now that PHP 7.3 is
 released, we can make it more closure to the native function. It looks
 like this patch was taken from the first example in this function page.
 Symfony/polyfills has a better one that mimics the original functionality
 with parameter types. I will attach a patch with more optimized polyfills.
 To make it complete, this patch also contains the original tests from PHP
 source, so we can make sure it really gives same results as PHP's own
 tests.

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


More information about the wp-trac mailing list