Merge "Use the ?? feature instead of isset() where it makes sense"
[lhc/web/wiklou.git] / languages / Language.php
index 5ac2882..9eea7ab 100644 (file)
@@ -386,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-
@@ -2837,11 +2838,14 @@ class Language {
        }
 
        /**
+        * TODO: $s is not always a string per T218883
         * @param string $s
         * @return string
         */
        function checkTitleEncoding( $s ) {
-               Assert::parameterType( 'string', $s, '$s' );
+               if ( is_array( $s ) ) {
+                       throw new MWException( 'Given array to checkTitleEncoding.' );
+               }
                if ( StringUtils::isUtf8( $s ) ) {
                        return $s;
                }