From aaee9164441da368bf6d0d5c2639ac8ae96d9456 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 9 Sep 2021 15:18:55 +0000 Subject: [PATCH] Code Modernization: Fix parameter name mismatch with parent in `WP_Customize_Custom_CSS_Setting::validate()`. 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. Adds `@since` to clearly specify why the change happened. Reassigns the generic parameter to the original parameter. Why? Restoring the original name keeps the context intact within the method and makes the code more readable. An inline comment explains why this reassignment is made Follow-up to [37476], [38829], [41376]. Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion. See #51553. Built from https://develop.svn.wordpress.org/trunk@51785 git-svn-id: http://core.svn.wordpress.org/trunk@51392 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-customize-custom-css-setting.php | 10 +++++++--- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) 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 b0fd89540b..0e6132f339 100644 --- a/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -145,18 +145,22 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting { } /** - * Validate CSS. + * Validate a received value for being valid CSS. * * Checks for imbalanced braces, brackets, and comments. * Notifications are rendered when the customizer state is saved. * * @since 4.7.0 * @since 4.9.0 Checking for balanced characters has been moved client-side via linting in code editor. + * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support. * - * @param string $css The input string. + * @param string $value CSS to validate. * @return true|WP_Error True if the input was validated, otherwise WP_Error. */ - public function validate( $css ) { + public function validate( $value ) { + // Restores the more descriptive, specific name for use within this method. + $css = $value; + $validity = new WP_Error(); if ( preg_match( '#