[wp-trac] [WordPress Trac] #57067: Replace certain `array_key_exists()` calls with `isset()` once PHP requirement is raised to 7.0+
WordPress Trac
noreply at wordpress.org
Thu Nov 10 22:01:34 UTC 2022
#57067: Replace certain `array_key_exists()` calls with `isset()` once PHP
requirement is raised to 7.0+
-------------------------+----------------------------
Reporter: flixos90 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: normal | Keywords:
Focuses: performance |
-------------------------+----------------------------
**This ticket is blocked until WordPress requires at least PHP 7.0 as
minimum version.**
Checks like `isset( MY_CONSTANT[ $key ] )` result in a fatal error in PHP
< 7.0, which is why parts of the WordPress codebase uses
`array_key_exists()` for such situations as of today, due to the support
for PHP 5.6. Also see
https://github.com/PHPCompatibility/PHPCompatibility/issues/1301 which
explores flagging this as part of the PHPCompatibility sniffs.
This was raised as part of #56974, which reviewed several of these checks.
`isset` is slightly preferable over `array_key_exists` in terms of
performance (with the caveat that the two behave differently when it comes
to `null` values).
As of today, this ticket is essentially a reminder to update such calls to
`array_key_exists()` in WordPress core once it will at some point no
longer support PHP versions below 7.0.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57067>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list