From 5289a345cf24f9952d09efd4c7a317414a86c26b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 28 Jun 2020 18:23:39 +0000 Subject: [PATCH] Code Modernization: Introduce the spread operator in `wp-includes/IXR`. 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 kraftbj. See #48267, #47678. git-svn-id: https://develop.svn.wordpress.org/trunk@48204 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/IXR/class-IXR-client.php | 8 ++++++-- src/wp-includes/IXR/class-IXR-clientmulticall.php | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/IXR/class-IXR-client.php b/src/wp-includes/IXR/class-IXR-client.php index f66bcb30d6..480822316b 100644 --- a/src/wp-includes/IXR/class-IXR-client.php +++ b/src/wp-includes/IXR/class-IXR-client.php @@ -58,9 +58,13 @@ class IXR_Client self::__construct( $server, $path, $port, $timeout ); } - function query() + /** + * @since 1.5.0 + * @since 5.5.0 Formalized the existing `...$args` parameter by adding it + * to the function signature. + */ + function query( ...$args ) { - $args = func_get_args(); $method = array_shift($args); $request = new IXR_Request($method, $args); $length = $request->getLength(); diff --git a/src/wp-includes/IXR/class-IXR-clientmulticall.php b/src/wp-includes/IXR/class-IXR-clientmulticall.php index bc40efd771..5a10246dbd 100644 --- a/src/wp-includes/IXR/class-IXR-clientmulticall.php +++ b/src/wp-includes/IXR/class-IXR-clientmulticall.php @@ -25,9 +25,13 @@ class IXR_ClientMulticall extends IXR_Client self::__construct( $server, $path, $port ); } - function addCall() + /** + * @since 1.5.0 + * @since 5.5.0 Formalized the existing `...$args` parameter by adding it + * to the function signature. + */ + function addCall( ...$args ) { - $args = func_get_args(); $methodName = array_shift($args); $struct = array( 'methodName' => $methodName, @@ -36,7 +40,12 @@ class IXR_ClientMulticall extends IXR_Client $this->calls[] = $struct; } - function query() + /** + * @since 1.5.0 + * @since 5.5.0 Formalized the existing `...$args` parameter by adding it + * to the function signature. + */ + function query( ...$args ) { // Prepare multicall, then call the parent::query() method return parent::query('system.multicall', $this->calls);