}
// get the language object to process
- $langObj = isset( self::$mLangObjCache[$code] )
- ? self::$mLangObjCache[$code]
- : self::newFromCode( $code );
+ $langObj = self::$mLangObjCache[$code] ?? self::newFromCode( $code );
// merge the language object in to get it up front in the cache
self::$mLangObjCache = array_merge( [ $code => $langObj ], self::$mLangObjCache );
*/
public function getNsText( $index ) {
$ns = $this->getNamespaces();
- return isset( $ns[$index] ) ? $ns[$index] : false;
+ return $ns[$index] ?? false;
}
/**
$ns = $wgExtraGenderNamespaces +
(array)self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' );
- return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index );
+ return $ns[$index][$gender] ?? $this->getNsText( $index );
}
/**
function getLocalNsIndex( $text ) {
$lctext = $this->lc( $text );
$ids = $this->getNamespaceIds();
- return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
+ return $ids[$lctext] ?? false;
}
/**
return $ns;
}
$ids = $this->getNamespaceIds();
- return isset( $ids[$lctext] ) ? $ids[$lctext] : false;
+ return $ids[$lctext] ?? false;
}
/**
global $wgAllUnicodeFixes;
$s = UtfNormal\Validator::cleanUp( $s );
if ( $wgAllUnicodeFixes ) {
- $s = $this->transformUsingPairFile( 'normalize-ar.ser', $s );
- $s = $this->transformUsingPairFile( 'normalize-ml.ser', $s );
+ $s = $this->transformUsingPairFile( 'normalize-ar.php', $s );
+ $s = $this->transformUsingPairFile( 'normalize-ml.php', $s );
}
return $s;
* @throws MWException
* @return string
*/
- function transformUsingPairFile( $file, $string ) {
+ protected function transformUsingPairFile( $file, $string ) {
if ( !isset( $this->transformData[$file] ) ) {
- $data = wfGetPrecompiledData( $file );
- if ( $data === false ) {
- throw new MWException( __METHOD__ . ": The transformation file $file is missing" );
- }
+ global $IP;
+ $data = require "$IP/languages/data/{$file}";
$this->transformData[$file] = new ReplacementArray( $data );
}
return $this->transformData[$file]->replace( $string );
if ( $gender === 'female' ) {
return $forms[1];
}
- return isset( $forms[2] ) ? $forms[2] : $forms[0];
+ return $forms[2] ?? $forms[0];
}
/**