Make WordPress Core


Ignore:
Timestamp:
09/09/2021 01:47:17 PM (4 years ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in WP_Upgrader_Skin::feedback().

In the parent class, renames the parameter $string to $feedback.
Why? string is a PHP reserved keyword.

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.

Follow-up to [11005], [25228], [30680], [32655], [38199], [49596].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ajax-upgrader-skin.php

    r49596 r51781  
    122122     * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
    123123     *              to the function signature.
     124     * @since 5.9.0 Renamed `$data` to `$feedback` for PHP 8 named parameter support.
    124125     *
    125      * @param string|array|WP_Error $data    Message data.
    126      * @param mixed                 ...$args Optional text replacements.
     126     * @param string|array|WP_Error $feedback Message data.
     127     * @param mixed                 ...$args  Optional text replacements.
    127128     */
    128     public function feedback( $data, ...$args ) {
    129         if ( is_wp_error( $data ) ) {
    130             foreach ( $data->get_error_codes() as $error_code ) {
    131                 $this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) );
     129    public function feedback( $feedback, ...$args ) {
     130        if ( is_wp_error( $feedback ) ) {
     131            foreach ( $feedback->get_error_codes() as $error_code ) {
     132                $this->errors->add( $error_code, $feedback->get_error_message( $error_code ), $feedback->get_error_data( $error_code ) );
    132133            }
    133134        }
    134135
    135         parent::feedback( $data, ...$args );
     136        parent::feedback( $feedback, ...$args );
    136137    }
    137138}
Note: See TracChangeset for help on using the changeset viewer.