* @param string[]|string $localInterwikis
*/
public function __construct( Language $language, GenderCache $genderCache,
- $localInterwikis = array()
+ $localInterwikis = []
) {
$this->language = $language;
$this->genderCache = $genderCache;
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string $title->getText()
*/
- public function getText( TitleValue $title ) {
+ public function getText( LinkTarget $title ) {
return $this->formatTitle( false, $title->getText(), '' );
}
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string
*/
- public function getPrefixedText( TitleValue $title ) {
+ public function getPrefixedText( LinkTarget $title ) {
return $this->formatTitle( $title->getNamespace(), $title->getText(), '' );
}
/**
* @see TitleFormatter::getText()
*
- * @param TitleValue $title
+ * @param LinkTarget $title
*
* @return string
*/
- public function getFullText( TitleValue $title ) {
+ public function getFullText( LinkTarget $title ) {
return $this->formatTitle( $title->getNamespace(), $title->getText(), $title->getFragment() );
}
* @param int $defaultNamespace
*
* @throws MalformedTitleException If $text is not a valid title string.
- * @return array A mapp with the fields 'interwiki', 'fragment', 'namespace',
+ * @return array A map with the fields 'interwiki', 'fragment', 'namespace',
* 'user_case_dbkey', and 'dbkey'.
*/
public function splitTitleString( $text, $defaultNamespace = NS_MAIN ) {
$dbkey = str_replace( ' ', '_', $text );
# Initialisation
- $parts = array(
+ $parts = [
'interwiki' => '',
'local_interwiki' => false,
'fragment' => '',
'namespace' => $defaultNamespace,
'dbkey' => $dbkey,
'user_case_dbkey' => $dbkey,
- );
+ ];
# Strip Unicode bidi override characters.
# Sometimes they slip into cut-n-pasted page titles, where the
# Namespace or interwiki prefix
$prefixRegexp = "/^(.+?)_*:_*(.*)$/S";
do {
- $m = array();
+ $m = [];
if ( preg_match( $prefixRegexp, $dbkey, $m ) ) {
$p = $m[1];
$ns = $this->language->getNsIndex( $p );
# Empty self-links should point to the Main Page, to ensure
# compatibility with cross-wiki transclusions and the like.
$mainPage = Title::newMainPage();
- return array(
+ return [
'interwiki' => $mainPage->getInterwiki(),
'local_interwiki' => true,
'fragment' => $mainPage->getFragment(),
'namespace' => $mainPage->getNamespace(),
'dbkey' => $mainPage->getDBkey(),
'user_case_dbkey' => $mainPage->getUserCaseDBKey()
- );
+ ];
}
$parts['interwiki'] = '';
# local interwikis should behave like initial-colon links
# Reject illegal characters.
$rxTc = self::getTitleInvalidRegex();
- $matches = array();
+ $matches = [];
if ( preg_match( $rxTc, $dbkey, $matches ) ) {
- throw new MalformedTitleException( 'title-invalid-characters', $text, array( $matches[0] ) );
+ throw new MalformedTitleException( 'title-invalid-characters', $text, [ $matches[0] ] );
}
# Pages with "/./" or "/../" appearing in the URLs will often be un-
$maxLength = ( $parts['namespace'] != NS_SPECIAL ) ? 255 : 512;
if ( strlen( $dbkey ) > $maxLength ) {
throw new MalformedTitleException( 'title-invalid-too-long', $text,
- array( Message::numParam( $maxLength ) ) );
+ [ Message::numParam( $maxLength ) ] );
}
# Normally, all wiki links are forced to have an initial capital letter so [[foo]]