<?php
/**
- * Representation of a page title within %MediaWiki.
+ * Representation of a page title within MediaWiki.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @license GPL 2+
* @author Daniel Kinzler
*/
use MediaWiki\Linker\LinkTarget;
use Wikimedia\Assert\Assert;
/**
- * Represents a page (or page fragment) title within %MediaWiki.
+ * Represents a page (or page fragment) title within MediaWiki.
*
* @note In contrast to Title, this is designed to be a plain value object. That is,
* it is immutable, does not use global state, and causes no side effects.
* @since 1.23
*/
class TitleValue implements LinkTarget {
+
/**
+ * @deprecated in 1.31. This class is immutable. Use the getter for access.
* @var int
*/
protected $namespace;
/**
+ * @deprecated in 1.31. This class is immutable. Use the getter for access.
* @var string
*/
protected $dbkey;
/**
+ * @deprecated in 1.31. This class is immutable. Use the getter for access.
* @var string
*/
protected $fragment;
/**
+ * @deprecated in 1.31. This class is immutable. Use the getter for access.
* @var string
*/
protected $interwiki;
Assert::parameterType( 'string', $interwiki, '$interwiki' );
// Sanity check, no full validation or normalization applied here!
- Assert::parameter( !preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ), '$dbkey', 'invalid DB key' );
+ Assert::parameter( !preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ), '$dbkey',
+ "invalid DB key '$dbkey'" );
Assert::parameter( $dbkey !== '', '$dbkey', 'should not be empty' );
$this->namespace = $namespace;
}
/**
+ * @since 1.23
* @return int
*/
public function getNamespace() {
}
/**
+ * @since 1.27
+ * @param int $ns
+ * @return bool
+ */
+ public function inNamespace( $ns ) {
+ return $this->namespace == $ns;
+ }
+
+ /**
+ * @since 1.23
* @return string
*/
public function getFragment() {
/**
* Returns the title's DB key, as supplied to the constructor,
* without namespace prefix or fragment.
+ * @since 1.23
*
* @return string
*/
/**
* Returns the title in text form,
* without namespace prefix or fragment.
+ * @since 1.23
*
* This is computed from the DB key by replacing any underscores with spaces.
*
* Returns a string representation of the title, for logging. This is purely informative
* and must not be used programmatically. Use the appropriate TitleFormatter to generate
* the correct string representation for a given use.
+ * @since 1.23
*
* @return string
*/