Coding Standards: Use strict null comparison instead of is_null()#12124
Coding Standards: Use strict null comparison instead of is_null()#12124Dervish12 wants to merge 1 commit into
Conversation
Replace `is_null( $var )` with `null === $var` and `! is_null( $var )` with `null !== $var` across multiple core files. WordPress Coding Standards prefer strict comparison operators over function calls for type checking. Using `null === $var` is functionally equivalent to `is_null( $var )` but aligns with the Yoda condition style used throughout WordPress core and is more consistent with how other type checks are written (e.g. `false === $var`). This changeset updates 14 core files, excluding third-party libraries and files where polyfill availability is a concern. Props Dervish12. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Dervish12. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
Summary
Replace
is_null( $var )withnull === $varand! is_null( $var )withnull !== $varacross multiple core files.WordPress Coding Standards prefer strict comparison operators over function calls for type checking. Using
null === $varis functionally equivalent tois_null( $var )but:false === $var)Files changed (14 files, 25 replacements)
src/wp-includes/functions.php— 6 instancessrc/wp-includes/blocks/navigation-link.php— 4 instancessrc/wp-includes/blocks.php— 2 instancessrc/wp-includes/post.php— 2 instancessrc/wp-includes/load.php— 2 instancessrc/wp-includes/blocks/icon.php— 1 instancesrc/wp-includes/blocks/template-part.php— 1 instancesrc/wp-includes/formatting.php— 1 instancesrc/wp-includes/http.php— 1 instancesrc/wp-includes/revision.php— 1 instancesrc/wp-includes/class-wp-http-cookie.php— 1 instancesrc/wp-includes/class-wp-http-proxy.php— 1 instancesrc/wp-includes/ms-functions.php— 1 instancesrc/wp-admin/install.php— 1 instanceThird-party libraries and files with polyfill availability concerns were intentionally excluded.
Test plan
is_null())This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.