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
This commit is contained in:
hellofromTonya 2021-09-09 15:18:55 +00:00
parent 6a19a16872
commit aaee916444
2 changed files with 8 additions and 4 deletions

View File

@ -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( '#</?\w+#', $css ) ) {

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51784';
$wp_version = '5.9-alpha-51785';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.