Skip to content

Commit f3e0f6b

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@62870 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6e37bf1 commit f3e0f6b

2 files changed

Lines changed: 4 additions & 20 deletions

File tree

‎tests/phpunit/includes/object-cache.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,11 +2364,7 @@ public function add_non_persistent_groups( $groups ) {
23642364
public function get_from_runtime_cache( $key, $group ) {
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

23742370
/**

‎tests/phpunit/tests/fonts/font-face/wp-font-face-tests-dataset.php‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,7 @@ public function get_expected_fonts_for_fonts_block_theme( $key = '' ) {
308308
);
309309
}
310310

311-
if ( isset( $data[ $key ] ) ) {
312-
return $data[ $key ];
313-
}
314-
315-
return $data;
311+
return $data[ $key ] ?? $data;
316312
}
317313

318314
public static function get_custom_font_families( $key = '' ) {
@@ -397,11 +393,7 @@ public static function get_custom_font_families( $key = '' ) {
397393
);
398394
}
399395

400-
if ( isset( $data[ $key ] ) ) {
401-
return $data[ $key ];
402-
}
403-
404-
return $data;
396+
return $data[ $key ] ?? $data;
405397
}
406398

407399
public static function get_custom_style_variations( $key = '' ) {
@@ -488,10 +480,6 @@ public static function get_custom_style_variations( $key = '' ) {
488480
);
489481
}
490482

491-
if ( isset( $data[ $key ] ) ) {
492-
return $data[ $key ];
493-
}
494-
495-
return $data;
483+
return $data[ $key ] ?? $data;
496484
}
497485
}

0 commit comments

Comments
 (0)