Use varargs for MessageLocalizer::msg and similar
authorUmherirrender <umherirrender_de.wp@web.de>
Fri, 8 Jun 2018 20:35:15 +0000 (22:35 +0200)
committerReedy <reedy@wikimedia.org>
Fri, 18 Oct 2019 20:15:12 +0000 (20:15 +0000)
Bug: T191666
Change-Id: I59f2ae1a96af392026fc106e57d23553003c16b8
(cherry picked from commit 8752df6592436d3394a743331bf8ac8299fe0f7d)

includes/actions/Action.php
includes/context/ContextSource.php
includes/context/DerivativeContext.php
includes/context/RequestContext.php
includes/htmlform/HTMLFormField.php
includes/language/MessageLocalizer.php
includes/logging/LogFormatter.php
includes/resourceloader/ResourceLoaderContext.php
includes/specialpage/SpecialPage.php
tests/phpunit/mocks/MockMessageLocalizer.php

index 4be2f7d..6497cab 100644 (file)
@@ -252,11 +252,12 @@ abstract class Action implements MessageLocalizer {
         * Get a Message object with context set
         * Parameters are the same as wfMessage()
         *
+        * @param string|string[]|MessageSpecifier $key
+        * @param mixed ...$params
         * @return Message
         */
-       final public function msg( $key ) {
-               $params = func_get_args();
-               return $this->getContext()->msg( ...$params );
+       final public function msg( $key, ...$params ) {
+               return $this->getContext()->msg( $key, ...$params );
        }
 
        /**
index a21f404..79d4e5b 100644 (file)
@@ -162,14 +162,11 @@ abstract class ContextSource implements IContextSource {
         * @since 1.18
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $args,...
-        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg( $key /* $args */ ) {
-               $args = func_get_args();
-
-               return $this->getContext()->msg( ...$args );
+       public function msg( $key, ...$params ) {
+               return $this->getContext()->msg( $key, ...$params );
        }
 
        /**
index e4340ce..27dd500 100644 (file)
@@ -256,14 +256,11 @@ class DerivativeContext extends ContextSource implements MutableContext {
         *
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $args,... Arguments to wfMessage
-        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg( $key ) {
-               $args = func_get_args();
-
+       public function msg( $key, ...$params ) {
                // phpcs:ignore MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage
-               return wfMessage( ...$args )->setContext( $this );
+               return wfMessage( $key, ...$params )->setContext( $this );
        }
 }
index cbcaba1..73b8c5c 100644 (file)
@@ -416,14 +416,11 @@ class RequestContext implements IContextSource, MutableContext {
         *
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $args,...
-        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg( $key ) {
-               $args = func_get_args();
-
-               return wfMessage( ...$args )->setContext( $this );
+       public function msg( $key, ...$params ) {
+               return wfMessage( $key, ...$params )->setContext( $this );
        }
 
        /**
index b55b652..e4c6b30 100644 (file)
@@ -76,15 +76,15 @@ abstract class HTMLFormField {
         *
         * Parameters are the same as wfMessage().
         *
+        * @param string|string[]|MessageSpecifier $key
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg() {
-               $args = func_get_args();
-
+       public function msg( $key, ...$params ) {
                if ( $this->mParent ) {
-                       return $this->mParent->msg( ...$args );
+                       return $this->mParent->msg( $key, ...$params );
                }
-               return wfMessage( ...$args );
+               return wfMessage( $key, ...$params );
        }
 
        /**
index fc51439..fd0b08d 100644 (file)
@@ -35,10 +35,9 @@ interface MessageLocalizer {
         *
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $params,... Normal message parameters
-        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
+        * @param mixed ...$params Normal message parameters
         * @return Message
         */
-       public function msg( $key /*...*/ );
+       public function msg( $key, ...$params );
 
 }
index b4a6825..4aa890f 100644 (file)
@@ -755,10 +755,11 @@ class LogFormatter {
        /**
         * Shortcut for wfMessage which honors local context.
         * @param string $key
+        * @param mixed ...$params
         * @return Message
         */
-       protected function msg( $key ) {
-               return $this->context->msg( $key );
+       protected function msg( $key, ...$params ) {
+               return $this->context->msg( $key, ...$params );
        }
 
        /**
index 1274052..ed9d70b 100644 (file)
@@ -215,12 +215,11 @@ class ResourceLoaderContext implements MessageLocalizer {
         * @since 1.27
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $args,...
-        * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg( $key ) {
-               return wfMessage( ...func_get_args() )
+       public function msg( $key, ...$params ) {
+               return wfMessage( $key, ...$params )
                        ->inLanguage( $this->getLanguage() )
                        // Use a dummy title because there is no real title
                        // for this endpoint, and the cache won't vary on it
index ba8e318..1400d35 100644 (file)
@@ -784,11 +784,13 @@ class SpecialPage implements MessageLocalizer {
         * Wrapper around wfMessage that sets the current context.
         *
         * @since 1.16
+        * @param string|string[]|MessageSpecifier $key
+        * @param mixed ...$params
         * @return Message
         * @see wfMessage
         */
-       public function msg( $key /* $args */ ) {
-               $message = $this->getContext()->msg( ...func_get_args() );
+       public function msg( $key, ...$params ) {
+               $message = $this->getContext()->msg( $key, ...$params );
                // RequestContext passes context to wfMessage, and the language is set from
                // the context, but setting the language for Message class removes the
                // interface message status, which breaks for example usernameless gender
index 4d35930..388dcf0 100644 (file)
@@ -30,14 +30,11 @@ class MockMessageLocalizer implements MessageLocalizer {
         *
         * @param string|string[]|MessageSpecifier $key Message key, or array of keys,
         *   or a MessageSpecifier.
-        * @param mixed $args,...
+        * @param mixed ...$params
         * @return Message
         */
-       public function msg( $key ) {
-               $args = func_get_args();
-
-               /** @var Message $message */
-               $message = wfMessage( ...$args );
+       public function msg( $key, ...$params ) {
+               $message = wfMessage( $key, ...$params );
 
                if ( $this->languageCode !== null ) {
                        $message->inLanguage( $this->languageCode );