[wp-trac] [WordPress Trac] #58874: Code Modernization: Consider using the null coalescing operator.
WordPress Trac
noreply at wordpress.org
Mon Dec 22 23:13:17 UTC 2025
#58874: Code Modernization: Consider using the null coalescing operator.
-------------------------------------------------+-------------------------
Reporter: costdev | Owner: costdev
Type: enhancement | Status: accepted
Priority: normal | Milestone: Future
| Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch awaiting-php7-make-post- | Focuses:
first 2nd-opinion |
-------------------------------------------------+-------------------------
Comment (by SergeyBiryukov):
In [changeset:"61403" 61403]:
{{{
#!CommitTicketReference repository="" revision="61403"
Code Modernization: Replace some `isset()` ternary checks with null
coalescing.
Since PHP 7.0 introduced the [https://www.php.net/manual/en/migration70
.new-features.php#migration70.new-features.null-coalesce-op null
coalescing operator], and WordPress now requires at least PHP 7.2.24,
`isset( $var ) ? $var : null` ternary checks can be safely replaced with
the more concise `$var ?? null` syntax.
As some new code using the null coalescing operator has already been
introduced into core in recent releases, this commit continues with the
code modernization by implementing incremental changes for easier review.
Props seanwei, getsyash, krupalpanchal, wildworks, jorbin, SergeyBiryukov.
Fixes #63430. See #58874.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58874#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list