/* Protected Members */
protected $name = null;
- protected $targets = array( 'desktop' );
+ protected $targets = [ 'desktop' ];
// In-object cache for file dependencies
- protected $fileDeps = array();
+ protected $fileDeps = [];
// In-object cache for message blob (keyed by language)
- protected $msgBlobs = array();
+ protected $msgBlobs = [];
// In-object cache for version hash
- protected $versionHash = array();
+ protected $versionHash = [];
// In-object cache for module content
- protected $contents = array();
+ protected $contents = [];
/**
* @var Config
*/
public function getTemplates() {
// Stub, override expected.
- return array();
+ return [];
}
/**
public function getScriptURLsForDebug( ResourceLoaderContext $context ) {
$resourceLoader = $context->getResourceLoader();
$derivative = new DerivativeResourceLoaderContext( $context );
- $derivative->setModules( array( $this->getName() ) );
+ $derivative->setModules( [ $this->getName() ] );
$derivative->setOnly( 'scripts' );
$derivative->setDebug( true );
$derivative
);
- return array( $url );
+ return [ $url ];
}
/**
*/
public function getStyles( ResourceLoaderContext $context ) {
// Stub, override expected
- return array();
+ return [];
}
/**
public function getStyleURLsForDebug( ResourceLoaderContext $context ) {
$resourceLoader = $context->getResourceLoader();
$derivative = new DerivativeResourceLoaderContext( $context );
- $derivative->setModules( array( $this->getName() ) );
+ $derivative->setModules( [ $this->getName() ] );
$derivative->setOnly( 'styles' );
$derivative->setDebug( true );
$derivative
);
- return array( 'all' => array( $url ) );
+ return [ 'all' => [ $url ] ];
}
/**
*/
public function getMessages() {
// Stub, override expected
- return array();
+ return [];
}
/**
*/
public function getDependencies( ResourceLoaderContext $context = null ) {
// Stub, override expected
- return array();
+ return [];
}
/**
$dbr = wfGetDB( DB_SLAVE );
$deps = $dbr->selectField( 'module_deps',
'md_deps',
- array(
+ [
'md_module' => $this->getName(),
'md_skin' => $vary,
- ),
+ ],
__METHOD__
);
(array)FormatJson::decode( $deps, true )
);
} else {
- $this->fileDeps[$vary] = array();
+ $this->fileDeps[$vary] = [];
}
}
return $this->fileDeps[$vary];
$vary = $context->getSkin() . '|' . $context->getLanguage();
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'module_deps',
- array( array( 'md_module', 'md_skin' ) ),
- array(
+ [ [ 'md_module', 'md_skin' ] ],
+ [
'md_module' => $this->getName(),
'md_skin' => $vary,
// Use relative paths to avoid ghost entries when $IP changes (T111481)
'md_deps' => FormatJson::encode( self::getRelativePaths( $localFileRefs ) ),
- )
+ ]
);
$dbw->onTransactionIdle( function () use ( &$scopeLock ) {
// Message blobs may only vary language, not by context keys
$lang = $context->getLanguage();
if ( !isset( $this->msgBlobs[$lang] ) ) {
- $this->getLogger()->warning( 'Message blob for {module} should have been preloaded', array(
+ $this->getLogger()->warning( 'Message blob for {module} should have been preloaded', [
'module' => $this->getName(),
- ) );
+ ] );
$store = $context->getResourceLoader()->getMessageBlobStore();
$this->msgBlobs[$lang] = $store->getBlob( $this, $lang );
}
* @return array Module-specific LESS variables.
*/
protected function getLessVars( ResourceLoaderContext $context ) {
- return array();
+ return [];
}
/**
// and that are non-empty (e.g. don't include "templates" for modules without
// templates). This helps prevent invalidating cache for all modules when new
// optional properties are introduced.
- $content = array();
+ $content = [];
// Scripts
if ( $context->shouldIncludeScripts() ) {
// Styles
if ( $context->shouldIncludeStyles() ) {
- $styles = array();
+ $styles = [];
// Don't create empty stylesheets like array( '' => '' ) for modules
// that don't *have* any stylesheets (bug 38024).
$stylePairs = $this->getStyles( $context );
// If we are in debug mode without &only= set, we'll want to return an array of URLs
// See comment near shouldIncludeScripts() for more details
if ( $context->getDebug() && !$context->getOnly() && $this->supportsURLLoading() ) {
- $styles = array(
+ $styles = [
'url' => $this->getStyleURLsForDebug( $context )
- );
+ ];
} else {
// Minify CSS before embedding in mw.loader.implement call
// (unless in debug mode)
foreach ( $stylePairs as $media => $style ) {
// Can be either a string or an array of strings.
if ( is_array( $style ) ) {
- $stylePairs[$media] = array();
+ $stylePairs[$media] = [];
foreach ( $style as $cssText ) {
if ( is_string( $cssText ) ) {
$stylePairs[$media][] =
}
}
// Wrap styles into @media groups as needed and flatten into a numerical array
- $styles = array(
+ $styles = [
'css' => $rl->makeCombinedStyles( $stylePairs )
- );
+ ];
}
}
$content['styles'] = $styles;
// Typically, the request for the startup module itself has only=scripts. That must apply
// only to the startup module content, and not to the module version computed here.
$context = new DerivativeResourceLoaderContext( $context );
- $context->setModules( array() );
+ $context->setModules( [] );
// Version hash must cover all resources, regardless of startup request itself.
$context->setOnly( null );
// Compute version hash based on content, not debug urls.
* @return array|null
*/
public function getDefinitionSummary( ResourceLoaderContext $context ) {
- return array(
+ return [
'_class' => get_class( $this ),
'_cacheEpoch' => $this->getConfig()->get( 'CacheEpoch' ),
- );
+ ];
}
/**