Begin introducing PHP 5.6 variadic parameters where appropriate
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 19 Apr 2018 21:11:28 +0000 (14:11 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Mon, 4 Jun 2018 18:53:55 +0000 (11:53 -0700)
Change-Id: I5670b8482e8d3bcb0b3a2b4d2ce9834cfc37e171

includes/GlobalFunctions.php
includes/shell/Shell.php

index 8fcd11e..ae09602 100644 (file)
@@ -1336,21 +1336,19 @@ function wfGetLangObj( $langcode = false ) {
  * This function replaces all old wfMsg* functions.
  *
  * @param string|string[]|MessageSpecifier $key Message key, or array of keys, or a MessageSpecifier
- * @param mixed $params,... Normal message parameters
+ * @param string ...$params Normal message parameters
  * @return Message
  *
  * @since 1.17
  *
  * @see Message::__construct
  */
-function wfMessage( $key /*...*/ ) {
+function wfMessage( $key, ...$params ) {
        $message = new Message( $key );
 
        // We call Message::params() to reduce code duplication
-       $params = func_get_args();
-       array_shift( $params );
        if ( $params ) {
-               call_user_func_array( [ $message, 'params' ], $params );
+               $message->params( ...$params );
        }
 
        return $message;
@@ -1361,16 +1359,15 @@ function wfMessage( $key /*...*/ ) {
  * for the first message which is non-empty. If all messages are empty then an
  * instance of the first message key is returned.
  *
- * @param string|string[] $keys,... Message keys
+ * @param string|string[] ...$keys Message keys
  * @return Message
  *
  * @since 1.18
  *
  * @see Message::newFallbackSequence
  */
-function wfMessageFallback( /*...*/ ) {
-       $args = func_get_args();
-       return call_user_func_array( 'Message::newFallbackSequence', $args );
+function wfMessageFallback( ...$keys ) {
+       return Message::newFallbackSequence( ...$keys );
 }
 
 /**
index 3f10c11..ee9f1eb 100644 (file)
@@ -110,23 +110,22 @@ class Shell {
        /**
         * Returns a new instance of Command class
         *
-        * @param string|string[] $command String or array of strings representing the command to
+        * @param string|string[] ...$commands String or array of strings representing the command to
         * be executed, each value will be escaped.
         *   Example:   [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'"
         * @return Command
         */
-       public static function command( $command ) {
-               $args = func_get_args();
-               if ( count( $args ) === 1 && is_array( reset( $args ) ) ) {
+       public static function command( ...$commands ) {
+               if ( count( $commands ) === 1 && is_array( reset( $commands ) ) ) {
                        // If only one argument has been passed, and that argument is an array,
                        // treat it as a list of arguments
-                       $args = reset( $args );
+                       $commands = reset( $commands );
                }
                $command = MediaWikiServices::getInstance()
                        ->getShellCommandFactory()
                        ->create();
 
-               return $command->params( $args );
+               return $command->params( $commands );
        }
 
        /**
@@ -156,12 +155,11 @@ class Shell {
         * (https://bugs.php.net/bug.php?id=26285) and the locale problems on Linux in
         * PHP 5.2.6+ (bug backported to earlier distro releases of PHP).
         *
-        * @param string $args,... strings to escape and glue together, or a single array of
-        *     strings parameter. Null values are ignored.
+        * @param string|string[] ...$args strings to escape and glue together, or a single
+        *     array of strings parameter. Null values are ignored.
         * @return string
         */
-       public static function escape( /* ... */ ) {
-               $args = func_get_args();
+       public static function escape( ...$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