diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /includes/title/TitleValue.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'includes/title/TitleValue.php')
-rw-r--r-- | includes/title/TitleValue.php | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/includes/title/TitleValue.php b/includes/title/TitleValue.php index 5cac3470..a0f3b6f9 100644 --- a/includes/title/TitleValue.php +++ b/includes/title/TitleValue.php @@ -21,6 +21,7 @@ * @license GPL 2+ * @author Daniel Kinzler */ +use Wikimedia\Assert\Assert; /** * Represents a page (or page fragment) title within %MediaWiki. @@ -67,26 +68,13 @@ class TitleValue { * @throws InvalidArgumentException */ public function __construct( $namespace, $dbkey, $fragment = '' ) { - if ( !is_int( $namespace ) ) { - throw new InvalidArgumentException( '$namespace must be an integer' ); - } - - if ( !is_string( $dbkey ) ) { - throw new InvalidArgumentException( '$dbkey must be a string' ); - } + Assert::parameterType( 'integer', $namespace, '$namespace' ); + Assert::parameterType( 'string', $dbkey, '$dbkey' ); + Assert::parameterType( 'string', $fragment, '$fragment' ); // Sanity check, no full validation or normalization applied here! - if ( preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ) ) { - throw new InvalidArgumentException( '$dbkey must be a valid DB key: ' . $dbkey ); - } - - if ( !is_string( $fragment ) ) { - throw new InvalidArgumentException( '$fragment must be a string' ); - } - - if ( $dbkey === '' ) { - throw new InvalidArgumentException( '$dbkey must not be empty' ); - } + Assert::parameter( !preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ), '$dbkey', 'invalid DB key' ); + Assert::parameter( $dbkey !== '', '$dbkey', 'should not be empty' ); $this->namespace = $namespace; $this->dbkey = $dbkey; |