Make WordPress Core


Ignore:
Timestamp:
03/27/2022 02:53:21 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/class-theme-upgrader.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the $return variable in Theme_Upgrader class methods to $response and updates the documentation accordingly.

Follow-up to [47409], [52946], [52996], [52997].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

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

    r52978 r52998  
    617617         * @since 2.8.0
    618618         *
    619          * @param bool|WP_Error $return Upgrade offer return.
    620          * @param array         $theme  Theme arguments.
    621          * @return bool|WP_Error The passed in $return param or WP_Error.
    622          */
    623         public function current_before( $return, $theme ) {
    624                 if ( is_wp_error( $return ) ) {
    625                         return $return;
     619         * @param bool|WP_Error $response The installation response before the installation has started.
     620         * @param array         $theme    Theme arguments.
     621         * @return bool|WP_Error The original `$response` parameter or WP_Error.
     622         */
     623        public function current_before( $response, $theme ) {
     624                if ( is_wp_error( $response ) ) {
     625                        return $response;
    626626                }
    627627
    628628                $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
    629629
    630                 // Only run if active theme
     630                // Only run if active theme.
    631631                if ( get_stylesheet() !== $theme ) {
    632                         return $return;
     632                        return $response;
    633633                }
    634634
    … …  
    638638                }
    639639
    640                 return $return;
     640                return $response;
    641641        }
    642642
    … …  
    649649         * @since 2.8.0
    650650         *
    651          * @param bool|WP_Error $return Upgrade offer return.
    652          * @param array         $theme  Theme arguments.
    653          * @return bool|WP_Error The passed in $return param or WP_Error.
    654          */
    655         public function current_after( $return, $theme ) {
    656                 if ( is_wp_error( $return ) ) {
    657                         return $return;
     651         * @param bool|WP_Error $response The installation response after the installation has finished.
     652         * @param array         $theme    Theme arguments.
     653         * @return bool|WP_Error The original `$response` parameter or WP_Error.
     654         */
     655        public function current_after( $response, $theme ) {
     656                if ( is_wp_error( $response ) ) {
     657                        return $response;
    658658                }
    659659
    … …  
    662662                // Only run if active theme.
    663663                if ( get_stylesheet() !== $theme ) {
    664                         return $return;
     664                        return $response;
    665665                }
    666666
    … …  
    676676                        $this->maintenance_mode( false );
    677677                }
    678                 return $return;
     678                return $response;
    679679        }
    680680
Note: See TracChangeset for help on using the changeset viewer.