[wp-trac] [WordPress Trac] #63430: Coding Standards: replace isset() ternary with null coalescing
WordPress Trac
noreply at wordpress.org
Sun May 11 00:56:58 UTC 2025
#63430: Coding Standards: replace isset() ternary with null coalescing
------------------------------+-----------------------------
Reporter: seanwei | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: minor | Keywords:
Focuses: coding-standards |
------------------------------+-----------------------------
When reviewing the source code, I noticed some ternary expressions of the
form `isset( $var ) ? $var : null`.
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, we
can safely replace these ternaries with the more concise `$var ?? null`
syntax.
To ensure the changeset is correct, I'd prefer break the changes to bulk
of files instead of fixing entire project in one PR.
I've changed manually with the help with IDE, and verify that the meaning
of code is exactly the same.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63430>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list