[wp-trac] [WordPress Trac] #64488: Code Modernization: replace if isset() return with null coalescing

WordPress Trac noreply at wordpress.org
Sat Jan 10 23:18:42 UTC 2026


#64488: Code Modernization: replace if isset() return with null coalescing
-------------------------+-------------------------------
 Reporter:  Soean        |       Owner:  westonruter
     Type:  enhancement  |      Status:  reviewing
 Priority:  normal       |   Milestone:  7.0
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  coding-standards
-------------------------+-------------------------------
Description changed by westonruter:

Old description:

> In #63430 isset() ternary were replaced with null coalescing.
>
> We also should replace if isset() return with null coalescing.
>
> {{{#!php
> <?php
> -        if (isset($this->items[$key])) {
> -            return $this->items[$key];
> -        }
> -
> -        return 'fallback value';
> +        return $this->items[$key] ?? 'fallback value';
> }}}

New description:

 In #63430 isset() ternary were replaced with null coalescing.

 We also should replace if isset() return with null coalescing.

 {{{#!php
 <?php
 -        if (isset($this->items[$key])) {
 -            return $this->items[$key];
 -        }
 -
 -        return 'fallback value';
 +        return $this->items[$key] ?? 'fallback value';
 }}}

 This is part of #58874.

--

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


More information about the wp-trac mailing list