Merge "Get rid of unnecessary func_get_args() and friends"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 12 Apr 2019 20:36:15 +0000 (20:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Apr 2019 20:36:15 +0000 (20:36 +0000)
31 files changed:
img_auth.php
includes/SiteConfiguration.php
includes/api/ApiAuthManagerHelper.php
includes/exception/MWException.php
includes/exception/MWExceptionRenderer.php
includes/htmlform/HTMLFormField.php
includes/import/WikiImporter.php
includes/installer/CliInstaller.php
includes/installer/Installer.php
includes/installer/WebInstaller.php
includes/libs/ArrayUtils.php
includes/libs/DeferredStringifier.php
includes/libs/MemoizedCallable.php
includes/libs/filebackend/FileBackend.php
includes/libs/jsminplus.php
includes/media/MediaTransformError.php
includes/media/ThumbnailImage.php
includes/parser/CoreParserFunctions.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
includes/shell/Command.php
includes/specials/helpers/ImportReporter.php
maintenance/storage/recompressTracked.php
tests/phpunit/includes/Storage/NameTableStoreTest.php
tests/phpunit/includes/api/query/ApiQueryTestBase.php
tests/phpunit/includes/auth/UserDataAuthenticationRequestTest.php
tests/phpunit/includes/changes/CategoryMembershipChangeTest.php
tests/phpunit/includes/libs/ArrayUtilsTest.php
tests/phpunit/includes/poolcounter/PoolCounterTest.php
tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php
tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php

index e6b6e1b..0a209e9 100644 (file)
@@ -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();
index b400797..cab98a7 100644 (file)
@@ -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 ) ) {
index e37b4d4..2f66277 100644 (file)
@@ -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];
index 502cee8..cb7ff19 100644 (file)
@@ -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, [
index 66775bf..c52a867 100644 (file)
@@ -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, [
index 16dc465..0702635 100644 (file)
@@ -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 );
                }
index 41ec673..466e3d8 100644 (file)
@@ -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() );
                }
        }
 
index 7267ddd..c008333 100644 (file)
@@ -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 href="(.*?)".*?>(.*?)<\/a>/', '$2 &lt;$1&gt;', $text );
index ea022bb..9053f8d 100644 (file)
@@ -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
index 2d12e62..0a6be86 100644 (file)
@@ -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 = '<div class="config-message">' .
-                       $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
+                       $this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) .
                        "</div>\n";
                $this->output->addHTML( $html );
        }
index e238887..ccc76bb 100644 (file)
@@ -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 ) {
index 9470413..7de60b1 100644 (file)
@@ -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;
        }
 
        /**
index e9d1fc1..5e7485c 100644 (file)
@@ -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 );
        }
 
        /**
index 7bc3045..53a0ca0 100644 (file)
@@ -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 {
index 3134e50..0eab860 100644 (file)
@@ -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);
                }
        }
 
index f3b5d8f..fb1b015 100644 (file)
@@ -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 );
index 0deb89f..36cf422 100644 (file)
@@ -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' );
                }
 
index b2b7486..7ce96be 100644 (file)
@@ -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 );
index 4ed6b79..c27a635 100644 (file)
@@ -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;
 
index eb869e2..dfce0a0 100644 (file)
@@ -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;
 
index 1dab7eb..ba8133f 100644 (file)
@@ -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
index c79e87c..8063804 100644 (file)
@@ -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
index de52e7a..f17b00c 100644 (file)
@@ -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 = [];
index fab49fa..f42e557 100644 (file)
@@ -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;
        }
index 08af755..7869bbd 100644 (file)
@@ -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 );
                }
index cc2771c..fc1930a 100644 (file)
@@ -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 );
index ca3ac1b..7ad6541 100644 (file)
@@ -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;
        }
index d5ac77b..12b6320 100644 (file)
@@ -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 );
index 19baf5a..28cd503 100644 (file)
@@ -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 );
        }
 }
index 16f2367..63c2b82 100644 (file)
@@ -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 );
                        } ) );
 
index a6b2162..2f95688 100644 (file)
@@ -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;
        }