WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/15/2019 10:41:03 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Code Modernisation: Introduce the spread operator in wp-admin/includes/class-*-upgrader-skin.php.

Rather than relying func_get_args() to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Props jrf.
See #47678.

File:
1 edited

Legend:

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

    r45487 r46125  
    7979     * @since 4.6.0
    8080     *
    81      * @param string|WP_Error $errors Errors.
     81     * @param string|WP_Error $errors  Errors.
     82     * @param mixed           ...$args Optional text replacements.
    8283     */
    83     public function error( $errors ) {
     84    public function error( $errors, ...$args ) {
    8485        if ( is_string( $errors ) ) {
    8586            $string = $errors;
     
    8990
    9091            if ( false !== strpos( $string, '%' ) ) {
    91                 $args = func_get_args();
    92                 $args = array_splice( $args, 1 );
    9392                if ( ! empty( $args ) ) {
    9493                    $string = vsprintf( $string, $args );
     
    105104        }
    106105
    107         $args = func_get_args();
    108         call_user_func_array( array( $this, 'parent::error' ), $args );
     106        parent::error( $errors, ...$args );
    109107    }
    110108
     
    114112     * @since 4.6.0
    115113     *
    116      * @param string|array|WP_Error $data Log entry data.
     114     * @param string|array|WP_Error $data    Log entry data.
     115     * @param mixed                 ...$args Optional text replacements.
    117116     */
    118     public function feedback( $data ) {
     117    public function feedback( $data, ...$args ) {
    119118        if ( is_wp_error( $data ) ) {
    120119            foreach ( $data->get_error_codes() as $error_code ) {
     
    123122        }
    124123
    125         $args = func_get_args();
    126         call_user_func_array( array( $this, 'parent::feedback' ), $args );
     124        parent::feedback( $data, ...$args );
    127125    }
    128126}
Note: See TracChangeset for help on using the changeset viewer.