# function callback,
# optional Parser::SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}}
# instead of {{#int:...}})
- $noHashFunctions = array(
+ $noHashFunctions = [
'ns', 'nse', 'urlencode', 'lcfirst', 'ucfirst', 'lc', 'uc',
'localurl', 'localurle', 'fullurl', 'fullurle', 'canonicalurl',
'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural', 'bidi',
'subjectpagenamee', 'pageid', 'revisionid', 'revisionday',
'revisionday2', 'revisionmonth', 'revisionmonth1', 'revisionyear',
'revisiontimestamp', 'revisionuser', 'cascadingsources',
- );
+ ];
foreach ( $noHashFunctions as $func ) {
- $parser->setFunctionHook( $func, array( __CLASS__, $func ), Parser::SFH_NO_HASH );
+ $parser->setFunctionHook( $func, [ __CLASS__, $func ], Parser::SFH_NO_HASH );
}
$parser->setFunctionHook(
'namespace',
- array( __CLASS__, 'mwnamespace' ),
+ [ __CLASS__, 'mwnamespace' ],
Parser::SFH_NO_HASH
);
- $parser->setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), Parser::SFH_NO_HASH );
- $parser->setFunctionHook( 'special', array( __CLASS__, 'special' ) );
- $parser->setFunctionHook( 'speciale', array( __CLASS__, 'speciale' ) );
- $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), Parser::SFH_OBJECT_ARGS );
- $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
+ $parser->setFunctionHook( 'int', [ __CLASS__, 'intFunction' ], Parser::SFH_NO_HASH );
+ $parser->setFunctionHook( 'special', [ __CLASS__, 'special' ] );
+ $parser->setFunctionHook( 'speciale', [ __CLASS__, 'speciale' ] );
+ $parser->setFunctionHook( 'tag', [ __CLASS__, 'tagObj' ], Parser::SFH_OBJECT_ARGS );
+ $parser->setFunctionHook( 'formatdate', [ __CLASS__, 'formatDate' ] );
if ( $wgAllowDisplayTitle ) {
$parser->setFunctionHook(
'displaytitle',
- array( __CLASS__, 'displaytitle' ),
+ [ __CLASS__, 'displaytitle' ],
Parser::SFH_NO_HASH
);
}
if ( $wgAllowSlowParserFunctions ) {
$parser->setFunctionHook(
'pagesinnamespace',
- array( __CLASS__, 'pagesinnamespace' ),
+ [ __CLASS__, 'pagesinnamespace' ],
Parser::SFH_NO_HASH
);
}
// and can result in a tag, therefore escape the angles
return $message->escaped();
}
- return array( $message->plain(), 'noparse' => false );
+ return [ $message->plain(), 'noparse' => false ];
} else {
- return array( 'found' => false );
+ return [ 'found' => false ];
}
}
$pref = $defaultPref;
}
- $date = $df->reformat( $pref, $date, array( 'match-whole' ) );
+ $date = $df->reformat( $pref, $date, [ 'match-whole' ] );
return $date;
}
if ( $index !== false ) {
return $wgContLang->getFormattedNsText( $index );
} else {
- return array( 'found' => false );
+ return [ 'found' => false ];
}
}
public static function urlencode( $parser, $s = '', $arg = null ) {
static $magicWords = null;
if ( is_null( $magicWords ) ) {
- $magicWords = new MagicWordArray( array( 'url_path', 'url_query', 'url_wiki' ) );
+ $magicWords = new MagicWordArray( [ 'url_path', 'url_query', 'url_wiki' ] );
}
switch ( $magicWords->matchStartToEnd( $arg ) ) {
*/
public static function lc( $parser, $s = '' ) {
global $wgContLang;
- return $parser->markerSkipCallback( $s, array( $wgContLang, 'lc' ) );
+ return $parser->markerSkipCallback( $s, [ $wgContLang, 'lc' ] );
}
/**
*/
public static function uc( $parser, $s = '' ) {
global $wgContLang;
- return $parser->markerSkipCallback( $s, array( $wgContLang, 'uc' ) );
+ return $parser->markerSkipCallback( $s, [ $wgContLang, 'uc' ] );
}
public static function localurl( $parser, $s = '', $arg = null ) {
}
return $text;
} else {
- return array( 'found' => false );
+ return [ 'found' => false ];
}
}
*/
public static function formatnum( $parser, $num = '', $arg = null ) {
if ( self::matchAgainstMagicword( 'rawsuffix', $arg ) ) {
- $func = array( $parser->getFunctionLang(), 'parseFormattedNumber' );
+ $func = [ $parser->getFunctionLang(), 'parseFormattedNumber' ];
} elseif ( self::matchAgainstMagicword( 'nocommafysuffix', $arg ) ) {
- $func = array( $parser->getFunctionLang(), 'formatNumNoSeparators' );
+ $func = [ $parser->getFunctionLang(), 'formatNumNoSeparators' ];
} else {
- $func = array( $parser->getFunctionLang(), 'formatNum' );
+ $func = [ $parser->getFunctionLang(), 'formatNum' ];
}
return $parser->markerSkipCallback( $num, $func );
}
static $magicWords = null;
if ( is_null( $magicWords ) ) {
- $magicWords = new MagicWordArray( array( 'displaytitle_noerror', 'displaytitle_noreplace' ) );
+ $magicWords = new MagicWordArray( [ 'displaytitle_noerror', 'displaytitle_noreplace' ] );
}
$arg = $magicWords->matchStartToEnd( $uarg );
// list of disallowed tags for DISPLAYTITLE
// these will be escaped even though they are allowed in normal wiki text
- $bad = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
- 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' );
+ $bad = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'blockquote', 'ol', 'ul', 'li', 'hr',
+ 'table', 'tr', 'th', 'td', 'dl', 'dd', 'caption', 'p', 'ruby', 'rb', 'rt', 'rtc', 'rp', 'br' ];
// disallow some styles that could be used to bypass $wgRestrictDisplayTitle
if ( $wgRestrictDisplayTitle ) {
$text = Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags(
$text,
$htmlTagsCallback,
- array(),
- array(),
+ [],
+ [],
$bad
) );
$title = Title::newFromText( Sanitizer::stripAllTags( $text ) );
if ( is_null( $t ) ) {
return '';
}
- return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getRootText() ) ) );
+ return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getRootText() ) ) );
}
public static function basepagename( $parser, $title = null ) {
$t = Title::newFromText( $title );
if ( is_null( $t ) ) {
return '';
}
- return wfEscapeWikiText( wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) ) );
+ return wfEscapeWikiText( wfUrlencode( str_replace( ' ', '_', $t->getBaseText() ) ) );
}
public static function talkpagename( $parser, $title = null ) {
$t = Title::newFromText( $title );
global $wgContLang;
static $magicWords = null;
if ( is_null( $magicWords ) ) {
- $magicWords = new MagicWordArray( array(
+ $magicWords = new MagicWordArray( [
'pagesincategory_all',
'pagesincategory_pages',
'pagesincategory_subcats',
'pagesincategory_files'
- ) );
+ ] );
}
- static $cache = array();
+ static $cache = [];
// split the given option to its variable
if ( self::matchAgainstMagicword( 'rawsuffix', $arg1 ) ) {
public static function defaultsort( $parser, $text, $uarg = '' ) {
static $magicWords = null;
if ( is_null( $magicWords ) ) {
- $magicWords = new MagicWordArray( array( 'defaultsort_noerror', 'defaultsort_noreplace' ) );
+ $magicWords = new MagicWordArray( [ 'defaultsort_noerror', 'defaultsort_noreplace' ] );
}
$arg = $magicWords->matchStartToEnd( $uarg );
}
}
if ( $isNowiki ) {
- return array( $url, 'nowiki' => true );
+ return [ $url, 'nowiki' => true ];
}
return $url;
} else {
$inner = null;
}
- $attributes = array();
+ $attributes = [];
foreach ( $args as $arg ) {
$bits = $arg->splitArg();
if ( strval( $bits['index'] ) === '' ) {
return "<$tagName$attrText>$inner</$tagName>";
}
- $params = array(
+ $params = [
'name' => $tagName,
'inner' => $inner,
'attributes' => $attributes,
'close' => "</$tagName>",
- );
+ ];
return $parser->extensionSubstitution( $params, $frame );
}
if ( $titleObject->areCascadeProtectionSourcesLoaded()
|| $parser->incrementExpensiveFunctionCount()
) {
- $names = array();
+ $names = [];
$sources = $titleObject->getCascadeProtectionSources();
foreach ( $sources[0] as $sourceTitle ) {
$names[] = $sourceTitle->getPrefixedText();