Make WordPress Core


Ignore:
Timestamp:
09/09/2021 01:47:17 PM (3 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-automatic-upgrader-skin.php

    r50828 r51781  
    6767     *
    6868     * @since 3.7.0
     69     * @since 5.9.0 Renamed `$data` to `$feedback` for PHP 8 named parameter support.
    6970     *
    70      * @param string|array|WP_Error $data    Message data.
    71      * @param mixed                 ...$args Optional text replacements.
     71     * @param string|array|WP_Error $feedback Message data.
     72     * @param mixed                 ...$args  Optional text replacements.
    7273     */
    73     public function feedback( $data, ...$args ) {
    74         if ( is_wp_error( $data ) ) {
    75             $string = $data->get_error_message();
    76         } elseif ( is_array( $data ) ) {
     74    public function feedback( $feedback, ...$args ) {
     75        if ( is_wp_error( $feedback ) ) {
     76            $string = $feedback->get_error_message();
     77        } elseif ( is_array( $feedback ) ) {
    7778            return;
    7879        } else {
    79             $string = $data;
     80            $string = $feedback;
    8081        }
     82
    8183        if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
    8284            $string = $this->upgrader->strings[ $string ];
Note: See TracChangeset for help on using the changeset viewer.