Make WordPress Core

Changeset 51785


Ignore:
Timestamp:
09/09/2021 03:17:20 PM (3 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-custom-css-setting.php

    r51784 r51785  
    146146
    147147    /**
    148      * Validate CSS.
     148     * Validate a received value for being valid CSS.
    149149     *
    150150     * Checks for imbalanced braces, brackets, and comments.
     
    153153     * @since 4.7.0
    154154     * @since 4.9.0 Checking for balanced characters has been moved client-side via linting in code editor.
    155      *
    156      * @param string $css The input string.
     155     * @since 5.9.0 Renamed `$css` to `$value` for PHP 8 named parameter support.
     156     *
     157     * @param string $value CSS to validate.
    157158     * @return true|WP_Error True if the input was validated, otherwise WP_Error.
    158159     */
    159     public function validate( $css ) {
     160    public function validate( $value ) {
     161        // Restores the more descriptive, specific name for use within this method.
     162        $css = $value;
     163
    160164        $validity = new WP_Error();
    161165
Note: See TracChangeset for help on using the changeset viewer.