Make CodeSniffer checks pass on includes/specialpages/
[lhc/web/wiklou.git] / includes / Status.php
index dc0bae0..795fd45 100644 (file)
  * so that a lack of error-handling will be explicit.
  */
 class Status {
+       /** @var bool */
        public $ok = true;
+
+       /** @var mixed  */
        public $value;
 
        /** Counters for batch operations */
+       /** @var int */
        public $successCount = 0;
+
+       /** @var int */
        public $failCount = 0;
 
        /** Array to indicate which items of the batch operations were successful */
+       /** @var array  */
        public $success = array();
 
+       /** @var array */
        public $errors = array();
+
+       /** @var callable */
        public $cleanCallback = false;
 
        /**
@@ -214,9 +224,11 @@ class Status {
        /**
         * Get the error list as a Message object
         *
-        * @param string $shortContext a short enclosing context message name, to
-        *        be used when there is a single error
-        * @param string $longContext a long enclosing context message name, for a list
+        * @param string|string[] $shortContext A short enclosing context message name (or an array of
+        * message names), to be used when there is a single error.
+        * @param string|string[] $longContext A long enclosing context message name (or an array of
+        * message names), for a list.
+        *
         * @return Message
         */
        public function getMessage( $shortContext = false, $longContext = false ) {
@@ -246,13 +258,13 @@ class Status {
                                $msgCount++;
                        }
 
-                       $wrapper = new RawMessage( '* $' . implode( "\n* \$", range( 1, $msgCount ) ) );
-                       $s = $wrapper->params( $msgs )->parse();
+                       $s = new RawMessage( '* $' . implode( "\n* \$", range( 1, $msgCount ) ) );
+                       $s->params( $msgs )->parse();
 
                        if ( $longContext ) {
-                               $s = wfMessage( $longContext, $wrapper );
+                               $s = wfMessage( $longContext, $s );
                        } elseif ( $shortContext ) {
-                               $wrapper = new RawMessage( "\n\$1\n", $wrapper );
+                               $wrapper = new RawMessage( "\n\$1\n", $s );
                                $wrapper->parse();
                                $s = wfMessage( $shortContext, $wrapper );
                        }
@@ -291,14 +303,15 @@ class Status {
        /**
         * Get the error message as HTML. This is done by parsing the wikitext error
         * message.
-        *
-        * @note: this does not perform a full wikitext to HTML conversion, it merely applies
-        *        a message transformation.
-        * @todo figure out whether that is actually The Right Thing.
+        * @param string $shortContext a short enclosing context message name, to
+        *        be used when there is a single error
+        * @param string $longContext a long enclosing context message name, for a list
+        * @return String
         */
        public function getHTML( $shortContext = false, $longContext = false ) {
                $text = $this->getWikiText( $shortContext, $longContext );
-               return MessageCache::singleton()->transform( $text, true );
+               $out = MessageCache::singleton()->parse( $text, null, true, true );
+               return $out instanceof ParserOutput ? $out->getText() : $out;
        }
 
        /**