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
This commit is contained in:
Sergey Biryukov 2020-06-28 18:23:39 +00:00
parent bd03636941
commit 5289a345cf
2 changed files with 18 additions and 5 deletions

View File

@ -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();

View File

@ -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);