resourceloader: Reformat code around member grouping in ResourceLoaderContext
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 17 Nov 2015 21:14:17 +0000 (21:14 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 17 Nov 2015 21:47:24 +0000 (21:47 +0000)
* No effective change. Only code reformatting.
* Logically group related members.
* Break up items one per line in getHash().

Change-Id: I8ccbe9d071a5c39f5c3d36d0d990574fb0ed8d72

includes/resourceloader/ResourceLoaderContext.php
tests/phpunit/includes/resourceloader/DerivativeResourceLoaderContextTest.php

index 6ecee4c..5ea4769 100644 (file)
@@ -33,19 +33,24 @@ class ResourceLoaderContext {
 
        protected $resourceLoader;
        protected $request;
-       protected $modules;
-       protected $language;
-       protected $direction;
+
+       // Module content vary
        protected $skin;
-       protected $user;
+       protected $language;
        protected $debug;
+       protected $user;
+
+       // Request vary (in addition to cache vary)
+       protected $modules;
        protected $only;
        protected $version;
-       protected $hash;
        protected $raw;
        protected $image;
        protected $variant;
        protected $format;
+
+       protected $direction;
+       protected $hash;
        protected $userObj;
        protected $imageObj;
 
@@ -346,9 +351,17 @@ class ResourceLoaderContext {
        public function getHash() {
                if ( !isset( $this->hash ) ) {
                        $this->hash = implode( '|', array(
-                               $this->getLanguage(), $this->getSkin(), $this->getUser(),
-                               $this->getImage(), $this->getVariant(), $this->getFormat(),
-                               $this->getDebug(), $this->getOnly(), $this->getVersion()
+                               // Module content vary
+                               $this->getLanguage(),
+                               $this->getSkin(),
+                               $this->getDebug(),
+                               $this->getUser(),
+                               // Request vary
+                               $this->getOnly(),
+                               $this->getVersion(),
+                               $this->getImage(),
+                               $this->getVariant(),
+                               $this->getFormat(),
                        ) );
                }
                return $this->hash;
index b457cec..ee9d766 100644 (file)
@@ -25,7 +25,7 @@ class DerivativeResourceLoaderContextTest extends PHPUnit_Framework_TestCase {
                $this->assertEquals( $derived->getModules(), array( 'test.context' ) );
                $this->assertEquals( $derived->getOnly(), 'scripts' );
                $this->assertEquals( $derived->getSkin(), 'fallback' );
-               $this->assertEquals( $derived->getHash(), 'zh|fallback||||||scripts|' );
+               $this->assertEquals( $derived->getHash(), 'zh|fallback|||scripts||||' );
        }
 
        public function testSetLanguage() {
@@ -72,7 +72,7 @@ class DerivativeResourceLoaderContextTest extends PHPUnit_Framework_TestCase {
 
                $derived->setLanguage( 'nl' );
                // Assert that subclass is able to clear parent class "hash" member
-               $this->assertEquals( $derived->getHash(), 'nl|fallback||||||scripts|' );
+               $this->assertEquals( $derived->getHash(), 'nl|fallback|||scripts||||' );
        }
 
 }