public $mConverter;
public $mVariants, $mCode, $mLoaded = false;
- public $mMagicExtensions = array(), $mMagicHookDone = false;
+ public $mMagicExtensions = [], $mMagicHookDone = false;
private $mHtmlCode = null, $mParentLanguage = false;
- public $dateFormatStrings = array();
+ public $dateFormatStrings = [];
public $mExtendedSpecialPageAliases;
protected $namespaceNames, $mNamespaceIds, $namespaceAliases;
/**
* ReplacementArray object caches
*/
- public $transformData = array();
+ public $transformData = [];
/**
* @var LocalisationCache
*/
static public $dataCache;
- static public $mLangObjCache = array();
+ static public $mLangObjCache = [];
- static public $mWeekdayMsgs = array(
+ static public $mWeekdayMsgs = [
'sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
'friday', 'saturday'
- );
+ ];
- static public $mWeekdayAbbrevMsgs = array(
+ static public $mWeekdayAbbrevMsgs = [
'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'
- );
+ ];
- static public $mMonthMsgs = array(
+ static public $mMonthMsgs = [
'january', 'february', 'march', 'april', 'may_long', 'june',
'july', 'august', 'september', 'october', 'november',
'december'
- );
- static public $mMonthGenMsgs = array(
+ ];
+ static public $mMonthGenMsgs = [
'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen',
'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen',
'december-gen'
- );
- static public $mMonthAbbrevMsgs = array(
+ ];
+ static public $mMonthAbbrevMsgs = [
'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
'sep', 'oct', 'nov', 'dec'
- );
+ ];
- static public $mIranianCalendarMonthMsgs = array(
+ static public $mIranianCalendarMonthMsgs = [
'iranian-calendar-m1', 'iranian-calendar-m2', 'iranian-calendar-m3',
'iranian-calendar-m4', 'iranian-calendar-m5', 'iranian-calendar-m6',
'iranian-calendar-m7', 'iranian-calendar-m8', 'iranian-calendar-m9',
'iranian-calendar-m10', 'iranian-calendar-m11', 'iranian-calendar-m12'
- );
+ ];
- static public $mHebrewCalendarMonthMsgs = array(
+ static public $mHebrewCalendarMonthMsgs = [
'hebrew-calendar-m1', 'hebrew-calendar-m2', 'hebrew-calendar-m3',
'hebrew-calendar-m4', 'hebrew-calendar-m5', 'hebrew-calendar-m6',
'hebrew-calendar-m7', 'hebrew-calendar-m8', 'hebrew-calendar-m9',
'hebrew-calendar-m10', 'hebrew-calendar-m11', 'hebrew-calendar-m12',
'hebrew-calendar-m6a', 'hebrew-calendar-m6b'
- );
+ ];
- static public $mHebrewCalendarMonthGenMsgs = array(
+ static public $mHebrewCalendarMonthGenMsgs = [
'hebrew-calendar-m1-gen', 'hebrew-calendar-m2-gen', 'hebrew-calendar-m3-gen',
'hebrew-calendar-m4-gen', 'hebrew-calendar-m5-gen', 'hebrew-calendar-m6-gen',
'hebrew-calendar-m7-gen', 'hebrew-calendar-m8-gen', 'hebrew-calendar-m9-gen',
'hebrew-calendar-m10-gen', 'hebrew-calendar-m11-gen', 'hebrew-calendar-m12-gen',
'hebrew-calendar-m6a-gen', 'hebrew-calendar-m6b-gen'
- );
+ ];
- static public $mHijriCalendarMonthMsgs = array(
+ static public $mHijriCalendarMonthMsgs = [
'hijri-calendar-m1', 'hijri-calendar-m2', 'hijri-calendar-m3',
'hijri-calendar-m4', 'hijri-calendar-m5', 'hijri-calendar-m6',
'hijri-calendar-m7', 'hijri-calendar-m8', 'hijri-calendar-m9',
'hijri-calendar-m10', 'hijri-calendar-m11', 'hijri-calendar-m12'
- );
+ ];
/**
* @since 1.20
* @var array
*/
- static public $durationIntervals = array(
+ static public $durationIntervals = [
'millennia' => 31556952000,
'centuries' => 3155695200,
'decades' => 315569520,
'hours' => 3600,
'minutes' => 60,
'seconds' => 1,
- );
+ ];
/**
* Cache for language fallbacks.
* @since 1.21
* @var array
*/
- static private $fallbackLanguageCache = array();
+ static private $fallbackLanguageCache = [];
/**
* Cache for language names
: self::newFromCode( $code );
// merge the language object in to get it up front in the cache
- self::$mLangObjCache = array_merge( array( $code => $langObj ), self::$mLangObjCache );
+ self::$mLangObjCache = array_merge( [ $code => $langObj ], self::$mLangObjCache );
// get rid of the oldest ones in case we have an overflow
self::$mLangObjCache = array_slice( self::$mLangObjCache, 0, $wgLangObjCacheSize, true );
* @return bool
*/
public static function isValidCode( $code ) {
- static $cache = array();
+ static $cache = [];
if ( !isset( $cache[$code] ) ) {
// People think language codes are html safe, so enforce it.
// Ideally we should only allow a-zA-Z0-9-
# Re-order by namespace ID number...
ksort( $this->namespaceNames );
- Hooks::run( 'LanguageGetNamespaces', array( &$this->namespaceNames ) );
+ Hooks::run( 'LanguageGetNamespaces', [ &$this->namespaceNames ] );
}
return $this->namespaceNames;
if ( is_null( $this->namespaceAliases ) ) {
$aliases = self::$dataCache->getItem( $this->mCode, 'namespaceAliases' );
if ( !$aliases ) {
- $aliases = array();
+ $aliases = [];
} else {
foreach ( $aliases as $name => $index ) {
if ( $index === NS_PROJECT_TALK ) {
}
# Also add converted namespace names as aliases, to avoid confusion.
- $convertedNames = array();
+ $convertedNames = [];
foreach ( $this->getVariants() as $variant ) {
if ( $variant === $this->mCode ) {
continue;
# If this is too slow, then we should arrange it so that it is done
# before caching. The catch is that at pre-cache time, the above
# class-specific fixup hasn't been done.
- $this->mNamespaceIds = array();
+ $this->mNamespaceIds = [];
foreach ( $this->getNamespaces() as $index => $name ) {
$this->mNamespaceIds[$this->lc( $name )] = $index;
}
}
}
- /**
- * @deprecated since 1.24, doesn't handle conflicting aliases. Use
- * SpecialPageFactory::getLocalNameFor instead.
- * @param string $name
- * @return string
- */
- function specialPage( $name ) {
- $aliases = $this->getSpecialPageAliases();
- if ( isset( $aliases[$name][0] ) ) {
- $name = $aliases[$name][0];
- }
- return $this->getNsText( NS_SPECIAL ) . ':' . $name;
- }
-
/**
* @return array
*/
return $this->getMessageFromDB( "tog-$tog" );
}
- /**
- * Get native language names, indexed by code.
- * Only those defined in MediaWiki, no other data like CLDR.
- * If $customisedOnly is true, only returns codes with a messages file
- *
- * @param bool $customisedOnly
- *
- * @return array
- * @deprecated since 1.20, use fetchLanguageNames()
- */
- public static function getLanguageNames( $customisedOnly = false ) {
- return self::fetchLanguageNames( null, $customisedOnly ? 'mwfile' : 'mw' );
- }
-
- /**
- * Get translated language names. This is done on best effort and
- * by default this is exactly the same as Language::getLanguageNames.
- * The CLDR extension provides translated names.
- * @param string $code Language code.
- * @return array Language code => language name
- * @since 1.18.0
- * @deprecated since 1.20, use fetchLanguageNames()
- */
- public static function getTranslatedLanguageNames( $code ) {
- return self::fetchLanguageNames( $code, 'all' );
- }
-
/**
* Get an array of language names, indexed by code.
* @param null|string $inLanguage Code of language in which to return the names
$cacheKey = $inLanguage === null ? 'null' : $inLanguage;
$cacheKey .= ":$include";
if ( self::$languageNameCache === null ) {
- self::$languageNameCache = new HashBagOStuff( array( 'maxKeys' => 20 ) );
+ self::$languageNameCache = new HashBagOStuff( [ 'maxKeys' => 20 ] );
}
$ret = self::$languageNameCache->get( $cacheKey );
$inLanguage = 'en';
}
- $names = array();
+ $names = [];
if ( $inLanguage ) {
# TODO: also include when $inLanguage is null, when this code is more efficient
- Hooks::run( 'LanguageGetTranslatedLanguageNames', array( &$names, $inLanguage ) );
+ Hooks::run( 'LanguageGetTranslatedLanguageNames', [ &$names, $inLanguage ] );
}
$mwNames = $wgExtraLanguageNames + MediaWiki\Languages\Data\Names::$names;
return $names;
}
- $returnMw = array();
+ $returnMw = [];
$coreCodes = array_keys( $mwNames );
foreach ( $coreCodes as $coreCode ) {
$returnMw[$coreCode] = $names[$coreCode];
}
if ( $include === 'mwfile' ) {
- $namesMwFile = array();
+ $namesMwFile = [];
# We do this using a foreach over the codes instead of a directory
# loop so that messages files in extensions will work correctly.
foreach ( $returnMw as $code => $value ) {
return wfMessage( $msg )->inLanguage( $this );
}
- /**
- * Get the native language name of $code.
- * Only if defined in MediaWiki, no other data like CLDR.
- * @param string $code
- * @return string
- * @deprecated since 1.20, use fetchLanguageName()
- */
- function getLanguageName( $code ) {
- return self::fetchLanguageName( $code );
- }
-
/**
* @param string $key
* @return string
* @return array
*/
function getMonthNamesArray() {
- $monthNames = array( '' );
+ $monthNames = [ '' ];
for ( $i = 1; $i < 13; $i++ ) {
$monthNames[] = $this->getMonthName( $i );
}
* @return array
*/
function getMonthAbbreviationsArray() {
- $monthNames = array( '' );
+ $monthNames = [ '' ];
for ( $i = 1; $i < 13; $i++ ) {
$monthNames[] = $this->getMonthAbbreviation( $i );
}
$ttl = 86400 - substr( $ts, 8, 2 ) * 3600 -
substr( $ts, 10, 2 ) * 60 - substr( $ts, 12, 2 );
} else {
- $possibleTtls = array();
+ $possibleTtls = [];
$timeRemainingInDay = 86400 - substr( $ts, 8, 2 ) * 3600 -
substr( $ts, 10, 2 ) * 60 - substr( $ts, 12, 2 );
if ( $usedWeek ) {
return $s;
}
- private static $GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
- private static $IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 );
+ private static $GREG_DAYS = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
+ private static $IRANIAN_DAYS = [ 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 ];
/**
* Algorithm by Roozbeh Pournader and Mohammad Toossi to convert
$jm = $i + 1;
$jd = $jDayNo + 1;
- return array( $jy, $jm, $jd );
+ return [ $jy, $jm, $jd ];
}
/**
$zd = $zl - (int)( ( 709 * $zm ) / 24 );
$zy = 30 * $zn + $zj - 30;
- return array( $zy, $zm, $zd );
+ return [ $zy, $zm, $zd ];
}
/**
}
}
- return array( $hebrewYear, $hebrewMonth, $hebrewDay, $days );
+ return [ $hebrewYear, $hebrewMonth, $hebrewDay, $days ];
}
/**
$gy_offset = $gy;
}
- return array( $gy_offset, $gm, $gd );
+ return [ $gy_offset, $gm, $gd ];
}
/**
* @return string
*/
static function romanNumeral( $num ) {
- static $table = array(
- array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ),
- array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ),
- array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ),
- array( '', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM', 'MMMMMM', 'MMMMMMM',
- 'MMMMMMMM', 'MMMMMMMMM', 'MMMMMMMMMM' )
- );
+ static $table = [
+ [ '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ],
+ [ '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ],
+ [ '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ],
+ [ '', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM', 'MMMMMM', 'MMMMMMM',
+ 'MMMMMMMM', 'MMMMMMMMM', 'MMMMMMMMMM' ]
+ ];
$num = intval( $num );
if ( $num > 10000 || $num <= 0 ) {
* @return string
*/
static function hebrewNumeral( $num ) {
- static $table = array(
- array( '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ),
- array( '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ),
- array( '',
- array( 'ק' ),
- array( 'ר' ),
- array( 'ש' ),
- array( 'ת' ),
- array( 'ת', 'ק' ),
- array( 'ת', 'ר' ),
- array( 'ת', 'ש' ),
- array( 'ת', 'ת' ),
- array( 'ת', 'ת', 'ק' ),
- array( 'ת', 'ת', 'ר' ),
- ),
- array( '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' )
- );
+ static $table = [
+ [ '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ],
+ [ '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ],
+ [ '',
+ [ 'ק' ],
+ [ 'ר' ],
+ [ 'ש' ],
+ [ 'ת' ],
+ [ 'ת', 'ק' ],
+ [ 'ת', 'ר' ],
+ [ 'ת', 'ש' ],
+ [ 'ת', 'ת' ],
+ [ 'ת', 'ת', 'ק' ],
+ [ 'ת', 'ת', 'ר' ],
+ ],
+ [ '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ]
+ ];
$num = intval( $num );
if ( $num > 9999 || $num <= 0 ) {
return $table[0][$num / 1000] . "' אלפים";
}
- $letters = array();
+ $letters = [];
for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) {
if ( $num >= $pow10 ) {
} else {
$lastIndex = $preTransformLength - 1;
$letters[$lastIndex] = str_replace(
- array( 'כ', 'מ', 'נ', 'פ', 'צ' ),
- array( 'ך', 'ם', 'ן', 'ף', 'ץ' ),
+ [ 'כ', 'מ', 'נ', 'פ', 'צ' ],
+ [ 'ך', 'ם', 'ן', 'ף', 'ץ' ],
$letters[$lastIndex]
);
*
* @return string
*/
- public function formatDuration( $seconds, array $chosenIntervals = array() ) {
+ public function formatDuration( $seconds, array $chosenIntervals = [] ) {
$intervals = $this->getDurationIntervals( $seconds, $chosenIntervals );
- $segments = array();
+ $segments = [];
foreach ( $intervals as $intervalName => $intervalValue ) {
// Messages: duration-seconds, duration-minutes, duration-hours, duration-days, duration-weeks,
*
* @return array
*/
- public function getDurationIntervals( $seconds, array $chosenIntervals = array() ) {
+ public function getDurationIntervals( $seconds, array $chosenIntervals = [] ) {
if ( empty( $chosenIntervals ) ) {
- $chosenIntervals = array(
+ $chosenIntervals = [
'millennia',
'centuries',
'decades',
'hours',
'minutes',
'seconds'
- );
+ ];
}
$intervals = array_intersect_key( self::$durationIntervals, array_flip( $chosenIntervals ) );
$sortedNames = array_keys( $intervals );
$smallestInterval = array_pop( $sortedNames );
- $segments = array();
+ $segments = [];
foreach ( $intervals as $name => $length ) {
$value = floor( $seconds / $length );
*/
private function internalUserTimeAndDate( $type, $ts, User $user, array $options ) {
$ts = wfTimestamp( TS_MW, $ts );
- $options += array( 'timecorrection' => true, 'format' => true );
+ $options += [ 'timecorrection' => true, 'format' => true ];
if ( $options['timecorrection'] !== false ) {
if ( $options['timecorrection'] === true ) {
$offset = $user->getOption( 'timecorrection' );
* @since 1.19
* @return string
*/
- public function userDate( $ts, User $user, array $options = array() ) {
+ public function userDate( $ts, User $user, array $options = [] ) {
return $this->internalUserTimeAndDate( 'date', $ts, $user, $options );
}
* @since 1.19
* @return string
*/
- public function userTime( $ts, User $user, array $options = array() ) {
+ public function userTime( $ts, User $user, array $options = [] ) {
return $this->internalUserTimeAndDate( 'time', $ts, $user, $options );
}
* @since 1.19
* @return string
*/
- public function userTimeAndDate( $ts, User $user, array $options = array() ) {
+ public function userTimeAndDate( $ts, User $user, array $options = [] ) {
return $this->internalUserTimeAndDate( 'both', $ts, $user, $options );
}
$offsetRel = $relativeTo->offsetForUser( $user );
$ts = '';
- if ( Hooks::run( 'GetHumanTimestamp', array( &$ts, $time, $relativeTo, $user, $this ) ) ) {
+ if ( Hooks::run( 'GetHumanTimestamp', [ &$ts, $time, $relativeTo, $user, $this ] ) ) {
$ts = $this->getHumanTimestampInternal( $time, $relativeTo, $user );
}
$x = $first ? '^' : '';
return preg_replace_callback(
"/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
- array( $this, 'ucCallback' ),
+ [ $this, 'ucCallback' ],
$str
);
} else {
$x = $first ? '^' : '';
return preg_replace_callback(
"/$x([A-Z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
- array( $this, 'lcCallback' ),
+ [ $this, 'lcCallback' ],
$str
);
} else {
if ( function_exists( 'mb_strtoupper' ) ) {
return preg_replace_callback(
$replaceRegexp,
- array( $this, 'ucwordsCallbackMB' ),
+ [ $this, 'ucwordsCallbackMB' ],
$str
);
} else {
return preg_replace_callback(
$replaceRegexp,
- array( $this, 'ucwordsCallbackWiki' ),
+ [ $this, 'ucwordsCallbackWiki' ],
$str
);
}
if ( function_exists( 'mb_strtoupper' ) ) {
return preg_replace_callback(
$replaceRegexp,
- array( $this, 'ucwordbreaksCallbackMB' ),
+ [ $this, 'ucwordbreaksCallbackMB' ],
$str
);
} else {
return preg_replace_callback(
$replaceRegexp,
- array( $this, 'ucwordsCallbackWiki' ),
+ [ $this, 'ucwordsCallbackWiki' ],
$str
);
}
} else {
return preg_replace_callback(
'/\b([\w\x80-\xff]+)\b/',
- array( $this, 'ucwordbreaksCallbackAscii' ),
+ [ $this, 'ucwordbreaksCallbackAscii' ],
$str
);
}
/**
* @param string $s
* @return string
+ * @throws MWException
*/
function checkTitleEncoding( $s ) {
if ( is_array( $s ) ) {
* @return string
*/
function firstChar( $s ) {
- $matches = array();
+ $matches = [];
preg_match(
'/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/',
return;
}
$this->mMagicHookDone = true;
- Hooks::run( 'LanguageGetMagic', array( &$this->mMagicExtensions, $this->getCode() ) );
+ Hooks::run( 'LanguageGetMagic', [ &$this->mMagicExtensions, $this->getCode() ] );
}
/**
$this->mExtendedSpecialPageAliases =
self::$dataCache->getItem( $this->mCode, 'specialPageAliases' );
Hooks::run( 'LanguageGetSpecialPageAliases',
- array( &$this->mExtendedSpecialPageAliases, $this->getCode() ) );
+ [ &$this->mExtendedSpecialPageAliases, $this->getCode() ] );
}
return $this->mExtendedSpecialPageAliases;
* Normally we output all numbers in plain en_US style, that is
* 293,291.235 for twohundredninetythreethousand-twohundredninetyone
* point twohundredthirtyfive. However this is not suitable for all
- * languages, some such as Punjabi want ੨੯੩,੨੯੫.੨੩੫ and others such as
+ * languages, some such as Bengali (bn) want ২,৯৩,২৯১.২৩৫ and others such as
* Icelandic just want to use commas instead of dots, and dots instead
* of commas like "293.291,235".
*
$number = strtr( $number, array_flip( $s ) );
}
- $number = strtr( $number, array( ',' => '' ) );
+ $number = strtr( $number, [ ',' => '' ] );
return $number;
}
$sign = "-";
$number = substr( $number, 1 );
}
- $integerPart = array();
- $decimalPart = array();
+ $integerPart = [];
+ $decimalPart = [];
$numMatches = preg_match_all( "/(#+)/", $digitGroupingPattern, $matches );
preg_match( "/\d+/", $number, $integerPart );
preg_match( "/\.\d*/", $number, $decimalPart );
protected function removeBadCharLast( $string ) {
if ( $string != '' ) {
$char = ord( $string[strlen( $string ) - 1] );
- $m = array();
+ $m = [];
if ( $char >= 0xc0 ) {
# We got the first byte only of a multibyte char; remove it.
$string = substr( $string, 0, -1 );
$bracketState = 0; // 1-tag start, 2-tag name, 0-neither
$entityState = 0; // 0-not entity, 1-entity
$tag = $ret = ''; // accumulated tag name, accumulated result string
- $openTags = array(); // open tag stack
+ $openTags = []; // open tag stack
$maybeState = null; // possible truncation state
$textLen = strlen( $text );
# Save where we are; we will truncate here unless there turn out to
# be so few remaining characters that truncation is not necessary.
if ( !$maybeState ) { // already saved? ($neLength = 0 case)
- $maybeState = array( $ret, $openTags ); // save state
+ $maybeState = [ $ret, $openTags ]; // save state
}
} elseif ( $dispLen > $length && $dispLen > strlen( $ellipsis ) ) {
# String in fact does need truncation, the truncation point was OK.
if ( $neLength == 0 && !$maybeState ) {
// Save state without $ch. We want to *hit* the first
// display char (to get tags) but not *use* it if truncating.
- $maybeState = array( substr( $ret, 0, -1 ), $openTags );
+ $maybeState = [ substr( $ret, 0, -1 ), $openTags ];
}
if ( $ch == '&' ) {
$entityState = 1; // entity found, (e.g. " ")
return $wgGrammarForms[$this->getCode()];
}
- return array();
+ return [];
}
/**
* Provides an alternative text depending on specified gender.
* Refresh the cache of conversion tables when
* MediaWiki:Conversiontable* is updated.
*
- * @param Title $titleobj The Title of the page being updated
+ * @param Title $title The Title of the page being updated
*/
public function updateConversionTable( Title $title ) {
$this->mConverter->updateConversionTable( $title );
return self::$dataCache->getItem( $this->mCode, 'linkPrefixCharset' );
}
- /**
- * @deprecated since 1.24, will be removed in 1.25
- * @return Language
- */
- function getLangObj() {
- wfDeprecated( __METHOD__, '1.24' );
- return $this;
- }
-
/**
* Get the "parent" language which has a converter to convert a "compatible" language
* (in another variant) to this language (eg. zh for zh-cn, but not en for en-gb).
return $this->mParentLanguage;
}
- $pieces = explode( '-', $this->getCode() );
- $code = $pieces[0];
+ $code = explode( '-', $this->getCode() )[0];
if ( !in_array( $code, LanguageConverter::$languagesWithVariants ) ) {
$this->mParentLanguage = null;
return null;
}
/**
- * Get the RFC 3066 code for this language object
+ * Get the internal language code for this language object
*
* NOTE: The return value of this function is NOT HTML-safe and must be escaped with
* htmlspecialchars() or similar
}
/**
- * Get the code in Bcp47 format which we can use
+ * Get the code in BCP 47 format which we can use
* inside of html lang="" tags.
*
* NOTE: The return value of this function is NOT HTML-safe and must be escaped with
public static function getMessagesFileName( $code ) {
global $IP;
$file = self::getFileName( "$IP/languages/messages/Messages", $code, '.php' );
- Hooks::run( 'Language::getMessagesFileName', array( $code, &$file ) );
+ Hooks::run( 'Language::getMessagesFileName', [ $code, &$file ] );
return $file;
}
/**
* @param string $code
* @return string
+ * @throws MWException
* @since 1.23
*/
public static function getJsonMessagesFileName( $code ) {
*/
public static function getFallbacksFor( $code ) {
if ( $code === 'en' || !Language::isValidBuiltInCode( $code ) ) {
- return array();
+ return [];
}
// For unknown languages, fallbackSequence returns an empty array,
// hardcode fallback to 'en' in that case.
- return self::getLocalisationCache()->getItem( $code, 'fallbackSequence' ) ?: array( 'en' );
+ return self::getLocalisationCache()->getItem( $code, 'fallbackSequence' ) ?: [ 'en' ];
}
/**
// Eliminate any languages already included in the chain
$siteFallbacks = array_diff( $siteFallbacks, $fallbacks );
- self::$fallbackLanguageCache[$cacheKey] = array( $fallbacks, $siteFallbacks );
+ self::$fallbackLanguageCache[$cacheKey] = [ $fallbacks, $siteFallbacks ];
}
return self::$fallbackLanguageCache[$cacheKey];
}
* @return array Array of message keys (strings)
*/
public static function getMessageKeysFor( $code ) {
- return self::getLocalisationCache()->getSubItemList( $code, 'messages' );
+ return self::getLocalisationCache()->getSubitemList( $code, 'messages' );
}
/**
# such as action=raw much more expensive than they need to be.
# This will hopefully cover most cases.
$talk = preg_replace_callback( '/{{grammar:(.*?)\|(.*?)}}/i',
- array( &$this, 'replaceGrammarInNamespace' ), $talk );
+ [ &$this, 'replaceGrammarInNamespace' ], $talk );
return str_replace( ' ', '_', $talk );
}
static function getCaseMaps() {
static $wikiUpperChars, $wikiLowerChars;
if ( isset( $wikiUpperChars ) ) {
- return array( $wikiUpperChars, $wikiLowerChars );
+ return [ $wikiUpperChars, $wikiLowerChars ];
}
$arr = wfGetPrecompiledData( 'Utf8Case.ser' );
}
$wikiUpperChars = $arr['wikiUpperChars'];
$wikiLowerChars = $arr['wikiLowerChars'];
- return array( $wikiUpperChars, $wikiLowerChars );
+ return [ $wikiUpperChars, $wikiLowerChars ];
}
/**
* @param string $expiry Database expiry String
* @param bool|int $format True to process using language functions, or TS_ constant
* to return the expiry in a given timestamp
- * @param string $inifinity If $format is not true, use this string for infinite expiry
+ * @param string $infinity If $format is not true, use this string for infinite expiry
* @return string
* @since 1.18
*/
* or 'avoidminutes'.
* @return string
*/
- function formatTimePeriod( $seconds, $format = array() ) {
+ function formatTimePeriod( $seconds, $format = [] ) {
if ( !is_array( $format ) ) {
- $format = array( 'avoid' => $format ); // For backwards compatibility
+ $format = [ 'avoid' => $format ]; // For backwards compatibility
}
if ( !isset( $format['avoid'] ) ) {
$format['avoid'] = false;
$s = $hoursMsg->params( $this->formatNum( $hours ) )->text();
$s .= ' ';
$s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text();
- if ( !in_array( $format['avoid'], array( 'avoidseconds', 'avoidminutes' ) ) ) {
+ if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes' ] ) ) {
$s .= ' ' . $secondsMsg->params( $this->formatNum( $secondsPart ) )->text();
}
} else {
$this->getMessageFromDB( str_replace( '$1', '', $messageKey ) )
);
}
- $sizes = array( '', 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa', 'zeta', 'yotta' );
+ $sizes = [ '', 'kilo', 'mega', 'giga', 'tera', 'peta', 'exa', 'zeta', 'yotta' ];
$index = 0;
$maxIndex = count( $sizes ) - 1;
* @return string
*/
public function viewPrevNext( Title $title, $offset, $limit,
- array $query = array(), $atend = false
+ array $query = [], $atend = false
) {
// @todo FIXME: Why on earth this needs one message for the text and another one for tooltip?
}
# Make links to set number of items per page
- $numLinks = array();
- foreach ( array( 20, 50, 100, 250, 500 ) as $num ) {
+ $numLinks = [];
+ foreach ( [ 20, 50, 100, 250, 500 ] as $num ) {
$numLinks[] = $this->numLink( $title, $offset, $num,
$query, $this->formatNum( $num ), 'shown-title', 'mw-numlink' );
}
private function numLink( Title $title, $offset, $limit, array $query, $link,
$tooltipMsg, $class
) {
- $query = array( 'limit' => $limit, 'offset' => $offset ) + $query;
+ $query = [ 'limit' => $limit, 'offset' => $offset ] + $query;
$tooltip = wfMessage( $tooltipMsg )->inLanguage( $this )->title( $title )
->numParams( $limit )->text();
- return Html::element( 'a', array( 'href' => $title->getLocalURL( $query ),
- 'title' => $tooltip, 'class' => $class ), $link );
+ return Html::element( 'a', [ 'href' => $title->getLocalURL( $query ),
+ 'title' => $tooltip, 'class' => $class ], $link );
}
/**