Fix issues identified by SpaceBeforeSingleLineComment sniff
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index 8a30ad1..42091a0 100644 (file)
@@ -60,7 +60,11 @@ class CoreParserFunctions {
                        $parser->setFunctionHook( $func, array( __CLASS__, $func ), Parser::SFH_NO_HASH );
                }
 
-               $parser->setFunctionHook( 'namespace', array( __CLASS__, 'mwnamespace' ), Parser::SFH_NO_HASH );
+               $parser->setFunctionHook(
+                       'namespace',
+                       array( __CLASS__, 'mwnamespace' ),
+                       Parser::SFH_NO_HASH
+               );
                $parser->setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), Parser::SFH_NO_HASH );
                $parser->setFunctionHook( 'special', array( __CLASS__, 'special' ) );
                $parser->setFunctionHook( 'speciale', array( __CLASS__, 'speciale' ) );
@@ -68,7 +72,11 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
 
                if ( $wgAllowDisplayTitle ) {
-                       $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), Parser::SFH_NO_HASH );
+                       $parser->setFunctionHook(
+                               'displaytitle',
+                               array( __CLASS__, 'displaytitle' ),
+                               Parser::SFH_NO_HASH
+                       );
                }
                if ( $wgAllowSlowParserFunctions ) {
                        $parser->setFunctionHook(
@@ -88,9 +96,13 @@ class CoreParserFunctions {
                if ( strval( $part1 ) !== '' ) {
                        $args = array_slice( func_get_args(), 2 );
                        $message = wfMessage( $part1, $args )
-                               ->inLanguage( $parser->getOptions()->getUserLangObj() )->plain();
-
-                       return array( $message, 'noparse' => false );
+                               ->inLanguage( $parser->getOptions()->getUserLangObj() );
+                       if ( !$message->exists() ) {
+                               // When message does not exists, the message name is surrounded by angle
+                               // and can result in a tag, therefore escape the angles
+                               return $message->escaped();
+                       }
+                       return array( $message->plain(), 'noparse' => false );
                } else {
                        return array( 'found' => false );
                }
@@ -692,15 +704,15 @@ class CoreParserFunctions {
 
                // split the given option to its variable
                if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
-                       //{{pagesincategory:|raw[|type]}}
+                       // {{pagesincategory:|raw[|type]}}
                        $raw = $arg1;
                        $type = $magicWords->matchStartToEnd( $arg2 );
                } else {
-                       //{{pagesincategory:[|type[|raw]]}}
+                       // {{pagesincategory:[|type[|raw]]}}
                        $type = $magicWords->matchStartToEnd( $arg1 );
                        $raw = $arg2;
                }
-               if ( !$type ) { //backward compatibility
+               if ( !$type ) { // backward compatibility
                        $type = 'pagesincategory_all';
                }
 
@@ -806,7 +818,9 @@ class CoreParserFunctions {
         * @param int $direction
         * @return string
         */
-       public static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
+       public static function pad(
+               $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
+       ) {
                $padding = $parser->killMarkers( $padding );
                $lengthOfPadding = mb_strlen( $padding );
                if ( $lengthOfPadding == 0 ) {