http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99760

Revision: 99760
Author:   reedy
Date:     2011-10-14 08:06:54 +0000 (Fri, 14 Oct 2011)
Log Message:
-----------
Documentation

Trim trailing whitespace

Make returns return values where appropriate (ie other paths in the same method 
do)

Modified Paths:
--------------
    trunk/phase3/includes/resourceloader/ResourceLoader.php
    trunk/phase3/includes/resourceloader/ResourceLoaderContext.php
    trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderFilePageModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php
    trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php

Modified: trunk/phase3/includes/resourceloader/ResourceLoader.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoader.php     2011-10-14 
08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoader.php     2011-10-14 
08:06:54 UTC (rev 99760)
@@ -263,10 +263,10 @@
 
        /**
         * Add a foreign source of modules.
-        * 
+        *
         * Source properties:
         * 'loadScript': URL (either fully-qualified or protocol-relative) of 
load.php for this source
-        * 
+        *
         * @param $id Mixed: source ID (string), or array( id1 => props1, id2 
=> props2, ... )
         * @param $properties Array: source properties
         */
@@ -340,7 +340,7 @@
 
        /**
         * Get the list of sources
-        * 
+        *
         * @return Array: array( id => array of properties, .. )
         */
        public function getSources() {
@@ -401,6 +401,9 @@
                // the last modified time
                $mtime = wfTimestamp( TS_UNIX, $wgCacheEpoch );
                foreach ( $modules as $module ) {
+                       /**
+                        * @var $module ResourceLoaderModule
+                        */
                        try {
                                // Bypass Squid and other shared caches if the 
request includes any private modules
                                if ( $module->getGroup() === 'private' ) {
@@ -571,7 +574,7 @@
                        $this->sendResponseHeaders( $context, $ts, false );
                        // If there's an If-Modified-Since header, respond with 
a 304 appropriately
                        if ( $this->tryRespondLastModified( $context, $ts ) ) {
-                               return; // output handled (buffers cleared)
+                               return false; // output handled (buffers 
cleared)
                        }
                        $response = $fileCache->fetchText();
                        // Remove the output buffer and output the response
@@ -617,6 +620,10 @@
 
                // Generate output
                foreach ( $modules as $name => $module ) {
+                       /**
+                        * @var $module ResourceLoaderModule
+                        */
+
                        wfProfileIn( __METHOD__ . '-' . $name );
                        try {
                                $scripts = '';
@@ -876,13 +883,13 @@
        /**
         * Returns JS code which calls mw.loader.addSource() with the given
         * parameters. Has two calling conventions:
-        * 
+        *
         *   - ResourceLoader::makeLoaderSourcesScript( $id, $properties ):
         *       Register a single source
-        * 
+        *
         *   - ResourceLoader::makeLoaderSourcesScript( array( $id1 => $props1, 
$id2 => $props2, ... ) );
         *       Register sources with the given IDs and properties.
-        * 
+        *
         * @param $id String: source ID
         * @param $properties Array: source properties (see addSource())
         *
@@ -982,7 +989,7 @@
                $query = self::makeLoaderQuery( $modules, $lang, $skin, $user, 
$version, $debug,
                        $only, $printable, $handheld, $extraQuery
                );
-               
+
                // Prevent the IE6 extension check from being triggered (bug 
28840)
                // by appending a character that's invalid in Windows 
extensions ('*')
                return wfExpandUrl( wfAppendQuery( $wgLoadScript, $query ) . 
'&*', PROTO_RELATIVE );
@@ -1017,7 +1024,7 @@
                        $query['handheld'] = 1;
                }
                $query += $extraQuery;
-               
+
                // Make queries uniform in order
                ksort( $query );
                return $query;

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderContext.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderContext.php      
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderContext.php      
2011-10-14 08:06:54 UTC (rev 99760)
@@ -21,7 +21,7 @@
  */
 
 /**
- * Object passed around to modules which contains information about the state 
+ * Object passed around to modules which contains information about the state
  * of a specific loader request
  */
 class ResourceLoaderContext {
@@ -42,6 +42,10 @@
 
        /* Methods */
 
+       /**
+        * @param $resourceLoader ResourceLoader
+        * @param $request WebRequest
+        */
        public function __construct( $resourceLoader, WebRequest $request ) {
                global $wgDefaultSkin, $wgResourceLoaderDebug;
 
@@ -63,7 +67,7 @@
                        $this->skin = $wgDefaultSkin;
                }
        }
-       
+
        /**
         * Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to
         * an array of module names like array( 'jquery.foo', 'jquery.bar',
@@ -99,9 +103,10 @@
                }
                return $retval;
        }
-       
+
        /**
         * Return a dummy ResourceLoaderContext object suitable for passing 
into things that don't "really" need a context
+        * @return ResourceLoaderContext
         */
        public static function newDummyContext() {
                return new self( null, new FauxRequest( array() ) );
@@ -218,7 +223,7 @@
        public function getHash() {
                if ( !isset( $this->hash ) ) {
                        $this->hash = implode( '|', array(
-                               $this->getLanguage(), $this->getDirection(), 
$this->skin, $this->user, 
+                               $this->getLanguage(), $this->getDirection(), 
$this->skin, $this->user,
                                $this->debug, $this->only, $this->version
                        ) );
                }

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php   
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php   
2011-10-14 08:06:54 UTC (rev 99760)
@@ -223,7 +223,11 @@
                $files = $this->getScriptFiles( $context );
                return $this->readScriptFiles( $files );
        }
-       
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
        public function getScriptURLsForDebug( ResourceLoaderContext $context ) 
{
                $urls = array();
                foreach ( $this->getScriptFiles( $context ) as $file ) {
@@ -232,6 +236,9 @@
                return $urls;
        }
 
+       /**
+        * @return bool
+        */
        public function supportsURLLoading() {
                return $this->debugRaw;
        }
@@ -275,6 +282,10 @@
                return $styles;
        }
 
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
        public function getStyleURLsForDebug( ResourceLoaderContext $context ) {
                $urls = array();
                foreach ( $this->getStyleFiles( $context ) as $mediaType => 
$list ) {
@@ -582,7 +593,7 @@
                        $style, $dir, $remoteDir, true
                );
        }
-       
+
        /**
         * Safe version of filemtime(), which doesn't throw a PHP warning if 
the file doesn't exist
         * but returns 1 instead.

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderFilePageModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderFilePageModule.php       
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderFilePageModule.php       
2011-10-14 08:06:54 UTC (rev 99760)
@@ -1,8 +1,13 @@
 <?php
-/* 
+/**
  * ResourceLoader definition for MediaWiki:Filepage.css
  */
 class ResourceLoaderFilePageModule extends ResourceLoaderWikiModule {
+
+       /**
+        * @param $context ResourceLoaderContext
+        * @return array
+        */
        protected function getPages( ResourceLoaderContext $context ) {
                return array(
                        'MediaWiki:Filepage.css' => array( 'type' => 'style' ),

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderModule.php       
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderModule.php       
2011-10-14 08:06:54 UTC (rev 99760)
@@ -52,11 +52,11 @@
        # limit the types of scripts and styles we allow to load on, say, 
sensitive special
        # pages like Special:UserLogin and Special:Preferences
        protected $origin = self::ORIGIN_CORE_SITEWIDE;
-       
+
        /* Protected Members */
 
        protected $name = null;
-       
+
        // In-object cache for file dependencies
        protected $fileDeps = array();
        // In-object cache for message blob mtime
@@ -126,18 +126,18 @@
                // Stub, override expected
                return '';
        }
-       
+
        /**
         * Get the URL or URLs to load for this module's JS in debug mode.
         * The default behavior is to return a load.php?only=scripts URL for
         * the module, but file-based modules will want to override this to
         * load the files directly.
-        * 
+        *
         * This function is called only when 1) we're in debug mode, 2) there
         * is no only= parameter and 3) supportsURLLoading() returns true.
         * #2 is important to prevent an infinite loop, therefore this function
         * MUST return either an only= URL or a non-load.php URL.
-        * 
+        *
         * @param $context ResourceLoaderContext: Context object
         * @return Array of URLs
         */
@@ -155,7 +155,7 @@
                );
                return array( $url );
        }
-       
+
        /**
         * Whether this module supports URL loading. If this function returns 
false,
         * getScript() will be used even in cases (debug mode, no only param) 
where
@@ -176,13 +176,13 @@
                // Stub, override expected
                return array();
        }
-       
+
        /**
         * Get the URL or URLs to load for this module's CSS in debug mode.
         * The default behavior is to return a load.php?only=styles URL for
         * the module, but file-based modules will want to override this to
         * load the files directly. See also getScriptURLsForDebug()
-        * 
+        *
         * @param $context ResourceLoaderContext: Context object
         * @return Array: array( mediaType => array( URL1, URL2, ... ), ... )
         */
@@ -212,10 +212,10 @@
                // Stub, override expected
                return array();
        }
-       
+
        /**
         * Get the group this module is in.
-        * 
+        *
         * @return String: Group name
         */
        public function getGroup() {
@@ -225,14 +225,14 @@
 
        /**
         * Get the origin of this module. Should only be overridden for foreign 
modules.
-        * 
+        *
         * @return String: Origin name, 'local' for local modules
         */
        public function getSource() {
                // Stub, override expected
                return 'local';
        }
-       
+
        /**
         * Where on the HTML page should this module's JS be loaded?
         * 'top': in the <head>
@@ -273,7 +273,7 @@
                // Stub, override expected
                return array();
        }
-       
+
        /**
         * Get the files this module depends on indirectly for a given skin.
         * Currently these are only image files referenced by the module's CSS.
@@ -300,7 +300,7 @@
                }
                return $this->fileDeps[$skin];
        }
-       
+
        /**
         * Set preloaded file dependency information. Used so we can load this
         * information for all modules at once.
@@ -310,7 +310,7 @@
        public function setFileDependencies( $skin, $deps ) {
                $this->fileDeps[$skin] = $deps;
        }
-       
+
        /**
         * Get the last modification timestamp of the message blob for this
         * module in a given language.
@@ -321,7 +321,7 @@
                if ( !isset( $this->msgBlobMtime[$lang] ) ) {
                        if ( !count( $this->getMessages() ) )
                                return 0;
-                       
+
                        $dbr = wfGetDB( DB_SLAVE );
                        $msgBlobMtime = $dbr->selectField( 'msg_resource', 
'mr_timestamp', array(
                                        'mr_resource' => $this->getName(),
@@ -337,7 +337,7 @@
                }
                return $this->msgBlobMtime[$lang];
        }
-       
+
        /**
         * Set a preloaded message blob last modification timestamp. Used so we
         * can load this information for all modules at once.
@@ -347,9 +347,9 @@
        public function setMsgBlobMtime( $lang, $mtime ) {
                $this->msgBlobMtime[$lang] = $mtime;
        }
-       
+
        /* Abstract Methods */
-       
+
        /**
         * Get this module's last modification timestamp for a given
         * combination of language, skin and debug mode flag. This is typically
@@ -364,7 +364,7 @@
                // 0 would mean now
                return 1;
        }
-       
+
        /**
         * Check whether this module is known to be empty. If a child class
         * has an easy and cheap way to determine that this module is
@@ -412,7 +412,7 @@
                                $err = $e->getMessage();
                                $result = "throw new Error(" . 
Xml::encodeJsVar("JavaScript parse error: $err") . ");";
                        }
-                       
+
                        $cache->set( $key, $result );
                        return $result;
                } else {
@@ -420,6 +420,9 @@
                }
        }
 
+       /**
+        * @return JSParser
+        */
        protected static function javaScriptParser() {
                if ( !self::$jsParser ) {
                        self::$jsParser = new JSParser();

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php        
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php        
2011-10-14 08:06:54 UTC (rev 99760)
@@ -241,6 +241,9 @@
                return $out;
        }
 
+       /**
+        * @return bool
+        */
        public function supportsURLLoading() {
                return false;
        }

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php   
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderUserModule.php   
2011-10-14 08:06:54 UTC (rev 99760)
@@ -38,16 +38,16 @@
                        $username = $context->getUser();
                        $userpageTitle = Title::makeTitleSafe( NS_USER, 
$username );
                        $userpage = $userpageTitle->getPrefixedDBkey(); // 
Needed so $excludepages works
-                       
+
                        $pages = array(
                                "$userpage/common.js" => array( 'type' => 
'script' ),
-                               "$userpage/" . $context->getSkin() . '.js' => 
+                               "$userpage/" . $context->getSkin() . '.js' =>
                                        array( 'type' => 'script' ),
                                "$userpage/common.css" => array( 'type' => 
'style' ),
-                               "$userpage/" . $context->getSkin() . '.css' => 
+                               "$userpage/" . $context->getSkin() . '.css' =>
                                        array( 'type' => 'style' ),
                        );
-                       
+
                        // Hack for bug 26283: if we're on a preview page for a 
CSS/JS page,
                        // we need to exclude that page from this module. In 
that case, the excludepage
                        // parameter will be set to the name of the page we 
need to exclude.

Modified: 
trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php    
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderUserOptionsModule.php    
2011-10-14 08:06:54 UTC (rev 99760)
@@ -55,7 +55,7 @@
        /**
         * Fetch the context's user options, or if it doesn't match current 
user,
         * the default options.
-        * 
+        *
         * @param $context ResourceLoaderContext: Context object
         * @return Array: List of user options keyed by option name
         */
@@ -75,7 +75,7 @@
         * @return string
         */
        public function getScript( ResourceLoaderContext $context ) {
-               return Xml::encodeJsCall( 'mw.user.options.set', 
+               return Xml::encodeJsCall( 'mw.user.options.set',
                        array( $this->contextUserOptions( $context ) ) );
        }
 
@@ -96,7 +96,7 @@
 
                        // Underline: 2 = browser default, 1 = always, 0 = never
                        if ( $options['underline'] < 2 ) {
-                               $rules[] = "a { text-decoration: " . 
+                               $rules[] = "a { text-decoration: " .
                                        ( $options['underline'] ? 'underline 
!important' : 'none' ) . "; }";
                        }
                        if ( $options['highlightbroken'] ) {
@@ -133,7 +133,10 @@
        public function getGroup() {
                return 'private';
        }
-       
+
+       /**
+        * @return array
+        */
        public function getDependencies() {
                return array( 'mediawiki.user' );
        }

Modified: 
trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php     
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderUserTokensModule.php     
2011-10-14 08:06:54 UTC (rev 99760)
@@ -32,7 +32,7 @@
 
        /**
         * Fetch the tokens for the current user.
-        * 
+        *
         * @param $context ResourceLoaderContext: Context object
         * @return Array: List of tokens keyed by token type
         */
@@ -50,7 +50,7 @@
         * @return string
         */
        public function getScript( ResourceLoaderContext $context ) {
-               return Xml::encodeJsCall( 'mw.user.tokens.set', 
+               return Xml::encodeJsCall( 'mw.user.tokens.set',
                        array( $this->contextUserTokens( $context ) ) );
        }
 
@@ -60,7 +60,10 @@
        public function getGroup() {
                return 'private';
        }
-       
+
+       /**
+        * @return array
+        */
        public function getDependencies() {
                return array( 'mediawiki.user' );
        }

Modified: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
===================================================================
--- trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php   
2011-10-14 08:01:47 UTC (rev 99759)
+++ trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php   
2011-10-14 08:06:54 UTC (rev 99760)
@@ -24,35 +24,39 @@
 
 /**
  * Abstraction for resource loader modules which pull from wiki pages
- * 
- * This can only be used for wiki pages in the MediaWiki and User namespaces, 
- * because of its dependence on the functionality of 
+ *
+ * This can only be used for wiki pages in the MediaWiki and User namespaces,
+ * because of its dependence on the functionality of
  * Title::isValidCssJsSubpage.
  */
 abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
-       
+
        /* Protected Members */
 
        # Origin is user-supplied code
        protected $origin = self::ORIGIN_USER_SITEWIDE;
-       
+
        // In-object cache for title mtimes
        protected $titleMtimes = array();
-       
+
        /* Abstract Protected Methods */
-       
+
+       /**
+        * @abstract
+        * @param $context ResourceLoaderContext
+        */
        abstract protected function getPages( ResourceLoaderContext $context );
-       
+
        /* Protected Methods */
-       
+
        /**
         * Get the Database object used in getTitleMTimes(). Defaults to the 
local slave DB
         * but subclasses may want to override this to return a remote DB 
object.
-        * 
+        *
         * NOTE: This ONLY works for getTitleMTimes() and getModifiedTime(), 
NOT FOR ANYTHING ELSE.
         * In particular, it doesn't work for getting the content of JS and CSS 
pages. That functionality
         * will use the local DB irrespective of the return value of this 
method.
-        * 
+        *
         * @return DatabaseBase
         */
        protected function getDB() {
@@ -77,7 +81,7 @@
                }
                return $revision->getRawText();
        }
-       
+
        /* Methods */
 
        /**
@@ -112,7 +116,7 @@
         */
        public function getStyles( ResourceLoaderContext $context ) {
                global $wgScriptPath;
-               
+
                $styles = array();
                foreach ( $this->getPages( $context ) as $titleText => $options 
) {
                        if ( $options['type'] !== 'style' ) {
@@ -121,7 +125,7 @@
                        $title = Title::newFromText( $titleText );
                        if ( !$title || $title->isRedirect()  ) {
                                continue;
-                       }                       
+                       }
                        $media = isset( $options['media'] ) ? $options['media'] 
: 'all';
                        $style = $this->getContent( $title );
                        if ( strval( $style ) === '' ) {
@@ -174,13 +178,13 @@
                if ( isset( $this->titleMtimes[$hash] ) ) {
                        return $this->titleMtimes[$hash];
                }
-               
+
                $this->titleMtimes[$hash] = array();
                $batch = new LinkBatch;
                foreach ( $this->getPages( $context ) as $titleText => $options 
) {
                        $batch->addObj( Title::newFromText( $titleText ) );
                }
-               
+
                if ( !$batch->isEmpty() ) {
                        $dbr = $this->getDB();
                        $res = $dbr->select( 'page',


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to