From 1ace25088fabd20ac57564568100c295fd35fd26 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Sep 2019 11:53:01 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@46144 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-list-table.php | 2 +- src/wp-includes/class-wp-comment-query.php | 2 +- src/wp-includes/class-wp-oembed.php | 2 +- src/wp-includes/class-wp-query.php | 2 +- src/wp-includes/class-wp-roles.php | 2 +- src/wp-includes/class-wp-user-query.php | 2 +- src/wp-includes/class-wp-user.php | 2 +- src/wp-includes/class-wp-xmlrpc-server.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index b02b97cbc8..e5d12ceae9 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -239,7 +239,7 @@ class WP_List_Table { */ public function __call( $name, $arguments ) { if ( in_array( $name, $this->compat_methods ) ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->$name( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index 988d106c9e..9038b6194b 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -124,7 +124,7 @@ class WP_Comment_Query { */ public function __call( $name, $arguments ) { if ( 'get_search_sql' === $name ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->get_search_sql( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php index d64bb079bd..b08a5c942e 100644 --- a/src/wp-includes/class-wp-oembed.php +++ b/src/wp-includes/class-wp-oembed.php @@ -235,7 +235,7 @@ class WP_oEmbed { */ public function __call( $name, $arguments ) { if ( in_array( $name, $this->compat_methods ) ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->$name( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 57fd58a4f6..295b93c837 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -3561,7 +3561,7 @@ class WP_Query { */ public function __call( $name, $arguments ) { if ( in_array( $name, $this->compat_methods ) ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->$name( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-roles.php b/src/wp-includes/class-wp-roles.php index 18b0d55035..6e3004c37c 100644 --- a/src/wp-includes/class-wp-roles.php +++ b/src/wp-includes/class-wp-roles.php @@ -101,7 +101,7 @@ class WP_Roles { */ public function __call( $name, $arguments ) { if ( '_init' === $name ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->_init( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index d0abd8f44c..64776e10e8 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -885,7 +885,7 @@ class WP_User_Query { */ public function __call( $name, $arguments ) { if ( 'get_search_sql' === $name ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->get_search_sql( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index 73f7cdf0d5..a1c2b6e2c4 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -444,7 +444,7 @@ class WP_User { */ public function __call( $name, $arguments ) { if ( '_init_caps' === $name ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->_init_caps( ...$arguments ); } return false; } diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index f99a6aaa10..5142efad8c 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -177,7 +177,7 @@ class wp_xmlrpc_server extends IXR_Server { */ public function __call( $name, $arguments ) { if ( '_multisite_getUsersBlogs' === $name ) { - return call_user_func_array( array( $this, $name ), $arguments ); + return $this->_multisite_getUsersBlogs( ...$arguments ); } return false; }