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
This commit is contained in:
hellofromTonya 2021-09-09 14:48:55 +00:00
parent 071c322bf2
commit 6a19a16872
4 changed files with 9 additions and 5 deletions

View File

@ -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' );

View File

@ -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 = '';
}

View File

@ -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;

View File

@ -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.