Make WordPress Core

Changeset 62870


Ignore:
Timestamp:
07/28/2026 04:23:21 PM (6 weeks ago)
Author:
SergeyBiryukov
Message:

Tests: Use null coalescing operator over isset() checks.

This commit replaces verbose isset()-and-return blocks with the ?? operator in the object cache helper and font-face test dataset.

Follow-up to [40561], [56500], [59260].

Props Soean, mukesh27.
See #64894.

Location:
trunk/tests/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/object-cache.php

    r62699 r62870  
    23652365                $derived_key = $this->buildKey( $key, $group );
    23662366
    2367                 if ( isset( $this->cache[ $derived_key ] ) ) {
    2368                         return $this->cache[ $derived_key ];
    2369                 }
    2370 
    2371                 return false;
     2367                return $this->cache[ $derived_key ] ?? false;
    23722368        }
    23732369
  • trunk/tests/phpunit/tests/fonts/font-face/wp-font-face-tests-dataset.php

    r59260 r62870  
    309309                }
    310310
    311                 if ( isset( $data[ $key ] ) ) {
    312                         return $data[ $key ];
    313                 }
    314 
    315                 return $data;
     311                return $data[ $key ] ?? $data;
    316312        }
    317313
     
    398394                }
    399395
    400                 if ( isset( $data[ $key ] ) ) {
    401                         return $data[ $key ];
    402                 }
    403 
    404                 return $data;
     396                return $data[ $key ] ?? $data;
    405397        }
    406398
     
    489481                }
    490482
    491                 if ( isset( $data[ $key ] ) ) {
    492                         return $data[ $key ];
    493                 }
    494 
    495                 return $data;
     483                return $data[ $key ] ?? $data;
    496484        }
    497485}
Note: See TracChangeset for help on using the changeset viewer.