diff --git a/img_auth.php b/img_auth.php index e6b6e1b67e8..0a209e98b42 100644 --- a/img_auth.php +++ b/img_auth.php @@ -186,13 +186,12 @@ function wfImageAuthMain() { * subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2 * @param string $msg1 * @param string $msg2 + * @param mixed ...$args To pass as params to wfMessage() with $msg2. Either variadic, or a single + * array argument. */ -function wfForbidden( $msg1, $msg2 ) { +function wfForbidden( $msg1, $msg2, ...$args ) { global $wgImgAuthDetails; - $args = func_get_args(); - array_shift( $args ); - array_shift( $args ); $args = ( isset( $args[0] ) && is_array( $args[0] ) ) ? $args[0] : $args; $msgHdr = wfMessage( $msg1 )->escaped(); diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index b400797c583..cab98a7c630 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -582,14 +582,14 @@ class SiteConfiguration { * which is not fun * * @param array $array1 + * @param array ...$arrays * * @return array */ - static function arrayMerge( $array1/* ... */ ) { + static function arrayMerge( array $array1, ...$arrays ) { $out = $array1; - $argsCount = func_num_args(); - for ( $i = 1; $i < $argsCount; $i++ ) { - foreach ( func_get_arg( $i ) as $key => $value ) { + foreach ( $arrays as $array ) { + foreach ( $array as $key => $value ) { if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { $out[$key] = self::arrayMerge( $out[$key], $value ); } elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) { diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php index e37b4d481da..2f66277ec40 100644 --- a/includes/api/ApiAuthManagerHelper.php +++ b/includes/api/ApiAuthManagerHelper.php @@ -345,10 +345,10 @@ class ApiAuthManagerHelper { /** * Fetch the standard parameters this helper recognizes * @param string $action AuthManager action - * @param string $param,... Parameters to use + * @param string ...$wantedParams Parameters to use * @return array */ - public static function getStandardParams( $action, $param /* ... */ ) { + public static function getStandardParams( $action, ...$wantedParams ) { $params = [ 'requests' => [ ApiBase::PARAM_TYPE => 'string', @@ -384,8 +384,6 @@ class ApiAuthManagerHelper { ]; $ret = []; - $wantedParams = func_get_args(); - array_shift( $wantedParams ); foreach ( $wantedParams as $name ) { if ( isset( $params[$name] ) ) { $ret[$name] = $params[$name]; diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 502cee82b7e..cb7ff19b358 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -69,23 +69,22 @@ class MWException extends Exception { * @param string $key Message name * @param string $fallback Default message if the message cache can't be * called by the exception - * The function also has other parameters that are arguments for the message + * @param mixed ...$params To pass to wfMessage() * @return string Message with arguments replaced */ - public function msg( $key, $fallback /*[, params...] */ ) { + public function msg( $key, $fallback, ...$params ) { global $wgSitename; - $args = array_slice( func_get_args(), 2 ); // FIXME: Keep logic in sync with MWExceptionRenderer::msg. $res = false; if ( $this->useMessageCache() ) { try { - $res = wfMessage( $key, $args )->text(); + $res = wfMessage( $key, $params )->text(); } catch ( Exception $e ) { } } if ( $res === false ) { - $res = wfMsgReplaceArgs( $fallback, $args ); + $res = wfMsgReplaceArgs( $fallback, $params ); // If an exception happens inside message rendering, // {{SITENAME}} sometimes won't be replaced. $res = strtr( $res, [ diff --git a/includes/exception/MWExceptionRenderer.php b/includes/exception/MWExceptionRenderer.php index 66775bf61fa..c52a867865c 100644 --- a/includes/exception/MWExceptionRenderer.php +++ b/includes/exception/MWExceptionRenderer.php @@ -191,18 +191,17 @@ class MWExceptionRenderer { * @param string $key Message name * @param string $fallback Default message if the message cache can't be * called by the exception - * The function also has other parameters that are arguments for the message + * @param mixed ...$params To pass to wfMessage() * @return string Message with arguments replaced */ - private static function msg( $key, $fallback /*[, params...] */ ) { + private static function msg( $key, $fallback, ...$params ) { global $wgSitename; - $args = array_slice( func_get_args(), 2 ); // FIXME: Keep logic in sync with MWException::msg. try { - $res = wfMessage( $key, $args )->text(); + $res = wfMessage( $key, $params )->text(); } catch ( Exception $e ) { - $res = wfMsgReplaceArgs( $fallback, $args ); + $res = wfMsgReplaceArgs( $fallback, $params ); // If an exception happens inside message rendering, // {{SITENAME}} sometimes won't be replaced. $res = strtr( $res, [ diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 16dc46591b5..0702635e4fa 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -77,9 +77,7 @@ abstract class HTMLFormField { * * @return Message */ - public function msg() { - $args = func_get_args(); - + public function msg( ...$args ) { if ( $this->mParent ) { return $this->mParent->msg( ...$args ); } diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 41ec673a185..466e3d873c6 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -120,10 +120,7 @@ class WikiImporter { wfDebug( "IMPORT: $data\n" ); } - public function notice( $msg /*, $param, ...*/ ) { - $params = func_get_args(); - array_shift( $params ); - + public function notice( $msg, ...$params ) { if ( is_callable( $this->mNoticeCallback ) ) { call_user_func( $this->mNoticeCallback, $msg, $params ); } else { # No ImportReporter -> CLI @@ -430,8 +427,7 @@ class WikiImporter { } } - $args = func_get_args(); - return Hooks::run( 'AfterImportPage', $args ); + return Hooks::run( 'AfterImportPage', func_get_args() ); } /** @@ -486,8 +482,7 @@ class WikiImporter { private function pageOutCallback( $title, $foreignTitle, $revCount, $sucCount, $pageInfo ) { if ( isset( $this->mPageOutCallback ) ) { - $args = func_get_args(); - call_user_func_array( $this->mPageOutCallback, $args ); + call_user_func_array( $this->mPageOutCallback, func_get_args() ); } } diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 7267ddd2f34..c008333e473 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -200,24 +200,23 @@ class CliInstaller extends Installer { $this->showMessage( 'config-install-step-done' ); } - public function showMessage( $msg /*, ... */ ) { - echo $this->getMessageText( func_get_args() ) . "\n"; + public function showMessage( $msg, ...$params ) { + echo $this->getMessageText( $msg, $params ) . "\n"; flush(); } - public function showError( $msg /*, ... */ ) { - echo "***{$this->getMessageText( func_get_args() )}***\n"; + public function showError( $msg, ...$params ) { + echo "***{$this->getMessageText( $msg, $params )}***\n"; flush(); } /** + * @param string $msg * @param array $params * * @return string */ - protected function getMessageText( $params ) { - $msg = array_shift( $params ); - + protected function getMessageText( $msg, $params ) { $text = wfMessage( $msg, $params )->parse(); $text = preg_replace( '/(.*?)<\/a>/', '$2 <$1>', $text ); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index ea022bb5f0d..9053f8d1951 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -336,14 +336,16 @@ abstract class Installer { * The messages will be in wikitext format, which will be converted to an * output format such as HTML or text before being sent to the user. * @param string $msg + * @param mixed ...$params */ - abstract public function showMessage( $msg /*, ... */ ); + abstract public function showMessage( $msg, ...$params ); /** * Same as showMessage(), but for displaying errors * @param string $msg + * @param mixed ...$params */ - abstract public function showError( $msg /*, ... */ ); + abstract public function showError( $msg, ...$params ); /** * Show a message to the installing user by using a Status object diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 2d12e62de8c..0a6be86ba56 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -374,13 +374,14 @@ class WebInstaller extends Installer { * Show an error message in a box. Parameters are like wfMessage(), or * alternatively, pass a Message object in. * @param string|Message $msg + * @param mixed ...$params */ - public function showError( $msg /*...*/ ) { + public function showError( $msg, ...$params ) { if ( !( $msg instanceof Message ) ) { - $args = func_get_args(); - array_shift( $args ); - $args = array_map( 'htmlspecialchars', $args ); - $msg = wfMessage( $msg, $args ); + $msg = wfMessage( + $msg, + array_map( 'htmlspecialchars', $params ) + ); } $text = $msg->useDatabase( false )->plain(); $this->output->addHTML( $this->getErrorBox( $text ) ); @@ -675,9 +676,7 @@ class WebInstaller extends Installer { * @param string $msg * @return string */ - public function getHelpBox( $msg /*, ... */ ) { - $args = func_get_args(); - array_shift( $args ); + public function getHelpBox( $msg, ...$args ) { $args = array_map( 'htmlspecialchars', $args ); $text = wfMessage( $msg, $args )->useDatabase( false )->plain(); $html = $this->parse( $text, true ); @@ -693,10 +692,10 @@ class WebInstaller extends Installer { /** * Output a help box. * @param string $msg Key for wfMessage() + * @param mixed ...$params */ - public function showHelpBox( $msg /*, ... */ ) { - $args = func_get_args(); - $html = $this->getHelpBox( ...$args ); + public function showHelpBox( $msg, ...$params ) { + $html = $this->getHelpBox( $msg, ...$params ); $this->output->addHTML( $html ); } @@ -705,12 +704,11 @@ class WebInstaller extends Installer { * Output looks like a list. * * @param string $msg + * @param mixed ...$params */ - public function showMessage( $msg /*, ... */ ) { - $args = func_get_args(); - array_shift( $args ); + public function showMessage( $msg, ...$params ) { $html = '
' . - $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) . + $this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) . "
\n"; $this->output->addHTML( $html ); } diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php index e23888779f9..ccc76bb77ba 100644 --- a/includes/libs/ArrayUtils.php +++ b/includes/libs/ArrayUtils.php @@ -151,13 +151,11 @@ class ArrayUtils { * @since 1.23 * * @param array $array1 The array to compare from - * @param array $array2,... More arrays to compare against + * @param array ...$arrays More arrays to compare against * @return array An array containing all the values from array1 * that are not present in any of the other arrays. */ - public static function arrayDiffAssocRecursive( $array1 ) { - $arrays = func_get_args(); - array_shift( $arrays ); + public static function arrayDiffAssocRecursive( $array1, ...$arrays ) { $ret = []; foreach ( $array1 as $key => $value ) { diff --git a/includes/libs/DeferredStringifier.php b/includes/libs/DeferredStringifier.php index 94704133ae1..7de60b1d5c1 100644 --- a/includes/libs/DeferredStringifier.php +++ b/includes/libs/DeferredStringifier.php @@ -36,12 +36,11 @@ class DeferredStringifier { /** * @param callable $callback Callback that gets called by __toString - * @param mixed $param,... Parameters to the callback + * @param mixed ...$params Parameters to the callback */ - public function __construct( $callback /*...*/ ) { - $this->params = func_get_args(); - array_shift( $this->params ); + public function __construct( $callback, ...$params ) { $this->callback = $callback; + $this->params = $params; } /** diff --git a/includes/libs/MemoizedCallable.php b/includes/libs/MemoizedCallable.php index e9d1fc1ca3e..5e7485c2793 100644 --- a/includes/libs/MemoizedCallable.php +++ b/includes/libs/MemoizedCallable.php @@ -135,11 +135,11 @@ class MemoizedCallable { * * Like MemoizedCallable::invokeArgs(), but variadic. * - * @param mixed $params,... Parameters for memoized function or method. + * @param mixed ...$params Parameters for memoized function or method. * @return mixed The memoized callable's return value. */ - public function invoke() { - return $this->invokeArgs( func_get_args() ); + public function invoke( ...$params ) { + return $this->invokeArgs( $params ); } /** diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 7bc3045c490..53a0ca040f4 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -1575,11 +1575,10 @@ abstract class FileBackend implements LoggerAwareInterface { * - StatusValue::newGood() if this method is called without parameters * - StatusValue::newFatal() with all parameters to this method if passed in * - * @param string $args,... + * @param string ...$args * @return StatusValue */ - final protected function newStatus() { - $args = func_get_args(); + final protected function newStatus( ...$args ) { if ( count( $args ) ) { $sv = StatusValue::newFatal( ...$args ); } else { diff --git a/includes/libs/jsminplus.php b/includes/libs/jsminplus.php index 3134e50cfaf..0eab8608a42 100644 --- a/includes/libs/jsminplus.php +++ b/includes/libs/jsminplus.php @@ -1700,7 +1700,7 @@ class JSNode public $funDecls = array(); public $varDecls = array(); - public function __construct($t, $type=0) + public function __construct($t, $type=0, ...$nodes) { if ($token = $t->currentToken()) { @@ -1716,11 +1716,9 @@ class JSNode $this->lineno = $t->lineno; } - if (($numargs = func_num_args()) > 2) + foreach($nodes as $node) { - $args = func_get_args(); - for ($i = 2; $i < $numargs; $i++) - $this->addNode($args[$i]); + $this->addNode($node); } } diff --git a/includes/media/MediaTransformError.php b/includes/media/MediaTransformError.php index f3b5d8f8090..fb1b015a719 100644 --- a/includes/media/MediaTransformError.php +++ b/includes/media/MediaTransformError.php @@ -30,8 +30,7 @@ class MediaTransformError extends MediaTransformOutput { /** @var Message */ private $msg; - function __construct( $msg, $width, $height /*, ... */ ) { - $args = array_slice( func_get_args(), 3 ); + function __construct( $msg, $width, $height, ...$args ) { $this->msg = wfMessage( $msg )->params( $args ); $this->width = intval( $width ); $this->height = intval( $height ); diff --git a/includes/media/ThumbnailImage.php b/includes/media/ThumbnailImage.php index 0deb89fcc42..36cf4228e5e 100644 --- a/includes/media/ThumbnailImage.php +++ b/includes/media/ThumbnailImage.php @@ -112,7 +112,7 @@ class ThumbnailImage extends MediaTransformOutput { function toHtml( $options = [] ) { global $wgPriorityHints, $wgElementTiming; - if ( count( func_get_args() ) == 2 ) { + if ( func_num_args() == 2 ) { throw new MWException( __METHOD__ . ' called in the old style' ); } diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index b2b74869184..7ce96bebafd 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -90,13 +90,13 @@ class CoreParserFunctions { /** * @param Parser $parser - * @param string $part1 + * @param string $part1 Message key + * @param mixed ...$params To pass to wfMessage() * @return array */ - public static function intFunction( $parser, $part1 = '' /*, ... */ ) { + public static function intFunction( $parser, $part1 = '', ...$params ) { if ( strval( $part1 ) !== '' ) { - $args = array_slice( func_get_args(), 2 ); - $message = wfMessage( $part1, $args ) + $message = wfMessage( $part1, $params ) ->inLanguage( $parser->getOptions()->getUserLangObj() ); return [ $message->plain(), 'noparse' => false ]; } else { @@ -313,11 +313,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $username + * @param string ...$forms What to output for each gender * @return string */ - public static function gender( $parser, $username ) { - $forms = array_slice( func_get_args(), 2 ); - + public static function gender( $parser, $username, ...$forms ) { // Some shortcuts to avoid loading user data unnecessarily if ( count( $forms ) === 0 ) { return ''; @@ -351,10 +350,10 @@ class CoreParserFunctions { /** * @param Parser $parser * @param string $text + * @param string ...$forms What to output for each number (singular, dual, plural, etc.) * @return string */ - public static function plural( $parser, $text = '' ) { - $forms = array_slice( func_get_args(), 2 ); + public static function plural( $parser, $text = '', ...$forms ) { $text = $parser->getFunctionLang()->parseFormattedNumber( $text ); settype( $text, ctype_digit( $text ) ? 'int' : 'float' ); return $parser->getFunctionLang()->convertPlural( $text, $forms ); diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 4ed6b791fee..c27a635e044 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -1421,12 +1421,10 @@ class PPFrame_DOM implements PPFrame { /** * @param string $sep * @param int $flags - * @param string|PPNode_DOM|DOMDocument $args,... + * @param string|PPNode_DOM|DOMDocument ...$args * @return string */ - public function implodeWithFlags( $sep, $flags /*, ... */ ) { - $args = array_slice( func_get_args(), 2 ); - + public function implodeWithFlags( $sep, $flags, ...$args ) { $first = true; $s = ''; foreach ( $args as $root ) { @@ -1453,12 +1451,10 @@ class PPFrame_DOM implements PPFrame { * This previously called implodeWithFlags but has now been inlined to reduce stack depth * * @param string $sep - * @param string|PPNode_DOM|DOMDocument $args,... + * @param string|PPNode_DOM|DOMDocument ...$args * @return string */ - public function implode( $sep /*, ... */ ) { - $args = array_slice( func_get_args(), 1 ); - + public function implode( $sep, ...$args ) { $first = true; $s = ''; foreach ( $args as $root ) { @@ -1485,11 +1481,10 @@ class PPFrame_DOM implements PPFrame { * with implode() * * @param string $sep - * @param string|PPNode_DOM|DOMDocument $args,... + * @param string|PPNode_DOM|DOMDocument ...$args * @return array */ - public function virtualImplode( $sep /*, ... */ ) { - $args = array_slice( func_get_args(), 1 ); + public function virtualImplode( $sep, ...$args ) { $out = []; $first = true; @@ -1517,11 +1512,10 @@ class PPFrame_DOM implements PPFrame { * @param string $start * @param string $sep * @param string $end - * @param string|PPNode_DOM|DOMDocument $args,... + * @param string|PPNode_DOM|DOMDocument ...$args * @return array */ - public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) { - $args = array_slice( func_get_args(), 3 ); + public function virtualBracketedImplode( $start, $sep, $end, ...$args ) { $out = [ $start ]; $first = true; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index eb869e21c35..dfce0a022b9 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -1232,12 +1232,10 @@ class PPFrame_Hash implements PPFrame { /** * @param string $sep * @param int $flags - * @param string|PPNode $args,... + * @param string|PPNode ...$args * @return string */ - public function implodeWithFlags( $sep, $flags /*, ... */ ) { - $args = array_slice( func_get_args(), 2 ); - + public function implodeWithFlags( $sep, $flags, ...$args ) { $first = true; $s = ''; foreach ( $args as $root ) { @@ -1263,12 +1261,10 @@ class PPFrame_Hash implements PPFrame { * Implode with no flags specified * This previously called implodeWithFlags but has now been inlined to reduce stack depth * @param string $sep - * @param string|PPNode $args,... + * @param string|PPNode ...$args * @return string */ - public function implode( $sep /*, ... */ ) { - $args = array_slice( func_get_args(), 1 ); - + public function implode( $sep, ...$args ) { $first = true; $s = ''; foreach ( $args as $root ) { @@ -1295,11 +1291,10 @@ class PPFrame_Hash implements PPFrame { * with implode() * * @param string $sep - * @param string|PPNode $args,... + * @param string|PPNode ...$args * @return PPNode_Hash_Array */ - public function virtualImplode( $sep /*, ... */ ) { - $args = array_slice( func_get_args(), 1 ); + public function virtualImplode( $sep, ...$args ) { $out = []; $first = true; @@ -1328,11 +1323,10 @@ class PPFrame_Hash implements PPFrame { * @param string $start * @param string $sep * @param string $end - * @param string|PPNode $args,... + * @param string|PPNode ...$args * @return PPNode_Hash_Array */ - public function virtualBracketedImplode( $start, $sep, $end /*, ... */ ) { - $args = array_slice( func_get_args(), 3 ); + public function virtualBracketedImplode( $start, $sep, $end, ...$args ) { $out = [ $start ]; $first = true; diff --git a/includes/shell/Command.php b/includes/shell/Command.php index 1dab7ebeb33..ba8133f2468 100644 --- a/includes/shell/Command.php +++ b/includes/shell/Command.php @@ -111,11 +111,10 @@ class Command { * Adds parameters to the command. All parameters are sanitized via Shell::escape(). * Null values are ignored. * - * @param string|string[] $args,... + * @param string|string[] ...$args * @return $this */ - public function params( /* ... */ ) { - $args = func_get_args(); + public function params( ...$args ) { if ( count( $args ) === 1 && is_array( reset( $args ) ) ) { // If only one argument has been passed, and that argument is an array, // treat it as a list of arguments @@ -130,11 +129,10 @@ class Command { * Adds unsafe parameters to the command. These parameters are NOT sanitized in any way. * Null values are ignored. * - * @param string|string[] $args,... + * @param string|string[] ...$args * @return $this */ - public function unsafeParams( /* ... */ ) { - $args = func_get_args(); + public function unsafeParams( ...$args ) { if ( count( $args ) === 1 && is_array( reset( $args ) ) ) { // If only one argument has been passed, and that argument is an array, // treat it as a list of arguments diff --git a/includes/specials/helpers/ImportReporter.php b/includes/specials/helpers/ImportReporter.php index c79e87c36e3..80638042b0b 100644 --- a/includes/specials/helpers/ImportReporter.php +++ b/includes/specials/helpers/ImportReporter.php @@ -69,10 +69,10 @@ class ImportReporter extends ContextSource { ); } - function reportLogItem( /* ... */ ) { + function reportLogItem( ...$args ) { $this->mLogItemCount++; if ( is_callable( $this->mOriginalLogCallback ) ) { - call_user_func_array( $this->mOriginalLogCallback, func_get_args() ); + call_user_func_array( $this->mOriginalLogCallback, $args ); } } @@ -86,8 +86,7 @@ class ImportReporter extends ContextSource { */ public function reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo ) { - $args = func_get_args(); - call_user_func_array( $this->mOriginalPageOutCallback, $args ); + call_user_func_array( $this->mOriginalPageOutCallback, func_get_args() ); if ( $title === null ) { # Invalid or non-importable title; a notice is already displayed diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index de52e7aa211..f17b00c1c81 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -272,8 +272,7 @@ class RecompressTracked { * Dispatch a command to the next available replica DB. * This may block until a replica DB finishes its work and becomes available. */ - function dispatch( /*...*/ ) { - $args = func_get_args(); + function dispatch( ...$args ) { $pipes = $this->replicaPipes; $x = []; $y = []; diff --git a/tests/phpunit/includes/Storage/NameTableStoreTest.php b/tests/phpunit/includes/Storage/NameTableStoreTest.php index fab49fa5820..f42e557b770 100644 --- a/tests/phpunit/includes/Storage/NameTableStoreTest.php +++ b/tests/phpunit/includes/Storage/NameTableStoreTest.php @@ -62,23 +62,23 @@ class NameTableStoreTest extends MediaWikiTestCase { ->getMock(); $mock->expects( $this->exactly( $insertCalls ) ) ->method( 'insert' ) - ->willReturnCallback( function () { - return call_user_func_array( [ $this->db, 'insert' ], func_get_args() ); + ->willReturnCallback( function ( ...$args ) { + return call_user_func_array( [ $this->db, 'insert' ], $args ); } ); $mock->expects( $this->exactly( $selectCalls ) ) ->method( 'select' ) - ->willReturnCallback( function () { - return call_user_func_array( [ $this->db, 'select' ], func_get_args() ); + ->willReturnCallback( function ( ...$args ) { + return call_user_func_array( [ $this->db, 'select' ], $args ); } ); $mock->expects( $this->exactly( $insertCalls ) ) ->method( 'affectedRows' ) - ->willReturnCallback( function () { - return call_user_func_array( [ $this->db, 'affectedRows' ], func_get_args() ); + ->willReturnCallback( function ( ...$args ) { + return call_user_func_array( [ $this->db, 'affectedRows' ], $args ); } ); $mock->expects( $this->any() ) ->method( 'insertId' ) - ->willReturnCallback( function () { - return call_user_func_array( [ $this->db, 'insertId' ], func_get_args() ); + ->willReturnCallback( function ( ...$args ) { + return call_user_func_array( [ $this->db, 'insertId' ], $args ); } ); return $mock; } diff --git a/tests/phpunit/includes/api/query/ApiQueryTestBase.php b/tests/phpunit/includes/api/query/ApiQueryTestBase.php index 08af755d8bf..7869bbd2db9 100644 --- a/tests/phpunit/includes/api/query/ApiQueryTestBase.php +++ b/tests/phpunit/includes/api/query/ApiQueryTestBase.php @@ -32,14 +32,14 @@ STR; /** * Merges all requests parameter + expected values into one - * @param array $v,... List of arrays, each of which contains exactly two + * @param array ...$arrays List of arrays, each of which contains exactly two * @return array */ - protected function merge( /*...*/ ) { + protected function merge( ...$arrays ) { $request = []; $expected = []; - foreach ( func_get_args() as $v ) { - list( $req, $exp ) = $this->validateRequestExpectedPair( $v ); + foreach ( $arrays as $array ) { + list( $req, $exp ) = $this->validateRequestExpectedPair( $array ); $request = array_merge_recursive( $request, $req ); $this->mergeExpected( $expected, $exp ); } diff --git a/tests/phpunit/includes/auth/UserDataAuthenticationRequestTest.php b/tests/phpunit/includes/auth/UserDataAuthenticationRequestTest.php index cc2771cbfb0..fc1930aa56e 100644 --- a/tests/phpunit/includes/auth/UserDataAuthenticationRequestTest.php +++ b/tests/phpunit/includes/auth/UserDataAuthenticationRequestTest.php @@ -53,9 +53,8 @@ class UserDataAuthenticationRequestTest extends AuthenticationRequestTestCase { * @dataProvider provideLoadFromSubmission */ public function testLoadFromSubmission( - array $args, array $data, $expectState /* $hiddenPref, $enableEmail */ + array $args, array $data, $expectState, $hiddenPref = null, $enableEmail = null ) { - list( $args, $data, $expectState, $hiddenPref, $enableEmail ) = func_get_args(); $this->setMwGlobals( 'wgHiddenPrefs', $hiddenPref ); $this->setMwGlobals( 'wgEnableEmail', $enableEmail ); parent::testLoadFromSubmission( $args, $data, $expectState ); diff --git a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php index ca3ac1b6510..7ad654136d9 100644 --- a/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php +++ b/tests/phpunit/includes/changes/CategoryMembershipChangeTest.php @@ -39,8 +39,8 @@ class CategoryMembershipChangeTest extends MediaWikiLangTestCase { */ private static $pageName = 'CategoryMembershipChangeTestPage'; - public static function newForCategorizationCallback() { - self::$lastNotifyArgs = func_get_args(); + public static function newForCategorizationCallback( ...$args ) { + self::$lastNotifyArgs = $args; self::$notifyCallCounter += 1; return self::$mockRecentChange; } diff --git a/tests/phpunit/includes/libs/ArrayUtilsTest.php b/tests/phpunit/includes/libs/ArrayUtilsTest.php index d5ac77bbf7c..12b63205647 100644 --- a/tests/phpunit/includes/libs/ArrayUtilsTest.php +++ b/tests/phpunit/includes/libs/ArrayUtilsTest.php @@ -133,9 +133,7 @@ class ArrayUtilsTest extends PHPUnit\Framework\TestCase { * @covers ArrayUtils::arrayDiffAssocRecursive * @dataProvider provideArrayDiffAssocRecursive */ - function testArrayDiffAssocRecursive( $expected ) { - $args = func_get_args(); - array_shift( $args ); + function testArrayDiffAssocRecursive( $expected, ...$args ) { $this->assertEquals( call_user_func_array( 'ArrayUtils::arrayDiffAssocRecursive', $args ), $expected ); diff --git a/tests/phpunit/includes/poolcounter/PoolCounterTest.php b/tests/phpunit/includes/poolcounter/PoolCounterTest.php index 19baf5a82f6..28cd503cac0 100644 --- a/tests/phpunit/includes/poolcounter/PoolCounterTest.php +++ b/tests/phpunit/includes/poolcounter/PoolCounterTest.php @@ -78,7 +78,7 @@ class PoolCounterTest extends MediaWikiTestCase { // That call will die if the contructor is not public, unless we use disableOriginalConstructor(), // in which case we could not test the constructor. abstract class PoolCounterAbstractMock extends PoolCounter { - public function __construct() { - call_user_func_array( 'parent::__construct', func_get_args() ); + public function __construct( ...$args ) { + call_user_func_array( 'parent::__construct', $args ); } } diff --git a/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php index 16f236770c2..63c2b821721 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php @@ -204,8 +204,7 @@ class WatchedItemQueryServiceUnitTest extends MediaWikiTestCase { } ) ); $mock->expects( $this->any() ) ->method( 'isAllowedAny' ) - ->will( $this->returnCallback( function () use ( $notAllowedAction ) { - $actions = func_get_args(); + ->will( $this->returnCallback( function ( ...$actions ) use ( $notAllowedAction ) { return !in_array( $notAllowedAction, $actions ); } ) ); diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php index a6b21629620..2f956885485 100644 --- a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php @@ -89,8 +89,8 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->getMock(); $mock->expects( $this->any() ) ->method( 'makeKey' ) - ->will( $this->returnCallback( function () { - return implode( ':', func_get_args() ); + ->will( $this->returnCallback( function ( ...$args ) { + return implode( ':', $args ); } ) ); return $mock; }