Change name of main page in Sardinian (sc)
[lhc/web/wiklou.git] / languages / Language.php
index 5d5f980..9eea7ab 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 use CLDRPluralRuleParser\Evaluator;
+use Wikimedia\Assert\Assert;
 
 /**
  * Internationalisation code
@@ -385,6 +386,7 @@ class Language {
         */
        public static function isValidCode( $code ) {
                static $cache = [];
+               Assert::parameterType( 'string', $code, '$code' );
                if ( !isset( $cache[$code] ) ) {
                        // People think language codes are html safe, so enforce it.
                        // Ideally we should only allow a-zA-Z0-9-
@@ -404,20 +406,11 @@ class Language {
         *
         * @param string $code
         *
-        * @throws MWException
         * @since 1.18
         * @return bool
         */
        public static function isValidBuiltInCode( $code ) {
-               if ( !is_string( $code ) ) {
-                       if ( is_object( $code ) ) {
-                               $addmsg = " of class " . get_class( $code );
-                       } else {
-                               $addmsg = '';
-                       }
-                       $type = gettype( $code );
-                       throw new MWException( __METHOD__ . " must be passed a string, $type given$addmsg" );
-               }
+               Assert::parameterType( 'string', $code, '$code' );
 
                return (bool)preg_match( '/^[a-z0-9-]{2,}$/', $code );
        }
@@ -2845,9 +2838,9 @@ class Language {
        }
 
        /**
+        * TODO: $s is not always a string per T218883
         * @param string $s
         * @return string
-        * @throws MWException
         */
        function checkTitleEncoding( $s ) {
                if ( is_array( $s ) ) {