protected $origin = self::ORIGIN_CORE_SITEWIDE;
- protected $images = array();
- protected $variants = array();
+ protected $images = [];
+ protected $variants = [];
protected $prefix = null;
protected $selectorWithoutVariant = '.{prefix}-{name}';
protected $selectorWithVariant = '.{prefix}-{name}-{variant}';
- protected $targets = array( 'desktop', 'mobile' );
+ protected $targets = [ 'desktop', 'mobile' ];
/** @var string Position on the page to load this module at */
protected $position = 'bottom';
* @endcode
* @throws InvalidArgumentException
*/
- public function __construct( $options = array(), $localBasePath = null ) {
+ public function __construct( $options = [], $localBasePath = null ) {
$this->localBasePath = self::extractLocalBasePath( $options, $localBasePath );
$this->definition = $options;
}
if ( !isset( $option['default'] ) ) {
// Backwards compatibility
- $option = array( 'default' => $option );
+ $option = [ 'default' => $option ];
}
foreach ( $option as $skin => $data ) {
if ( !is_array( $option ) ) {
*/
public function getSelectors() {
$this->loadFromDefinition();
- return array(
+ return [
'selectorWithoutVariant' => $this->selectorWithoutVariant,
'selectorWithVariant' => $this->selectorWithVariant,
- );
+ ];
}
/**
$skin = $context->getSkin();
if ( !isset( $this->imageObjects ) ) {
$this->loadFromDefinition();
- $this->imageObjects = array();
+ $this->imageObjects = [];
}
if ( !isset( $this->imageObjects[$skin] ) ) {
- $this->imageObjects[$skin] = array();
+ $this->imageObjects[$skin] = [];
if ( !isset( $this->images[$skin] ) ) {
$this->images[$skin] = isset( $this->images['default'] ) ?
$this->images['default'] :
- array();
+ [];
}
foreach ( $this->images[$skin] as $name => $options ) {
$fileDescriptor = is_string( $options ) ? $options : $options['file'];
$allowedVariants = array_merge(
- is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(),
+ is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : [],
$this->getGlobalVariants( $context )
);
if ( isset( $this->variants[$skin] ) ) {
array_fill_keys( $allowedVariants, true )
);
} else {
- $variantConfig = array();
+ $variantConfig = [];
}
$image = new ResourceLoaderImage(
$skin = $context->getSkin();
if ( !isset( $this->globalVariants ) ) {
$this->loadFromDefinition();
- $this->globalVariants = array();
+ $this->globalVariants = [];
}
if ( !isset( $this->globalVariants[$skin] ) ) {
- $this->globalVariants[$skin] = array();
+ $this->globalVariants[$skin] = [];
if ( !isset( $this->variants[$skin] ) ) {
$this->variants[$skin] = isset( $this->variants['default'] ) ?
$this->variants['default'] :
- array();
+ [];
}
foreach ( $this->variants[$skin] as $name => $config ) {
if ( isset( $config['global'] ) && $config['global'] ) {
$this->loadFromDefinition();
// Build CSS rules
- $rules = array();
+ $rules = [];
$script = $context->getResourceLoader()->getLoadScript( $this->getSource() );
$selectors = $this->getSelectors();
$declarations = implode( "\n\t", $declarations );
$selector = strtr(
$selectors['selectorWithoutVariant'],
- array(
+ [
'{prefix}' => $this->getPrefix(),
'{name}' => $name,
'{variant}' => '',
- )
+ ]
);
$rules[] = "$selector {\n\t$declarations\n}";
$declarations = implode( "\n\t", $declarations );
$selector = strtr(
$selectors['selectorWithVariant'],
- array(
+ [
'{prefix}' => $this->getPrefix(),
'{name}' => $name,
'{variant}' => $variant,
- )
+ ]
);
$rules[] = "$selector {\n\t$declarations\n}";
}
}
$style = implode( "\n", $rules );
- return array( 'all' => $style );
+ return [ 'all' => $style ];
}
/**
* @return string[] CSS declarations to use given URIs as background-image
*/
protected function getCssDeclarations( $primary, $fallback ) {
- return array(
+ return [
"background-image: url($fallback);",
"background-image: linear-gradient(transparent, transparent), url($primary);",
// Do not serve SVG to Opera 12, bad rendering with border-radius or background-size (T87504)
"background-image: -o-linear-gradient(transparent, transparent), url($fallback);",
- );
+ ];
}
/**
public function getDefinitionSummary( ResourceLoaderContext $context ) {
$this->loadFromDefinition();
$summary = parent::getDefinitionSummary( $context );
- foreach ( array(
+ foreach ( [
'localBasePath',
'images',
'variants',
'prefix',
'selectorWithoutVariant',
'selectorWithVariant',
- ) as $member ) {
+ ] as $member ) {
$summary[$member] = $this->{$member};
};
return $summary;
*/
public function getModifiedTime( ResourceLoaderContext $context ) {
$this->loadFromDefinition();
- $files = array();
+ $files = [];
foreach ( $this->getImages( $context ) as $name => $image ) {
$files[] = $image->getPath( $context );
}
$files = array_values( array_unique( $files ) );
- $filesMtime = max( array_map( array( __CLASS__, 'safeFilemtime' ), $files ) );
+ $filesMtime = max( array_map( [ __CLASS__, 'safeFilemtime' ], $files ) );
return $filesMtime;
}