Merge "PHAN: conditionally load stubs"
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index ef26db6..6aa3acc 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  * @ingroup Parser
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Various core parser functions, registered in Parser::firstCallInit()
@@ -275,7 +276,7 @@ class CoreParserFunctions {
                }
                if ( !is_null( $title ) ) {
                        # Convert NS_MEDIA -> NS_FILE
-                       if ( $title->getNamespace() == NS_MEDIA ) {
+                       if ( $title->inNamespace( NS_MEDIA ) ) {
                                $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
                        }
                        if ( !is_null( $arg ) ) {
@@ -340,16 +341,17 @@ class CoreParserFunctions {
                // allow prefix.
                $title = Title::newFromText( $username );
 
-               if ( $title && $title->getNamespace() == NS_USER ) {
+               if ( $title && $title->inNamespace( NS_USER ) ) {
                        $username = $title->getText();
                }
 
                // check parameter, or use the ParserOptions if in interface message
                $user = User::newFromName( $username );
+               $genderCache = MediaWikiServices::getInstance()->getGenderCache();
                if ( $user ) {
-                       $gender = GenderCache::singleton()->getGenderOf( $user, __METHOD__ );
+                       $gender = $genderCache->getGenderOf( $user, __METHOD__ );
                } elseif ( $username === '' && $parser->getOptions()->getInterfaceMessage() ) {
-                       $gender = GenderCache::singleton()->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
+                       $gender = $genderCache->getGenderOf( $parser->getOptions()->getUser(), __METHOD__ );
                }
                $ret = $parser->getFunctionLang()->gender( $gender, $forms );
                return $ret;
@@ -487,7 +489,15 @@ class CoreParserFunctions {
                return $mwObject->matchStartToEnd( $value );
        }
 
-       public static function formatRaw( $num, $raw, Language $language ) {
+       /**
+        * Formats a number according to a language.
+        *
+        * @param int|float $num
+        * @param string $raw
+        * @param Language|StubUserLang $language
+        * @return string
+        */
+       public static function formatRaw( $num, $raw, $language ) {
                if ( self::matchAgainstMagicword( 'rawsuffix', $raw ) ) {
                        return $num;
                } else {