Code Quality: Replace void with null in union return types in Customizer classes.

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

Follow-up to r61766, r61719, r61716.

Props apermo, xate, mukesh27.
See #64238.
Fixes #64701.

Built from https://develop.svn.wordpress.org/trunk@61767


git-svn-id: http://core.svn.wordpress.org/trunk@61073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2026-02-27 23:18:40 +00:00
parent 6f57b82460
commit 98b788bf5d
5 changed files with 16 additions and 16 deletions

View File

@@ -3863,7 +3863,7 @@ final class WP_Customize_Manager {
* @since 3.4.0
*
* @param string $id Customize Setting ID.
* @return WP_Customize_Setting|void The setting, if set.
* @return WP_Customize_Setting|null The setting, if set.
*/
public function get_setting( $id ) {
if ( isset( $this->settings[ $id ] ) ) {
@@ -3915,7 +3915,7 @@ final class WP_Customize_Manager {
* @since 4.0.0
*
* @param string $id Panel ID to get.
* @return WP_Customize_Panel|void Requested panel instance, if set.
* @return WP_Customize_Panel|null Requested panel instance, if set.
*/
public function get_panel( $id ) {
if ( isset( $this->panels[ $id ] ) ) {
@@ -4011,7 +4011,7 @@ final class WP_Customize_Manager {
* @since 3.4.0
*
* @param string $id Section ID.
* @return WP_Customize_Section|void The section, if set.
* @return WP_Customize_Section|null The section, if set.
*/
public function get_section( $id ) {
if ( isset( $this->sections[ $id ] ) ) {
@@ -4090,7 +4090,7 @@ final class WP_Customize_Manager {
* @since 3.4.0
*
* @param string $id ID of the control.
* @return WP_Customize_Control|void The control object, if set.
* @return WP_Customize_Control|null The control object, if set.
*/
public function get_control( $id ) {
if ( isset( $this->controls[ $id ] ) ) {

View File

@@ -856,7 +856,7 @@ class WP_Customize_Setting {
* @param array $root
* @param array $keys
* @param bool $create Default false.
* @return array|void Keys are 'root', 'node', and 'key'.
* @return array|null Keys are 'root', 'node', and 'key'.
*/
final protected function multidimensional( &$root, $keys, $create = false ) {
if ( $create && empty( $root ) ) {
@@ -864,7 +864,7 @@ class WP_Customize_Setting {
}
if ( ! isset( $root ) || empty( $keys ) ) {
return;
return null;
}
$last = array_pop( $keys );
@@ -876,7 +876,7 @@ class WP_Customize_Setting {
}
if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) {
return;
return null;
}
$node = &$node[ $key ];
@@ -893,7 +893,7 @@ class WP_Customize_Setting {
}
if ( ! isset( $node[ $last ] ) ) {
return;
return null;
}
return array(

View File

@@ -176,7 +176,7 @@ final class WP_Customize_Widgets {
* @since 4.2.0
*
* @param string $setting_id Setting ID.
* @return string|void Setting type.
* @return string|null Setting type.
*/
protected function get_setting_type( $setting_id ) {
static $cache = array();
@@ -1454,7 +1454,7 @@ final class WP_Customize_Widgets {
*
* @param array $value Widget instance to sanitize.
* @param string $id_base Optional. Base of the ID of the widget being sanitized. Default null.
* @return array|void Sanitized widget instance.
* @return array|null Sanitized widget instance.
*/
public function sanitize_widget_instance( $value, $id_base = null ) {
global $wp_widget_factory;
@@ -1483,21 +1483,21 @@ final class WP_Customize_Widgets {
empty( $value['instance_hash_key'] ) ||
empty( $value['encoded_serialized_instance'] )
) {
return;
return null;
}
$decoded = base64_decode( $value['encoded_serialized_instance'], true );
if ( false === $decoded ) {
return;
return null;
}
if ( ! hash_equals( $this->get_instance_hash_key( $decoded ), $value['instance_hash_key'] ) ) {
return;
return null;
}
$instance = unserialize( $decoded );
if ( false === $instance ) {
return;
return null;
}
return $instance;

View File

@@ -193,7 +193,7 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
*
* @since 3.9.0
*
* @return string|void
* @return string|null
*/
public function get_current_image_src() {
$src = $this->value();

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-beta2-61766';
$wp_version = '7.0-beta2-61767';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.