Commit ac9b788984 for wordpress.org

commit ac9b7889840754c18fa2ea4b50c5728de36624de
Author: SergeyBiryukov <sergeybiryukov@git.wordpress.org>
Date:   Fri Nov 6 19:35:53 2026 +0000

    Code Modernization: Simplify `isset()` guards that initialize empty arrays.

    Covering one recognizable idiom: initializing a container to an empty array before writing into it.

    {{{#!diff
    -if ( ! isset( $widget_options[ $widget_id ] ) ) {
    -       $widget_options[ $widget_id ] = array();
    -}
    +$widget_options[ $widget_id ] ??= array();
    }}}

    Every one of the 54 changed guards is an `isset()` check whose entire body is a single `= array();` assignment to the tested expression. Each one is handled by one of four rules, so no case needs individual judgement:

    1. **Convert** the guard to `??=` (35 places).
    2. **Collapse** nested guard chains to the deepest key, since `??=` autovivifies missing parent arrays (`add_meta_box()`, `remove_meta_box()`):
       {{{#!php
       $wp_meta_boxes[ $page ][ $context ] ??= array();
       }}}
    3. **Remove** the guard where the next statement writes into the same array or property anyway, since that write creates it (9 places):
       {{{#!diff
       -if ( ! isset( $object_terms[ $id ] ) ) {
       -    $object_terms[ $id ] = array();
       -}
        $object_terms[ $id ][ $taxonomy ] = array();
       }}}
    4. **Inline** the default where the next statement reassigns the same expression from an `array_merge()` call (3 places):
       {{{#!php
       $this->headers[ $key ] = array_merge( $this->headers[ $key ] ?? array(), $value );
       }}}

    **Why this is safe**

    - `??=` requires PHP 7.4, which is already the minimum supported version.
    - `??=`, `??` and `! isset()` test the same condition, so the default is used in exactly the same cases.
    - Only blocks whose body is a single assignment were changed. Any guard containing further statements was skipped, since `??=` would let those statements run unconditionally.
    - Removed guards are only those directly followed by a write into the same array, or into a property of a `stdClass` object, where PHP creates the missing container the same way.
    - No behavior change.

    Developed in https://github.com/WordPress/wordpress-develop/pull/12912.

    Props Soean, mukesh27, westonruter.
    See #65823.
    Built from https://develop.svn.wordpress.org/trunk@65317


    git-svn-id: http://core.svn.wordpress.org/trunk@64457 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 37d98dfb1c..9ba75b74bc 100644
--- a/wp-admin/includes/dashboard.php
+++ b/wp-admin/includes/dashboard.php
@@ -1502,9 +1502,7 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
 		$widget_options = array();
 	}

-	if ( ! isset( $widget_options[ $widget_id ] ) ) {
-		$widget_options[ $widget_id ] = array();
-	}
+	$widget_options[ $widget_id ] ??= array();

 	$number = 1; // Hack to use wp_widget_rss_form().

diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php
index f26d63d528..dc90feb3b3 100644
--- a/wp-admin/includes/nav-menu.php
+++ b/wp-admin/includes/nav-menu.php
@@ -1483,9 +1483,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
 	$auto_add        = ! empty( $_POST['auto-add-pages'] );
 	$nav_menu_option = (array) get_option( 'nav_menu_options' );

-	if ( ! isset( $nav_menu_option['auto_add'] ) ) {
-		$nav_menu_option['auto_add'] = array();
-	}
+	$nav_menu_option['auto_add'] ??= array();

 	if ( $auto_add ) {
 		if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ) ) {
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index a255673aad..b7ef9ec696 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -2364,9 +2364,7 @@ function get_block_editor_server_block_settings() {
 				continue;
 			}

-			if ( ! isset( $blocks[ $block_name ] ) ) {
-				$blocks[ $block_name ] = array();
-			}
+			$blocks[ $block_name ] ??= array();

 			$blocks[ $block_name ][ $key ] = $block_type->{ $field };
 		}
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 9e996fc37c..c4496dea3d 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -1098,15 +1098,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan

 	$page = $screen->id;

-	if ( ! isset( $wp_meta_boxes ) ) {
-		$wp_meta_boxes = array();
-	}
-	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
-		$wp_meta_boxes[ $page ] = array();
-	}
-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
-		$wp_meta_boxes[ $page ][ $context ] = array();
-	}
+	$wp_meta_boxes[ $page ][ $context ] ??= array();

 	foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
 		foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
@@ -1158,10 +1150,6 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
 		$priority = 'low';
 	}

-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
-		$wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
-	}
-
 	$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
 		'id'       => $id,
 		'title'    => $title,
@@ -1502,15 +1490,7 @@ function remove_meta_box( $id, $screen, $context ) {

 	$page = $screen->id;

-	if ( ! isset( $wp_meta_boxes ) ) {
-		$wp_meta_boxes = array();
-	}
-	if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
-		$wp_meta_boxes[ $page ] = array();
-	}
-	if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
-		$wp_meta_boxes[ $page ][ $context ] = array();
-	}
+	$wp_meta_boxes[ $page ][ $context ] ??= array();

 	foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
 		$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php
index 5697a6e9ff..360b51798d 100644
--- a/wp-admin/includes/widgets.php
+++ b/wp-admin/includes/widgets.php
@@ -29,9 +29,7 @@ function wp_list_widgets() {
 		$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
 		$done[]  = $widget['callback'];

-		if ( ! isset( $widget['params'][0] ) ) {
-			$widget['params'][0] = array();
-		}
+		$widget['params'][0] ??= array();

 		$args = array(
 			'widget_id'   => $widget['id'],
diff --git a/wp-includes/block-supports/anchor.php b/wp-includes/block-supports/anchor.php
index 657234f8cb..c6eceea136 100644
--- a/wp-includes/block-supports/anchor.php
+++ b/wp-includes/block-supports/anchor.php
@@ -19,9 +19,7 @@ function wp_register_anchor_support( WP_Block_Type $block_type ) {
 		return;
 	}

-	if ( ! isset( $block_type->attributes ) ) {
-		$block_type->attributes = array();
-	}
+	$block_type->attributes ??= array();

 	if ( ! array_key_exists( 'anchor', $block_type->attributes ) ) {
 		$block_type->attributes['anchor'] = array(
diff --git a/wp-includes/block-template-utils.php b/wp-includes/block-template-utils.php
index 5f829e3eab..c883ac7330 100644
--- a/wp-includes/block-template-utils.php
+++ b/wp-includes/block-template-utils.php
@@ -1802,9 +1802,6 @@ function inject_ignored_hooked_blocks_metadata_attributes( $changes, $deprecated
 		$wrapper_block         = parse_blocks( $wrapper_block_markup )[0];
 		$ignored_hooked_blocks = $wrapper_block['attrs']['metadata']['ignoredHookedBlocks'] ?? array();
 		if ( ! empty( $ignored_hooked_blocks ) ) {
-			if ( ! isset( $changes->meta_input ) ) {
-				$changes->meta_input = array();
-			}
 			$changes->meta_input['_wp_ignored_hooked_blocks'] = wp_json_encode( $ignored_hooked_blocks );
 		}
 	} else {
diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php
index 309f1db97a..ba63ddc331 100644
--- a/wp-includes/blocks.php
+++ b/wp-includes/blocks.php
@@ -979,12 +979,6 @@ function get_hooked_blocks() {
 			continue;
 		}
 		foreach ( $block_type->block_hooks as $anchor_block_type => $relative_position ) {
-			if ( ! isset( $hooked_blocks[ $anchor_block_type ] ) ) {
-				$hooked_blocks[ $anchor_block_type ] = array();
-			}
-			if ( ! isset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ) ) {
-				$hooked_blocks[ $anchor_block_type ][ $relative_position ] = array();
-			}
 			$hooked_blocks[ $anchor_block_type ][ $relative_position ][] = $block_type->name;
 		}
 	}
@@ -1490,9 +1484,6 @@ function update_ignored_hooked_blocks_postmeta( $post ) {
 			$ignored_hooked_blocks          = array_unique( array_merge( $ignored_hooked_blocks, $existing_ignored_hooked_blocks ) );
 		}

-		if ( ! isset( $post->meta_input ) ) {
-			$post->meta_input = array();
-		}
 		$post->meta_input['_wp_ignored_hooked_blocks'] = json_encode( $ignored_hooked_blocks );
 	}

diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
index 70eb1756f4..c812b4a16a 100644
--- a/wp-includes/capabilities.php
+++ b/wp-includes/capabilities.php
@@ -831,11 +831,9 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
 			}
 			$post_type_object = get_post_type_object( $object_subtype );
 			// Initialize empty array if it doesn't exist.
-			if ( ! isset( $post_type_object->capabilities ) ) {
-				$post_type_object->capabilities = array();
-			}
-			$post_type_capabilities = get_post_type_capabilities( $post_type_object );
-			$caps                   = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
+			$post_type_object->capabilities ??= array();
+			$post_type_capabilities           = get_post_type_capabilities( $post_type_object );
+			$caps                             = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
 			break;
 		default:
 			// Handle meta capabilities for custom post types.
diff --git a/wp-includes/class-wp-block-styles-registry.php b/wp-includes/class-wp-block-styles-registry.php
index 0afb410970..8e4407223c 100644
--- a/wp-includes/class-wp-block-styles-registry.php
+++ b/wp-includes/class-wp-block-styles-registry.php
@@ -116,9 +116,6 @@ final class WP_Block_Styles_Registry {
 		}

 		foreach ( $block_names as $name ) {
-			if ( ! isset( $this->registered_block_styles[ $name ] ) ) {
-				$this->registered_block_styles[ $name ] = array();
-			}
 			$this->registered_block_styles[ $name ][ $block_style_name ] = $style_properties;
 		}

diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php
index 0185684735..9ee2054c79 100644
--- a/wp-includes/class-wp-customize-manager.php
+++ b/wp-includes/class-wp-customize-manager.php
@@ -2823,9 +2823,7 @@ final class WP_Customize_Manager {

 		// Ensure that all post values are included in the changeset data.
 		foreach ( $post_values as $setting_id => $post_value ) {
-			if ( ! isset( $args['data'][ $setting_id ] ) ) {
-				$args['data'][ $setting_id ] = array();
-			}
+			$args['data'][ $setting_id ] ??= array();
 			if ( ! isset( $args['data'][ $setting_id ]['value'] ) ) {
 				$args['data'][ $setting_id ]['value'] = $post_value;
 			}
@@ -2852,9 +2850,7 @@ final class WP_Customize_Manager {
 				unset( $data[ $changeset_setting_id ] );
 			} else {

-				if ( ! isset( $data[ $changeset_setting_id ] ) ) {
-					$data[ $changeset_setting_id ] = array();
-				}
+				$data[ $changeset_setting_id ] ??= array();

 				// Merge any additional setting params that have been supplied with the existing params.
 				$merged_setting_params = array_merge( $data[ $changeset_setting_id ], $setting_params );
@@ -3522,9 +3518,6 @@ final class WP_Customize_Manager {
 				preg_match( $namespace_pattern, $raw_setting_id, $matches )
 			);
 			if ( $is_theme_mod_setting ) {
-				if ( ! isset( $theme_mod_settings[ $matches['stylesheet'] ] ) ) {
-					$theme_mod_settings[ $matches['stylesheet'] ] = array();
-				}
 				$theme_mod_settings[ $matches['stylesheet'] ][ $matches['setting_id'] ] = $setting_params;

 				if ( $this->get_stylesheet() === $matches['stylesheet'] ) {
@@ -3671,9 +3664,7 @@ final class WP_Customize_Manager {

 		// Merge inactive theme mods with the stashed theme mod settings.
 		foreach ( $inactive_theme_mod_settings as $stylesheet => $theme_mod_settings ) {
-			if ( ! isset( $stashed_theme_mod_settings[ $stylesheet ] ) ) {
-				$stashed_theme_mod_settings[ $stylesheet ] = array();
-			}
+			$stashed_theme_mod_settings[ $stylesheet ] ??= array();

 			$stashed_theme_mod_settings[ $stylesheet ] = array_merge(
 				$stashed_theme_mod_settings[ $stylesheet ],
diff --git a/wp-includes/class-wp-customize-nav-menus.php b/wp-includes/class-wp-customize-nav-menus.php
index 07b2742264..b093509f2f 100644
--- a/wp-includes/class-wp-customize-nav-menus.php
+++ b/wp-includes/class-wp-customize-nav-menus.php
@@ -977,9 +977,6 @@ final class WP_Customize_Nav_Menus {
 		if ( empty( $postarr['post_name'] ) ) {
 			$postarr['post_name'] = sanitize_title( $postarr['post_title'] );
 		}
-		if ( ! isset( $postarr['meta_input'] ) ) {
-			$postarr['meta_input'] = array();
-		}
 		$postarr['meta_input']['_customize_draft_post_name'] = $postarr['post_name'];
 		$postarr['meta_input']['_customize_changeset_uuid']  = $this->manager->changeset_uuid();
 		unset( $postarr['post_name'] );
diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php
index 68dd8b1433..2658eb20fd 100644
--- a/wp-includes/class-wp-customize-setting.php
+++ b/wp-includes/class-wp-customize-setting.php
@@ -248,9 +248,7 @@ class WP_Customize_Setting {
 	 */
 	protected function aggregate_multidimensional() {
 		$id_base = $this->id_data['base'];
-		if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
-			self::$aggregated_multidimensionals[ $this->type ] = array();
-		}
+		self::$aggregated_multidimensionals[ $this->type ] ??= array();
 		if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) {
 			self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array(
 				'previewed_instances'       => array(), // Calling preview() will add the $setting to the array.
@@ -887,9 +885,7 @@ class WP_Customize_Setting {
 				// Account for an array overriding a string or object value.
 				$node = array();
 			}
-			if ( ! isset( $node[ $last ] ) ) {
-				$node[ $last ] = array();
-			}
+			$node[ $last ] ??= array();
 		}

 		if ( ! isset( $node[ $last ] ) ) {
diff --git a/wp-includes/class-wp-customize-widgets.php b/wp-includes/class-wp-customize-widgets.php
index d7cd0d5de1..dc45b3fb02 100644
--- a/wp-includes/class-wp-customize-widgets.php
+++ b/wp-includes/class-wp-customize-widgets.php
@@ -1082,9 +1082,7 @@ final class WP_Customize_Widgets {
 			$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
 			$done[]  = $widget['callback'];

-			if ( ! isset( $widget['params'][0] ) ) {
-				$widget['params'][0] = array();
-			}
+			$widget['params'][0] ??= array();

 			$available_widget = $widget;
 			unset( $available_widget['callback'] ); // Not serializable to JSON.
@@ -1887,11 +1885,8 @@ final class WP_Customize_Widgets {
 	 */
 	public function filter_wp_kses_allowed_data_attributes( $allowed_html ) {
 		foreach ( array_keys( $this->before_widget_tags_seen ) as $tag_name ) {
-			if ( ! isset( $allowed_html[ $tag_name ] ) ) {
-				$allowed_html[ $tag_name ] = array();
-			}
 			$allowed_html[ $tag_name ] = array_merge(
-				$allowed_html[ $tag_name ],
+				$allowed_html[ $tag_name ] ?? array(),
 				array_fill_keys(
 					array(
 						'data-customize-partial-id',
diff --git a/wp-includes/class-wp-duotone.php b/wp-includes/class-wp-duotone.php
index b254e3c95b..3b90f36cc5 100644
--- a/wp-includes/class-wp-duotone.php
+++ b/wp-includes/class-wp-duotone.php
@@ -1279,9 +1279,7 @@ class WP_Duotone {
 	public static function add_editor_settings( $settings ) {
 		$global_styles_presets = self::get_all_global_styles_presets();
 		if ( ! empty( $global_styles_presets ) ) {
-			if ( ! isset( $settings['styles'] ) ) {
-				$settings['styles'] = array();
-			}
+			$settings['styles'] ??= array();

 			$settings['styles'][] = array(
 				// For the editor we can add all of the presets by default.
diff --git a/wp-includes/class-wp-speculation-rules.php b/wp-includes/class-wp-speculation-rules.php
index 45e6f3ff0b..11794c83b8 100644
--- a/wp-includes/class-wp-speculation-rules.php
+++ b/wp-includes/class-wp-speculation-rules.php
@@ -204,9 +204,7 @@ final class WP_Speculation_Rules implements JsonSerializable {
 			}
 		}

-		if ( ! isset( $this->rules_by_mode[ $mode ] ) ) {
-			$this->rules_by_mode[ $mode ] = array();
-		}
+		$this->rules_by_mode[ $mode ] ??= array();

 		$this->rules_by_mode[ $mode ][ $id ] = $rule;
 		return true;
diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php
index 9027c779a7..a4bfbe86df 100644
--- a/wp-includes/class-wp-theme-json.php
+++ b/wp-includes/class-wp-theme-json.php
@@ -2693,9 +2693,7 @@ class WP_Theme_JSON {

 				$target = self::get_feature_selector( $feature_selectors, $preset_metadata['path'][0], $selector );

-				if ( ! isset( $vars_by_selector[ $target ] ) ) {
-					$vars_by_selector[ $target ] = array();
-				}
+				$vars_by_selector[ $target ] ??= array();

 				foreach ( $values_by_slug as $slug => $value ) {
 					$vars_by_selector[ $target ][] = array(
diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php
index 109cfa8cdb..47ec3db919 100644
--- a/wp-includes/class-wp-theme.php
+++ b/wp-includes/class-wp-theme.php
@@ -1394,10 +1394,8 @@ final class WP_Theme implements ArrayAccess {
 				}

 				foreach ( $types as $type ) {
-					$type = sanitize_key( $type );
-					if ( ! isset( $post_templates[ $type ] ) ) {
-						$post_templates[ $type ] = array();
-					}
+					$type                      = sanitize_key( $type );
+					$post_templates[ $type ] ??= array();

 					$post_templates[ $type ][ $file ] = $headers['TemplateName'];
 				}
diff --git a/wp-includes/class-wp-token-map.php b/wp-includes/class-wp-token-map.php
index 2b463427fb..19f9e9a3df 100644
--- a/wp-includes/class-wp-token-map.php
+++ b/wp-includes/class-wp-token-map.php
@@ -314,9 +314,7 @@ class WP_Token_Map {
 			} else {
 				$group = substr( $word, 0, $key_length );

-				if ( ! isset( $groups[ $group ] ) ) {
-					$groups[ $group ] = array();
-				}
+				$groups[ $group ] ??= array();

 				$groups[ $group ][] = array( substr( $word, $key_length ), $mapping );
 			}
diff --git a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
index aca7619a6b..de6c6a1fe1 100644
--- a/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
+++ b/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
@@ -902,9 +902,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
 	 * @return array Save response data.
 	 */
 	public function amend_customize_save_response( $data ) {
-		if ( ! isset( $data['nav_menu_item_updates'] ) ) {
-			$data['nav_menu_item_updates'] = array();
-		}
+		$data['nav_menu_item_updates'] ??= array();

 		$data['nav_menu_item_updates'][] = array(
 			'post_id'          => $this->post_id,
diff --git a/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/wp-includes/customize/class-wp-customize-nav-menu-setting.php
index 138ab8806e..83489d21cf 100644
--- a/wp-includes/customize/class-wp-customize-nav-menu-setting.php
+++ b/wp-includes/customize/class-wp-customize-nav-menu-setting.php
@@ -601,10 +601,8 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
 	 * @return array (Maybe) modified nav_menu_options array.
 	 */
 	protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $auto_add ) {
-		$nav_menu_options = (array) $nav_menu_options;
-		if ( ! isset( $nav_menu_options['auto_add'] ) ) {
-			$nav_menu_options['auto_add'] = array();
-		}
+		$nav_menu_options               = (array) $nav_menu_options;
+		$nav_menu_options['auto_add'] ??= array();

 		$i = array_search( $menu_id, $nav_menu_options['auto_add'], true );

@@ -628,12 +626,8 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting {
 	 * @return array Export data.
 	 */
 	public function amend_customize_save_response( $data ) {
-		if ( ! isset( $data['nav_menu_updates'] ) ) {
-			$data['nav_menu_updates'] = array();
-		}
-		if ( ! isset( $data['widget_nav_menu_updates'] ) ) {
-			$data['widget_nav_menu_updates'] = array();
-		}
+		$data['nav_menu_updates']        ??= array();
+		$data['widget_nav_menu_updates'] ??= array();

 		$data['nav_menu_updates'][] = array(
 			'term_id'          => $this->term_id,
diff --git a/wp-includes/customize/class-wp-widget-form-customize-control.php b/wp-includes/customize/class-wp-widget-form-customize-control.php
index cfab188606..3ac0e69969 100644
--- a/wp-includes/customize/class-wp-widget-form-customize-control.php
+++ b/wp-includes/customize/class-wp-widget-form-customize-control.php
@@ -98,10 +98,8 @@ class WP_Widget_Form_Customize_Control extends WP_Customize_Control {
 		// Get the widget_control and widget_content.
 		require_once ABSPATH . 'wp-admin/includes/widgets.php';

-		$widget = $wp_registered_widgets[ $this->widget_id ];
-		if ( ! isset( $widget['params'][0] ) ) {
-			$widget['params'][0] = array();
-		}
+		$widget                = $wp_registered_widgets[ $this->widget_id ];
+		$widget['params'][0] ??= array();

 		$args = array(
 			'widget_id'   => $widget['id'],
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index f91680a9ef..3344738229 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -5200,9 +5200,7 @@ function paginate_links( $args = '' ) {
 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
 	global $_wp_admin_css_colors;

-	if ( ! isset( $_wp_admin_css_colors ) ) {
-		$_wp_admin_css_colors = array();
-	}
+	$_wp_admin_css_colors ??= array();

 	$_wp_admin_css_colors[ $key ] = (object) array(
 		'name'        => $name,
diff --git a/wp-includes/interactivity-api/class-wp-interactivity-api.php b/wp-includes/interactivity-api/class-wp-interactivity-api.php
index d8f11e2d05..5cdcffd14d 100644
--- a/wp-includes/interactivity-api/class-wp-interactivity-api.php
+++ b/wp-includes/interactivity-api/class-wp-interactivity-api.php
@@ -218,9 +218,7 @@ final class WP_Interactivity_API {

 			$store_namespace = end( $this->namespace_stack );
 		}
-		if ( ! isset( $this->state_data[ $store_namespace ] ) ) {
-			$this->state_data[ $store_namespace ] = array();
-		}
+		$this->state_data[ $store_namespace ] ??= array();
 		if ( is_array( $state ) ) {
 			$this->state_data[ $store_namespace ] = array_replace_recursive(
 				$this->state_data[ $store_namespace ],
@@ -246,9 +244,7 @@ final class WP_Interactivity_API {
 	 *               $config argument was provided.
 	 */
 	public function config( string $store_namespace, array $config = array() ): array {
-		if ( ! isset( $this->config_data[ $store_namespace ] ) ) {
-			$this->config_data[ $store_namespace ] = array();
-		}
+		$this->config_data[ $store_namespace ] ??= array();
 		if ( is_array( $config ) ) {
 			$this->config_data[ $store_namespace ] = array_replace_recursive(
 				$this->config_data[ $store_namespace ],
@@ -286,9 +282,6 @@ final class WP_Interactivity_API {
 	 * @return array Data for the Interactivity Router script module.
 	 */
 	public function filter_script_module_interactivity_router_data( array $data ): array {
-		if ( ! isset( $data['i18n'] ) ) {
-			$data['i18n'] = array();
-		}
 		$data['i18n']['loading'] = __( 'Loading page, please wait.' );
 		$data['i18n']['loaded']  = __( 'Page Loaded.' );
 		return $data;
diff --git a/wp-includes/l10n/class-wp-translation-controller.php b/wp-includes/l10n/class-wp-translation-controller.php
index 60ccab87dd..f04849fea3 100644
--- a/wp-includes/l10n/class-wp-translation-controller.php
+++ b/wp-includes/l10n/class-wp-translation-controller.php
@@ -130,9 +130,7 @@ final class WP_Translation_Controller {
 			return false;
 		}

-		if ( ! isset( $this->loaded_translations[ $locale ][ $textdomain ] ) ) {
-			$this->loaded_translations[ $locale ][ $textdomain ] = array();
-		}
+		$this->loaded_translations[ $locale ][ $textdomain ] ??= array();

 		$this->loaded_translations[ $locale ][ $textdomain ][] = $moe;

diff --git a/wp-includes/meta.php b/wp-includes/meta.php
index e67429e44a..437737804f 100644
--- a/wp-includes/meta.php
+++ b/wp-includes/meta.php
@@ -1288,10 +1288,8 @@ function update_meta_cache( $meta_type, $object_ids ) {

 	$data = array();
 	foreach ( $non_cached_ids as $id ) {
-		if ( ! isset( $cache[ $id ] ) ) {
-			$cache[ $id ] = array();
-		}
-		$data[ $id ] = $cache[ $id ];
+		$cache[ $id ] ??= array();
+		$data[ $id ]    = $cache[ $id ];
 	}

 	wp_cache_add_multiple( $data, $cache_group );
diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
index 38c5884c8b..b35f7a9944 100644
--- a/wp-includes/plugin.php
+++ b/wp-includes/plugin.php
@@ -43,17 +43,11 @@ if ( $wp_filter ) {
 	$wp_filter = array();
 }

-if ( ! isset( $wp_actions ) ) {
-	$wp_actions = array();
-}
+$wp_actions ??= array();

-if ( ! isset( $wp_filters ) ) {
-	$wp_filters = array();
-}
+$wp_filters ??= array();

-if ( ! isset( $wp_current_filter ) ) {
-	$wp_current_filter = array();
-}
+$wp_current_filter ??= array();

 /**
  * Adds a callback function to a filter hook.
diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php
index 7773a40aaf..5efb16b28f 100644
--- a/wp-includes/rest-api/class-wp-rest-request.php
+++ b/wp-includes/rest-api/class-wp-rest-request.php
@@ -325,11 +325,7 @@ class WP_REST_Request implements ArrayAccess {
 		$key   = static::canonicalize_header_name( $key );
 		$value = (array) $value;

-		if ( ! isset( $this->headers[ $key ] ) ) {
-			$this->headers[ $key ] = array();
-		}
-
-		$this->headers[ $key ] = array_merge( $this->headers[ $key ], $value );
+		$this->headers[ $key ] = array_merge( $this->headers[ $key ] ?? array(), $value );
 	}

 	/**
diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php
index 612b00e780..be4af523d3 100644
--- a/wp-includes/rest-api/class-wp-rest-server.php
+++ b/wp-includes/rest-api/class-wp-rest-server.php
@@ -1066,9 +1066,7 @@ class WP_REST_Server {
 				$handlers = array( $handlers );
 			}

-			if ( ! isset( $this->route_options[ $route ] ) ) {
-				$this->route_options[ $route ] = array();
-			}
+			$this->route_options[ $route ] ??= array();

 			foreach ( $handlers as $key => &$handler ) {

diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
index bc6ba492a3..0277a7dd44 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
@@ -2253,9 +2253,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
 		foreach ( get_allowed_mime_types() as $mime_type ) {
 			$parts = explode( '/', $mime_type );

-			if ( ! isset( $media_types[ $parts[0] ] ) ) {
-				$media_types[ $parts[0] ] = array();
-			}
+			$media_types[ $parts[0] ] ??= array();

 			$media_types[ $parts[0] ][] = $mime_type;
 		}
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php
index 706e36fb6c..887662e06a 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php
@@ -436,9 +436,7 @@ class WP_REST_Menus_Controller extends WP_REST_Terms_Controller {

 		$nav_menu_option = (array) get_option( 'nav_menu_options', array( 'auto_add' => array() ) );

-		if ( ! isset( $nav_menu_option['auto_add'] ) ) {
-			$nav_menu_option['auto_add'] = array();
-		}
+		$nav_menu_option['auto_add'] ??= array();

 		$auto_add = $request['auto_add'];

diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index 6656a2f8e3..c267d56de2 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -3731,10 +3731,7 @@ function wp_update_term_count( $terms, $taxonomy, $do_deferred = false ) {
 	}

 	if ( wp_defer_term_counting() ) {
-		if ( ! isset( $_deferred[ $taxonomy ] ) ) {
-			$_deferred[ $taxonomy ] = array();
-		}
-		$_deferred[ $taxonomy ] = array_unique( array_merge( $_deferred[ $taxonomy ], $terms ) );
+		$_deferred[ $taxonomy ] = array_unique( array_merge( $_deferred[ $taxonomy ] ?? array(), $terms ) );
 		return true;
 	}

@@ -4037,9 +4034,6 @@ function update_object_term_cache( $object_ids, $object_type ) {
 	foreach ( $non_cached_ids as $id ) {
 		foreach ( $taxonomies as $taxonomy ) {
 			if ( ! isset( $object_terms[ $id ][ $taxonomy ] ) ) {
-				if ( ! isset( $object_terms[ $id ] ) ) {
-					$object_terms[ $id ] = array();
-				}
 				$object_terms[ $id ][ $taxonomy ] = array();
 			}
 		}
@@ -4529,10 +4523,8 @@ function _split_shared_term( $term_id, $term_taxonomy_id, $record = true ) {

 	// Keep a record of term_ids that have been split, keyed by old term_id. See wp_get_split_term().
 	if ( $record ) {
-		$split_term_data = get_option( '_split_terms', array() );
-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
-			$split_term_data[ $term_id ] = array();
-		}
+		$split_term_data               = get_option( '_split_terms', array() );
+		$split_term_data[ $term_id ] ??= array();

 		$split_term_data[ $term_id ][ $term_taxonomy->taxonomy ] = $new_term_id;
 		update_option( '_split_terms', $split_term_data );
@@ -4637,9 +4629,7 @@ function _wp_batch_split_terms() {
 			continue;
 		}

-		if ( ! isset( $split_term_data[ $term_id ] ) ) {
-			$split_term_data[ $term_id ] = array();
-		}
+		$split_term_data[ $term_id ] ??= array();

 		// Keep track of taxonomies whose hierarchies need flushing.
 		if ( ! isset( $taxonomies[ $shared_tt->taxonomy ] ) ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 4cc2b7e07e..c072086d61 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-beta4-65316';
+$wp_version = '7.2-beta4-65317';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.