* by a prefix. If you want to force a specific namespace even if
* $text might begin with a namespace prefix, use makeTitle() or
* makeTitleSafe().
- * @throws MWException
+ * @throws InvalidArgumentException
* @return Title|null Title or null on an error.
*/
public static function newFromText( $text, $defaultNamespace = NS_MAIN ) {
- if ( is_object( $text ) ) {
- throw new MWException( 'Title::newFromText given an object' );
+ if ( !is_string( $text ) ) {
+ throw new InvalidArgumentException( 'Title::newFromText given something that isn\'t a string' );
}
$cache = self::getTitleCache();
* @return bool
*/
public function has( $key ) {
- return array_key_exists( $key, $this->cache );
+ if ( is_string( $key ) || is_integer( $key ) ) {
+ return array_key_exists( $key, $this->cache );
+ }
+ wfWarn( __METHOD__ . ": Key passed isn't a string or an integer.", 2 );
+ return false;
}
/**
// @codingStandardsIgnoreStart Ignore long line warning
/**
- * @expectedException MWException object
+ * @expectedException InvalidArgumentException
* See http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.expectedException
*/
// @codingStandardsIgnoreEnd