From: Siebrand Mazeland Date: Sat, 10 May 2014 08:39:37 +0000 (+0200) Subject: Pass phpcs-strict on includes/resourceloader/ X-Git-Tag: 1.31.0-rc.0~15807^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=0b2fcf3785e166a6c5854acfb80c52c56e7c5bb5;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on includes/resourceloader/ Change-Id: I5c63e0612c2aae240abcdbf21da9cdadd80dee31 --- diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index d723d0edba..680bd994d3 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -29,24 +29,16 @@ * https://www.mediawiki.org/wiki/ResourceLoader */ class ResourceLoader { - - /** - * @var int - */ + /** @var int */ protected static $filterCacheVersion = 7; - /** - * @var array - */ + + /** @var array */ protected static $requiredSourceProperties = array( 'loadScript' ); - /** - * @var array Module name/ResourceLoaderModule object pairs - */ + /** @var array Module name/ResourceLoaderModule object pairs */ protected $modules = array(); - /** - * @var array Associative array mapping module name to info associative array - */ + /** @var array Associative array mapping module name to info associative array */ protected $moduleInfos = array(); /** @@ -55,14 +47,10 @@ class ResourceLoader { */ protected $testModuleNames = array(); - /** - * @var array e.g. array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) ) - */ + /** @var array e.g. array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) ) */ protected $sources = array(); - /** - * @var bool - */ + /** @var bool */ protected $hasErrors = false; /** @@ -225,7 +213,10 @@ class ResourceLoader { wfProfileIn( __METHOD__ ); // Add 'local' source first - $this->addSource( 'local', array( 'loadScript' => $wgLoadScript, 'apiScript' => wfScript( 'api' ) ) ); + $this->addSource( + 'local', + array( 'loadScript' => $wgLoadScript, 'apiScript' => wfScript( 'api' ) ) + ); // Add other sources $this->addSource( $wgResourceLoaderSources ); @@ -275,7 +266,8 @@ class ResourceLoader { // Check $name for validity if ( !self::isValidModuleName( $name ) ) { wfProfileOut( __METHOD__ ); - throw new MWException( "ResourceLoader module name '$name' is invalid, see ResourceLoader::isValidModuleName()" ); + throw new MWException( "ResourceLoader module name '$name' is invalid, " + . "see ResourceLoader::isValidModuleName()" ); } // Attach module @@ -304,7 +296,9 @@ class ResourceLoader { global $IP, $wgEnableJavaScriptTest; if ( $wgEnableJavaScriptTest !== true ) { - throw new MWException( 'Attempt to register JavaScript test modules but $wgEnableJavaScriptTest is false. Edit your LocalSettings.php to enable it.' ); + throw new MWException( 'Attempt to register JavaScript test modules ' + . 'but $wgEnableJavaScriptTest is false. ' + . 'Edit your LocalSettings.php to enable it.' ); } wfProfileIn( __METHOD__ ); @@ -325,7 +319,8 @@ class ResourceLoader { $module['dependencies'][] = 'test.mediawiki.qunit.testrunner'; } - $testModules['qunit'] = ( include "$IP/tests/qunit/QUnitTestResources.php" ) + $testModules['qunit']; + $testModules['qunit'] = + ( include "$IP/tests/qunit/QUnitTestResources.php" ) + $testModules['qunit']; foreach ( $testModules as $id => $names ) { // Register test modules @@ -395,10 +390,12 @@ class ResourceLoader { * @return array */ public function getTestModuleNames( $framework = 'all' ) { - /// @todo api siteinfo prop testmodulenames modulenames + /** @todo api siteinfo prop testmodulenames modulenames */ if ( $framework == 'all' ) { return $this->testModuleNames; - } elseif ( isset( $this->testModuleNames[$framework] ) && is_array( $this->testModuleNames[$framework] ) ) { + } elseif ( isset( $this->testModuleNames[$framework] ) + && is_array( $this->testModuleNames[$framework] ) + ) { return $this->testModuleNames[$framework]; } else { return array(); @@ -763,7 +760,10 @@ class ResourceLoader { $blobs = MessageBlobStore::get( $this, $modules, $context->getLanguage() ); } catch ( Exception $e ) { MWExceptionHandler::logException( $e ); - wfDebugLog( 'resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" ); + wfDebugLog( + 'resourceloader', + __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: $e" + ); $this->hasErrors = true; // Add exception to the output as a comment $exceptions .= self::formatException( $e ); @@ -795,9 +795,13 @@ class ResourceLoader { $scripts = $module->getScriptURLsForDebug( $context ); } else { $scripts = $module->getScript( $context ); - // rtrim() because there are usually a few line breaks after the last ';'. - // A new line at EOF, a new line added by ResourceLoaderFileModule::readScriptFiles, etc. - if ( is_string( $scripts ) && strlen( $scripts ) && substr( rtrim( $scripts ), -1 ) !== ';' ) { + // rtrim() because there are usually a few line breaks + // after the last ';'. A new line at EOF, a new line + // added by ResourceLoaderFileModule::readScriptFiles, etc. + if ( is_string( $scripts ) + && strlen( $scripts ) + && substr( rtrim( $scripts ), -1 ) !== ';' + ) { // Append semicolon to prevent weird bugs caused by files not // terminating their statements right (bug 27054) $scripts .= ";\n"; @@ -1055,7 +1059,9 @@ class ResourceLoader { * @param string $script JavaScript code * @return string */ - public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $source, $script ) { + public static function makeCustomLoaderScript( $name, $version, $dependencies, + $group, $source, $script + ) { $script = str_replace( "\n", "\n\t", trim( $script ) ); return Xml::encodeJsCall( "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )", @@ -1218,9 +1224,12 @@ class ResourceLoader { * @param array $extraQuery Extra query parameters to add * @return string URL to load.php. May be protocol-relative (if $wgLoadScript is procol-relative) */ - public static function makeLoaderURL( $modules, $lang, $skin, $user = null, $version = null, $debug = false, $only = null, - $printable = false, $handheld = false, $extraQuery = array() ) { + public static function makeLoaderURL( $modules, $lang, $skin, $user = null, + $version = null, $debug = false, $only = null, $printable = false, + $handheld = false, $extraQuery = array() + ) { global $wgLoadScript; + $query = self::makeLoaderQuery( $modules, $lang, $skin, $user, $version, $debug, $only, $printable, $handheld, $extraQuery ); @@ -1247,8 +1256,10 @@ class ResourceLoader { * * @return array */ - public static function makeLoaderQuery( $modules, $lang, $skin, $user = null, $version = null, $debug = false, $only = null, - $printable = false, $handheld = false, $extraQuery = array() ) { + public static function makeLoaderQuery( $modules, $lang, $skin, $user = null, + $version = null, $debug = false, $only = null, $printable = false, + $handheld = false, $extraQuery = array() + ) { $query = array( 'modules' => self::makePackedModulesString( $modules ), 'lang' => $lang, diff --git a/includes/resourceloader/ResourceLoaderContext.php b/includes/resourceloader/ResourceLoaderContext.php index 63ec5de6ce..9013e2bf93 100644 --- a/includes/resourceloader/ResourceLoaderContext.php +++ b/includes/resourceloader/ResourceLoaderContext.php @@ -27,7 +27,6 @@ * of a specific loader request */ class ResourceLoaderContext { - /* Protected Members */ protected $resourceLoader; @@ -109,7 +108,8 @@ class ResourceLoaderContext { } /** - * Return a dummy ResourceLoaderContext object suitable for passing into things that don't "really" need a context + * Return a dummy ResourceLoaderContext object suitable for passing into + * things that don't "really" need a context. * @return ResourceLoaderContext */ public static function newDummyContext() { diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 61fb111393..382bdd9d96 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -26,13 +26,14 @@ * ResourceLoader module based on local JavaScript/CSS files. */ class ResourceLoaderFileModule extends ResourceLoaderModule { - /* Protected Members */ /** @var string Local base path, see __construct() */ protected $localBasePath = ''; + /** @var string Remote base path, see __construct() */ protected $remoteBasePath = ''; + /** * @var array List of paths to JavaScript files to always include * @par Usage: @@ -41,6 +42,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $scripts = array(); + /** * @var array List of JavaScript files to include when using a specific language * @par Usage: @@ -49,6 +51,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $languageScripts = array(); + /** * @var array List of JavaScript files to include when using a specific skin * @par Usage: @@ -57,6 +60,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $skinScripts = array(); + /** * @var array List of paths to JavaScript files to include in debug mode * @par Usage: @@ -65,6 +69,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $debugScripts = array(); + /** * @var array List of paths to JavaScript files to include in the startup module * @par Usage: @@ -73,6 +78,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $loaderScripts = array(); + /** * @var array List of paths to CSS files to always include * @par Usage: @@ -81,6 +87,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $styles = array(); + /** * @var array List of paths to CSS files to include when using specific skins * @par Usage: @@ -89,6 +96,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $skinStyles = array(); + /** * @var array List of modules this module depends on * @par Usage: @@ -97,6 +105,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $dependencies = array(); + /** * @var array List of message keys used by this module * @par Usage: @@ -105,14 +114,19 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $messages = array(); + /** @var string Name of group to load this module in */ protected $group; + /** @var string Position on the page to load this module at */ protected $position = 'bottom'; + /** @var bool Link to raw files in debug mode */ protected $debugRaw = true; + /** @var bool Whether mw.loader.state() call should be omitted */ protected $raw = false; + protected $targets = array( 'desktop' ); /** @@ -129,6 +143,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { * @endcode */ protected $modifiedTime = array(); + /** * @var array Place where readStyleFile() tracks file dependencies * @par Usage: @@ -809,7 +824,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $result = $compiler->cachedCompile( $source ); if ( !is_array( $result ) ) { - throw new MWException( 'LESS compiler result has type ' . gettype( $result ) . '; array expected.' ); + throw new MWException( 'LESS compiler result has type ' + . gettype( $result ) . '; array expected.' ); } $this->localFileRefs += array_keys( $result['files'] ); diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 0996a33b00..9ddd184f1e 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -26,7 +26,6 @@ * Abstraction for resource loader modules, with name registration and maxage functionality. */ abstract class ResourceLoaderModule { - # Type of resource const TYPE_SCRIPTS = 'scripts'; const TYPE_STYLES = 'styles'; @@ -476,7 +475,8 @@ abstract class ResourceLoaderModule { return $data; } - wfDebugLog( 'resourceloader', __METHOD__ . ": New definition hash for module {$this->getName()} in context {$context->getHash()}: $hash." ); + wfDebugLog( 'resourceloader', __METHOD__ . ": New definition hash for module " + . "{$this->getName()} in context {$context->getHash()}: $hash." ); $timestamp = time(); $cache->set( $key, $timestamp );