Make WordPress Core

Changeset 46144


Ignore:
Timestamp:
09/15/2019 11:53:01 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Code Modernisation: Replace call_user_func_array() in various __call() methods with dynamic function calls.

The callback in these functions is always checked against a limited list of valid callbacks that can be safely changed to dynamic function calls.

Props jrf.
See #47678.

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r45932 r46144  
    240240    public function __call( $name, $arguments ) {
    241241        if ( in_array( $name, $this->compat_methods ) ) {
    242             return call_user_func_array( array( $this, $name ), $arguments );
     242            return $this->$name( ...$arguments );
    243243        }
    244244        return false;
  • trunk/src/wp-includes/class-wp-comment-query.php

    r46087 r46144  
    125125    public function __call( $name, $arguments ) {
    126126        if ( 'get_search_sql' === $name ) {
    127             return call_user_func_array( array( $this, $name ), $arguments );
     127            return $this->get_search_sql( ...$arguments );
    128128        }
    129129        return false;
  • trunk/src/wp-includes/class-wp-oembed.php

    r45674 r46144  
    236236    public function __call( $name, $arguments ) {
    237237        if ( in_array( $name, $this->compat_methods ) ) {
    238             return call_user_func_array( array( $this, $name ), $arguments );
     238            return $this->$name( ...$arguments );
    239239        }
    240240        return false;
  • trunk/src/wp-includes/class-wp-query.php

    r45932 r46144  
    35623562    public function __call( $name, $arguments ) {
    35633563        if ( in_array( $name, $this->compat_methods ) ) {
    3564             return call_user_func_array( array( $this, $name ), $arguments );
     3564            return $this->$name( ...$arguments );
    35653565        }
    35663566        return false;
  • trunk/src/wp-includes/class-wp-roles.php

    r42870 r46144  
    102102    public function __call( $name, $arguments ) {
    103103        if ( '_init' === $name ) {
    104             return call_user_func_array( array( $this, $name ), $arguments );
     104            return $this->_init( ...$arguments );
    105105        }
    106106        return false;
  • trunk/src/wp-includes/class-wp-user-query.php

    r45915 r46144  
    886886    public function __call( $name, $arguments ) {
    887887        if ( 'get_search_sql' === $name ) {
    888             return call_user_func_array( array( $this, $name ), $arguments );
     888            return $this->get_search_sql( ...$arguments );
    889889        }
    890890        return false;
  • trunk/src/wp-includes/class-wp-user.php

    r45623 r46144  
    445445    public function __call( $name, $arguments ) {
    446446        if ( '_init_caps' === $name ) {
    447             return call_user_func_array( array( $this, $name ), $arguments );
     447            return $this->_init_caps( ...$arguments );
    448448        }
    449449        return false;
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r45932 r46144  
    178178    public function __call( $name, $arguments ) {
    179179        if ( '_multisite_getUsersBlogs' === $name ) {
    180             return call_user_func_array( array( $this, $name ), $arguments );
     180            return $this->_multisite_getUsersBlogs( ...$arguments );
    181181        }
    182182        return false;
Note: See TracChangeset for help on using the changeset viewer.