phpcs: Pass includes/resourceloader/
authorTimo Tijhof <ttijhof@wikimedia.org>
Tue, 2 Apr 2013 20:28:40 +0000 (22:28 +0200)
committerTimo Tijhof <ttijhof@wikimedia.org>
Wed, 3 Apr 2013 00:16:02 +0000 (02:16 +0200)
- A cast statement must not be followed by a space.
- The method parameter $context is never used.
- Avoid function calls in a FOR loop test part.
- Opening brace should be on the same line as closing parenthesis.

Change-Id: I0eba7fcc9ceab372003d1134857346690c525e87

includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderUserTokensModule.php

index 62c0822..061d813 100644 (file)
@@ -594,7 +594,7 @@ class ResourceLoader {
                                // no matter how often we call ob_get_clean(), so instead of doing
                                // the more intuitive while ( ob_get_level() > 0 ) ob_get_clean();
                                // we have to be safe here and avoid an infinite loop.
-                               for ( $i = 0; $i < ob_get_level(); $i++ ) {
+                               for ( $i = 0, $len = ob_get_level(); $i < $len; $i++ ) {
                                        ob_end_clean();
                                }
 
@@ -671,8 +671,8 @@ class ResourceLoader {
         * @return String: Response data
         */
        public function makeModuleResponse( ResourceLoaderContext $context,
-               array $modules, $missing = array() )
-       {
+               array $modules, $missing = array()
+       {
                $out = '';
                $exceptions = '';
                if ( $modules === array() && $missing === array() ) {
@@ -894,7 +894,7 @@ class ResourceLoader {
                        // ResourceLoaderFileModule::getStyle can return the styles
                        // as a string or an array of strings. This is to allow separation in
                        // the front-end.
-                       $styles = (array) $styles;
+                       $styles = (array)$styles;
                        foreach ( $styles as $style ) {
                                $style = trim( $style );
                                // Don't output an empty "@media print { }" block (bug 40498)
@@ -986,12 +986,12 @@ class ResourceLoader {
         * @return string
         */
        public static function makeLoaderRegisterScript( $name, $version = null,
-               $dependencies = null, $group = null, $source = null )
-       {
+               $dependencies = null, $group = null, $source = null
+       {
                if ( is_array( $name ) ) {
                        return Xml::encodeJsCall( 'mw.loader.register', array( $name ) );
                } else {
-                       $version = (int) $version > 1 ? (int) $version : 1;
+                       $version = (int)$version > 1 ? (int)$version : 1;
                        return Xml::encodeJsCall( 'mw.loader.register',
                                array( $name, $version, $dependencies, $group, $source ) );
                }
index cedb5dc..2718bcb 100644 (file)
@@ -187,8 +187,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @endcode
         */
        public function __construct( $options = array(), $localBasePath = null,
-               $remoteBasePath = null )
-       {
+               $remoteBasePath = null
+       {
                global $IP, $wgScriptPath, $wgResourceBasePath;
                $this->localBasePath = $localBasePath === null ? $IP : $localBasePath;
                if ( $remoteBasePath !== null ) {
@@ -209,7 +209,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                case 'debugScripts':
                                case 'loaderScripts':
                                case 'styles':
-                                       $this->{$member} = (array) $option;
+                                       $this->{$member} = (array)$option;
                                        break;
                                // Collated lists of file paths
                                case 'languageScripts':
@@ -228,26 +228,26 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                                                "'$key' given, string expected."
                                                        );
                                                }
-                                               $this->{$member}[$key] = (array) $value;
+                                               $this->{$member}[$key] = (array)$value;
                                        }
                                        break;
                                // Lists of strings
                                case 'dependencies':
                                case 'messages':
                                case 'targets':
-                                       $this->{$member} = (array) $option;
+                                       $this->{$member} = (array)$option;
                                        break;
                                // Single strings
                                case 'group':
                                case 'position':
                                case 'localBasePath':
                                case 'remoteBasePath':
-                                       $this->{$member} = (string) $option;
+                                       $this->{$member} = (string)$option;
                                        break;
                                // Single booleans
                                case 'debugRaw':
                                case 'raw':
-                                       $this->{$member} = (bool) $option;
+                                       $this->{$member} = (bool)$option;
                                        break;
                        }
                }
@@ -481,7 +481,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         */
        protected static function collateFilePathListByOption( array $list, $option, $default ) {
                $collatedFiles = array();
-               foreach ( (array) $list as $key => $value ) {
+               foreach ( (array)$list as $key => $value ) {
                        if ( is_int( $key ) ) {
                                // File name as the value
                                if ( !isset( $collatedFiles[$default] ) ) {
index 03f3cc3..f6a7114 100644 (file)
@@ -319,7 +319,7 @@ abstract class ResourceLoaderModule {
                        ), __METHOD__
                );
                if ( !is_null( $deps ) ) {
-                       $this->fileDeps[$skin] = (array) FormatJson::decode( $deps, true );
+                       $this->fileDeps[$skin] = (array)FormatJson::decode( $deps, true );
                } else {
                        $this->fileDeps[$skin] = array();
                }
index f3090dd..92ebbe9 100644 (file)
@@ -35,10 +35,9 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
        /**
         * Fetch the tokens for the current user.
         *
-        * @param $context ResourceLoaderContext: Context object
-        * @return Array: List of tokens keyed by token type
+        * @return array: List of tokens keyed by token type
         */
-       protected function contextUserTokens( ResourceLoaderContext $context ) {
+       protected function contextUserTokens() {
                global $wgUser;
 
                return array(
@@ -54,7 +53,7 @@ class ResourceLoaderUserTokensModule extends ResourceLoaderModule {
         */
        public function getScript( ResourceLoaderContext $context ) {
                return Xml::encodeJsCall( 'mw.user.tokens.set',
-                       array( $this->contextUserTokens( $context ) ),
+                       array( $this->contextUserTokens() ),
                        ResourceLoader::inDebugMode()
                );
        }