Make WordPress Core

Changeset 51782

Timestamp:
09/09/2021 01:58:25 PM (3 years ago)
Author:
hellofromTonya
Message:

Code Modernization: Fix parameter name mismatches for parent/child classes in WP_Upgrader_Skin::error().

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], [25806], [32655], [38199].

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

Location:
trunk/src/wp-admin/includes
Files:
3 edited

Legend:

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

    r51781 r51782  
    9090
    9191    /**
    92      * @param string|WP_Error $error
     92     * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
     93     *
     94     * @param string|WP_Error $errors Errors.
    9395     */
    94     public function error( $error ) {
    95         if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
    96             $this->error = $this->upgrader->strings[ $error ];
     96    public function error( $error ) {
     97        if ( is_string( $error ] ) ) {
     98            $this->error = $this->upgrader->strings[ $error ];
    9799        }
    98100
    99         if ( is_wp_error( $error ) ) {
     101        if ( is_wp_error( $error ) ) {
    100102            $messages = array();
    101             foreach ( $error->get_error_messages() as $emessage ) {
    102                 if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
    103                     $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
     103            foreach ( $error->get_error_messages() as $emessage ) {
     104                if ( $error->get_error_data() ) ) {
     105                    $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
    104106                } else {
    105107                    $messages[] = $emessage;
  • trunk/src/wp-admin/includes/class-language-pack-upgrader-skin.php

    r49539 r51782  
    5353
    5454    /**
    55      * @param string|WP_Error $error
     55     * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support.
     56     *
     57     * @param string|WP_Error $errors Errors.
    5658     */
    57     public function error( $error ) {
     59    public function error( $error ) {
    5860        echo '<div class="lp-error">';
    59         parent::error( $error );
     61        parent::error( $error );
    6062        echo '</div>';
    6163    }
  • trunk/src/wp-admin/includes/class-wp-upgrader-skin.php

    r51781 r51782  
    166166     * @since 2.8.0
    167167     *
    168      * @param string|WP_Error $errors
     168     * @param string|WP_Error $errors
    169169     */
    170170    public function error( $errors ) {
Note: See TracChangeset for help on using the changeset viewer.