Opened 2 months ago
Last modified 8 weeks ago
#62558 new feature request
Add PHP 8.4 compat array functions: `array_find`, `array_find_key`, `array_any` and `array_all`
Reported by: | Soean | Owned by: | |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch php84 add-to-field-guide changes-requested |
Focuses: | php-compatibility | Cc: |
Description
Add polyfill functions for PHP 8.4 array utilities
- Added
array_find
function to search an array for the first element that passes a given callback. - Added
array_find_key
function to search an array for the first key that passes a given callback. - Added
array_any
function to check if any element of an array passes a given callback. - Added
array_all
function to check if all elements of an array pass a given callback.
Change History (5)
This ticket was mentioned in PR #7879 on WordPress/wordpress-develop by @Soean.
2 months ago
#1
- Keywords has-patch added
#3
@
2 months ago
- Keywords php84 added
- Type changed from defect (bug) to feature request
Related: #62061, #62277
Previously added polyfills: [57337], [52038]
One Inline Documentation request, if I may: There should not be a blank line before the @return
, see https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#1-functions-class-methods
#5
@
8 weeks ago
Do we have a guideline on which functions we polyfill, and which we don't?
PHP 8.4 has more new functions, and and the likelihood of functions like mb_*trim
functions being useful enough to polyfill is as good as the new array_*
functions.
I'm not objecting this ticket in particular, just wanted to put my two cents forward that we probably should follow a guideline (of which I don't know if exists) so we can maintain the polyfills properly.
array_find
function to search an array for the first element that passes a given callback.array_find_key
function to search an array for the first key that passes a given callback.array_any
function to check if any element of an array passes a given callback.array_all
function to check if all elements of an array pass a given callback.Trac ticket: https://core.trac.wordpress.org/ticket/62558