This make isValidBuiltInCode to throw an exception whenever it is passed
something which is not a string. The rational being to easily find out
errors when the method is wrongly used.
An alternative would be to detect the object being passed is a Language
object and get its Language code.
Change-Id: I37cc419cc725df8d8022e619d8f5191f58a8fd5e
* @return bool
*/
public static function isValidBuiltInCode( $code ) {
+
+ if( !is_string($code) ) {
+ $type = gettype( $code );
+ if( $type === 'object' ) {
+ $addmsg = " of class " . get_class( $code );
+ }
+ throw new MWException( __METHOD__ . " must be passed a string, $type given$addmsg" );
+ }
+
return preg_match( '/^[a-z0-9-]+$/i', $code );
}