[wp-trac] [WordPress Trac] #55105: Introduce a polyfill for `array_is_list()`.
WordPress Trac
noreply at wordpress.org
Mon Feb 7 17:29:01 UTC 2022
#55105: Introduce a polyfill for `array_is_list()`.
-----------------------------+-----------------------------
Reporter: costdev | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.9
Severity: minor | Keywords:
Focuses: |
-----------------------------+-----------------------------
PHP 8.1 introduces a new function, `array_is_list()`.
The function determines whether an array's keys consist of consecutive
numbers from `0` to `count( $arr ) - 1`.
Including a polyfill will allow developers to take advantage of the new
function.
**Notes**
- A list must start from an offset of 0. `array( 2 => 'one', 3 => 'two'
);` will return `false`.
- An empty array will return `true`.
**References**
- PHP Manual: [https://www.php.net/manual/en/function.array-is-list.php
array_is_list]
- PHP RFC: [https://wiki.php.net/rfc/is_list Add array_is_list]
- 3v4l.org: [https://3v4l.org/agfKh Examples]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55105>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list