Merge "Move RawMessage out of Message.php to its own file"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 15 Aug 2017 04:48:46 +0000 (04:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 15 Aug 2017 04:48:46 +0000 (04:48 +0000)
autoload.php
includes/Message.php
includes/RawMessage.php [new file with mode: 0644]

index 508e75b..d9e85bd 100644 (file)
@@ -1180,7 +1180,7 @@ $wgAutoloadLocalClasses = [
        'RangeChronologicalPager' => __DIR__ . '/includes/pager/RangeChronologicalPager.php',
        'RangeDifference' => __DIR__ . '/includes/diff/DiffEngine.php',
        'RawAction' => __DIR__ . '/includes/actions/RawAction.php',
-       'RawMessage' => __DIR__ . '/includes/Message.php',
+       'RawMessage' => __DIR__ . '/includes/RawMessage.php',
        'ReadOnlyError' => __DIR__ . '/includes/exception/ReadOnlyError.php',
        'ReadOnlyMode' => __DIR__ . '/includes/ReadOnlyMode.php',
        'ReassignEdits' => __DIR__ . '/maintenance/reassignEdits.php',
index 8777c6f..0240fa7 100644 (file)
@@ -1344,56 +1344,3 @@ class Message implements MessageSpecifier, Serializable {
                return $this->extractParam( new RawMessage( $vars, $params ), $format );
        }
 }
-
-/**
- * Variant of the Message class.
- *
- * Rather than treating the message key as a lookup
- * value (which is passed to the MessageCache and
- * translated as necessary), a RawMessage key is
- * treated as the actual message.
- *
- * All other functionality (parsing, escaping, etc.)
- * is preserved.
- *
- * @since 1.21
- */
-class RawMessage extends Message {
-
-       /**
-        * Call the parent constructor, then store the key as
-        * the message.
-        *
-        * @see Message::__construct
-        *
-        * @param string $text Message to use.
-        * @param array $params Parameters for the message.
-        *
-        * @throws InvalidArgumentException
-        */
-       public function __construct( $text, $params = [] ) {
-               if ( !is_string( $text ) ) {
-                       throw new InvalidArgumentException( '$text must be a string' );
-               }
-
-               parent::__construct( $text, $params );
-
-               // The key is the message.
-               $this->message = $text;
-       }
-
-       /**
-        * Fetch the message (in this case, the key).
-        *
-        * @return string
-        */
-       public function fetchMessage() {
-               // Just in case the message is unset somewhere.
-               if ( $this->message === null ) {
-                       $this->message = $this->key;
-               }
-
-               return $this->message;
-       }
-
-}
diff --git a/includes/RawMessage.php b/includes/RawMessage.php
new file mode 100644 (file)
index 0000000..9a0d947
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+/**
+ * Variant of the Message class.
+ *
+ * Rather than treating the message key as a lookup
+ * value (which is passed to the MessageCache and
+ * translated as necessary), a RawMessage key is
+ * treated as the actual message.
+ *
+ * All other functionality (parsing, escaping, etc.)
+ * is preserved.
+ *
+ * @since 1.21
+ */
+class RawMessage extends Message {
+
+       /**
+        * Call the parent constructor, then store the key as
+        * the message.
+        *
+        * @see Message::__construct
+        *
+        * @param string $text Message to use.
+        * @param array $params Parameters for the message.
+        *
+        * @throws InvalidArgumentException
+        */
+       public function __construct( $text, $params = [] ) {
+               if ( !is_string( $text ) ) {
+                       throw new InvalidArgumentException( '$text must be a string' );
+               }
+
+               parent::__construct( $text, $params );
+
+               // The key is the message.
+               $this->message = $text;
+       }
+
+       /**
+        * Fetch the message (in this case, the key).
+        *
+        * @return string
+        */
+       public function fetchMessage() {
+               // Just in case the message is unset somewhere.
+               if ( $this->message === null ) {
+                       $this->message = $this->key;
+               }
+
+               return $this->message;
+       }
+
+}