diff --git a/class.jetpack.php b/class.jetpack.php index ce849331852f5..e2c62ee1340a2 100644 --- a/class.jetpack.php +++ b/class.jetpack.php @@ -5537,8 +5537,10 @@ public static function check_privacy( $file ) { /** * Helper method for multicall XMLRPC. + * + * @param ...$args Args for the async_call. */ - public static function xmlrpc_async_call() { + public static function xmlrpc_async_call( ...$args ) { global $blog_id; static $clients = array(); @@ -5552,8 +5554,6 @@ public static function xmlrpc_async_call() { add_action( 'shutdown', array( 'Jetpack', 'xmlrpc_async_call' ) ); } - $args = func_get_args(); - if ( ! empty( $args[0] ) ) { call_user_func_array( array( $clients[ $client_blog_id ], 'addCall' ), $args ); } elseif ( is_multisite() ) { diff --git a/class.json-api.php b/class.json-api.php index be2c9846ab71f..144ef92c365e6 100644 --- a/class.json-api.php +++ b/class.json-api.php @@ -79,8 +79,7 @@ static function is_falsy( $value ) { return false; } - function __construct() { - $args = func_get_args(); + function __construct( ...$args ) { call_user_func_array( array( $this, 'setup_inputs' ), $args ); } diff --git a/modules/comments/base.php b/modules/comments/base.php index fb9d96856250a..137dd982c5ce0 100644 --- a/modules/comments/base.php +++ b/modules/comments/base.php @@ -45,13 +45,13 @@ protected function setup_filters() { * @param ... * @return false|string false if it's not a Highlander POST request. The matching credentials slug if it is. */ - function is_highlander_comment_post() { + function is_highlander_comment_post( ...$args ) { if ( empty( $_POST['hc_post_as'] ) ) { return false; } - if ( func_num_args() ) { - foreach ( func_get_args() as $id_source ) { + if ( $args ) { + foreach ( $args as $id_source ) { if ( $id_source === $_POST['hc_post_as'] ) { return $id_source; } diff --git a/packages/jitm/tests/php/test_JITM.php b/packages/jitm/tests/php/test_JITM.php index ba5ae63d66ff6..4f8f9058acf09 100644 --- a/packages/jitm/tests/php/test_JITM.php +++ b/packages/jitm/tests/php/test_JITM.php @@ -97,8 +97,7 @@ protected function mock_filters( $filters ) { $builder->setNamespace( __NAMESPACE__ ) ->setName( 'apply_filters' ) ->setFunction( - function() { - $current_args = func_get_args(); + function( ...$current_args ) { foreach ( $this->mocked_filters as $filter ) { if ( array_slice( $filter, 0, -1 ) === $current_args ) { return array_pop( $filter ); @@ -140,9 +139,8 @@ protected function mock_do_action() { $builder = new MockBuilder(); $builder->setNamespace( __NAMESPACE__ ) ->setName( 'do_action' ) - ->setFunction( function() { + ->setFunction( function( ...$args ) { global $actions; - $args = func_get_args(); $name = array_shift( $args ); if ( is_null( $actions ) ) { diff --git a/packages/status/tests/php/test_Status.php b/packages/status/tests/php/test_Status.php index dd0c9469c129d..b834ceb57f6b6 100644 --- a/packages/status/tests/php/test_Status.php +++ b/packages/status/tests/php/test_Status.php @@ -77,7 +77,7 @@ public function test_is_development_mode_filter_bool() { ) ); $this->assertFalse( $this->status->is_development_mode() ); - + $filters_mock->disable(); } @@ -86,7 +86,7 @@ public function test_is_development_mode_filter_bool() { */ public function test_is_development_mode_localhost() { $this->mock_function( 'site_url', 'localhost' ); - + $filters_mock = $this->mock_filters( array( array( 'jetpack_development_mode', false, false ), array( 'jetpack_development_mode', true, true ), @@ -101,7 +101,7 @@ public function test_is_development_mode_localhost() { * @covers Automattic\Jetpack\Status::is_development_mode * * @runInSeparateProcess - */ + */ public function test_is_development_mode_constant() { $this->mock_function( 'site_url', $this->site_url ); $filters_mock = $this->mock_filters( array( @@ -204,9 +204,7 @@ protected function mock_function_with_args( $function_name, $args = array() ) { $builder->setNamespace( __NAMESPACE__ ) ->setName( $function_name ) ->setFunction( - function() use ( &$args ) { - $current_args = func_get_args(); - + function( ...$current_args ) use ( &$args ) { foreach ( $args as $arg ) { if ( array_slice( $arg, 0, -1 ) === $current_args ) { return array_pop( $arg ); diff --git a/packages/sync/src/Listener.php b/packages/sync/src/Listener.php index dc9711843ca0d..417bc745ac152 100644 --- a/packages/sync/src/Listener.php +++ b/packages/sync/src/Listener.php @@ -106,13 +106,11 @@ function can_add_to_queue( $queue ) { ( ( $queue_size + 1 ) < $this->sync_queue_size_limit ); } - function full_sync_action_handler() { - $args = func_get_args(); + function full_sync_action_handler( ...$args ) { $this->enqueue_action( current_filter(), $args, $this->full_sync_queue ); } - function action_handler() { - $args = func_get_args(); + function action_handler( ...$args ) { $this->enqueue_action( current_filter(), $args, $this->sync_queue ); } diff --git a/sal/class.json-api-links.php b/sal/class.json-api-links.php index 5b18431f9995a..21450a5287bd9 100644 --- a/sal/class.json-api-links.php +++ b/sal/class.json-api-links.php @@ -18,7 +18,7 @@ public static function getInstance() { } // protect these methods for singleton - protected function __construct() { + protected function __construct() { $this->api = WPCOM_JSON_API::init(); } private function __clone() { } @@ -29,11 +29,10 @@ private function __wakeup() { } * * Used to construct meta links in API responses * - * @param mixed $args Optional arguments to be appended to URL + * @param mixed ...$args Optional arguments to be appended to URL * @return string Endpoint URL **/ - function get_link() { - $args = func_get_args(); + function get_link( ...$args ) { $format = array_shift( $args ); $base = WPCOM_JSON_API__BASE; @@ -127,7 +126,7 @@ function get_external_service_link( $external_service, $path = '' ) { * maximum available version of /animals/%s, e.g. 1.1 * * This method is used in get_link() to construct meta links for API responses. - * + * * @param $template_path string The generic endpoint path, e.g. /sites/%s * @param $path string The current endpoint path, relative to the version, e.g. /sites/12345 * @param $request_method string Request method used to access the endpoint path