[wp-trac] [WordPress Trac] #58874: Code Modernization: Consider using the null coalescing operator.

WordPress Trac noreply at wordpress.org
Tue Dec 23 21:19:14 UTC 2025


#58874: Code Modernization: Consider using the null coalescing operator.
-------------------------------------------------+-------------------------
 Reporter:  costdev                              |       Owner:  costdev
     Type:  enhancement                          |      Status:  accepted
 Priority:  normal                               |   Milestone:  7.0
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch awaiting-php7-make-post-   |     Focuses:
  first has-unit-tests                           |
-------------------------------------------------+-------------------------

Comment (by SergeyBiryukov):

 In [changeset:"61404" 61404]:
 {{{
 #!CommitTicketReference repository="" revision="61404"
 Code Modernization: Replace `isset()` with null coalescing in
 `WP_Roles::get_role()`.

 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.

 Follow-up to [2703], [61403].

 Props dilipbheda, mukesh27, spacedmonkey, SergeyBiryukov.
 Fixes #63216. See #58874.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58874#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list