From 6a19a168727d5299103038dd2af41ecb422bdd36 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 9 Sep 2021 14:48:55 +0000 Subject: [PATCH] Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_Customize_Setting::update()`. In each child class: renames the parameter to match the parent's method signature. Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match. Changes for readability: - `@since` clearly specifies the original parameter name and its new name as well as why the change happened. - In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made. Follow-up to [19995], [21037], [21053], [21354], [38829], [51298]. Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion. See #51553. Built from https://develop.svn.wordpress.org/trunk@51784 git-svn-id: http://core.svn.wordpress.org/trunk@51391 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-customize-background-image-setting.php | 2 +- .../customize/class-wp-customize-custom-css-setting.php | 8 ++++++-- .../customize/class-wp-customize-header-image-setting.php | 2 +- wp-includes/version.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/customize/class-wp-customize-background-image-setting.php b/wp-includes/customize/class-wp-customize-background-image-setting.php index 96b69a022d..b8b1a06a9d 100644 --- a/wp-includes/customize/class-wp-customize-background-image-setting.php +++ b/wp-includes/customize/class-wp-customize-background-image-setting.php @@ -20,7 +20,7 @@ final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting { /** * @since 3.4.0 * - * @param mixed $value + * @param mixed $value The value to update. Not used. */ public function update( $value ) { remove_theme_mod( 'background_image_thumb' ); diff --git a/wp-includes/customize/class-wp-customize-custom-css-setting.php b/wp-includes/customize/class-wp-customize-custom-css-setting.php index 39750f864c..b0fd89540b 100644 --- a/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -173,11 +173,15 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { * Store the CSS setting value in the custom_css custom post type for the stylesheet. * * @since 4.7.0 + * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support. * - * @param string $css The input value. + * @param string $value CSS to update. * @return int|false The post ID or false if the value could not be saved. */ - public function update( $css ) { + public function update( $value ) { + // Restores the more descriptive, specific name for use within this method. + $css = $value; + if ( empty( $css ) ) { $css = ''; } diff --git a/wp-includes/customize/class-wp-customize-header-image-setting.php b/wp-includes/customize/class-wp-customize-header-image-setting.php index a45193f76e..7bbc923a40 100644 --- a/wp-includes/customize/class-wp-customize-header-image-setting.php +++ b/wp-includes/customize/class-wp-customize-header-image-setting.php @@ -24,7 +24,7 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { * * @global Custom_Image_Header $custom_image_header * - * @param mixed $value + * @param mixed $value The value to update. */ public function update( $value ) { global $custom_image_header; diff --git a/wp-includes/version.php b/wp-includes/version.php index 5af58b02b0..860fde97ec 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51783'; +$wp_version = '5.9-alpha-51784'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.