private $currentLang = null;
/** @var array Localisation data. */
- private $data = array();
+ private $data = [];
/** @var string File name. */
private $fname = null;
/** @var string Directory for cache files. */
private $directory;
- public function __construct( $conf = array() ) {
+ public function __construct( $conf = [] ) {
global $wgCacheDirectory;
if ( isset( $conf['directory'] ) ) {
public function startWrite( $code ) {
$this->currentLang = $code;
- $this->fname = $this->directory. '/' . $code . '.l10n.php';
- $this->data[$code] = array();
+ $this->fname = $this->directory . '/' . $code . '.l10n.php';
+ $this->data[$code] = [];
if ( file_exists( $this->fname ) ) {
$this->data[$code] = require $this->fname;
}
public static function encode( $value ) {
if ( is_scalar( $value ) || $value === null ) {
// [V]alue
- return array( 'v', $value );
+ return [ 'v', $value ];
}
if ( is_object( $value ) ) {
// [S]erialized
- return array( 's', serialize( $value ) );
+ return [ 's', serialize( $value ) ];
}
if ( is_array( $value ) ) {
// [A]rray
- return array( 'a', array_map( function ( $v ) {
+ return [ 'a', array_map( function ( $v ) {
return LCStoreStaticArray::encode( $v );
- }, $data ) );
+ }, $value ) ];
}
throw new RuntimeException( 'Cannot encode ' . var_export( $value, true ) );
public function get( $code, $key ) {
if ( !array_key_exists( $code, $this->data ) ) {
- $fname = $this->directory. '/' . $code . '.l10n.php';
+ $fname = $this->directory . '/' . $code . '.l10n.php';
if ( !file_exists( $fname ) ) {
return null;
}