Improve 1-letter variable names in MutableContext and implementations
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 28 Dec 2017 18:59:53 +0000 (19:59 +0100)
committerThiemo Mättig <thiemo.maettig@wikimedia.de>
Sun, 7 Jan 2018 14:53:55 +0000 (15:53 +0100)
I'm also removing obsolete short comments that don't add anything to
whats already obvious from the method header. For example, I really don't
need a comment to understand that a method that's called "setUser" and
accepts a parameter named "$user" of type "User" is meant to "set the
User object". I mean, how more obvious can it be? ;-)

Change-Id: Ib079108457a5aa2a6896e95837542ab93b465144

includes/context/ContextSource.php
includes/context/DerivativeContext.php
includes/context/IContextSource.php
includes/context/MutableContext.php
includes/context/RequestContext.php

index 6530550..03fb9e2 100644 (file)
@@ -49,8 +49,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Set the IContextSource object
-        *
         * @since 1.18
         * @param IContextSource $context
         */
@@ -59,8 +57,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Config object
-        *
         * @since 1.23
         * @return Config
         */
@@ -69,8 +65,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the WebRequest object
-        *
         * @since 1.18
         * @return WebRequest
         */
@@ -79,8 +73,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Title object
-        *
         * @since 1.18
         * @return Title|null
         */
@@ -114,8 +106,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the OutputPage object
-        *
         * @since 1.18
         * @return OutputPage
         */
@@ -124,8 +114,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the User object
-        *
         * @since 1.18
         * @return User
         */
@@ -134,8 +122,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Language object
-        *
         * @since 1.19
         * @return Language
         */
@@ -144,8 +130,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Skin object
-        *
         * @since 1.18
         * @return Skin
         */
@@ -154,8 +138,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Timing object
-        *
         * @since 1.27
         * @return Timing
         */
@@ -164,8 +146,6 @@ abstract class ContextSource implements IContextSource {
        }
 
        /**
-        * Get the Stats object
-        *
         * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
         *
         * @since 1.25
index 82b97ec..f7a1815 100644 (file)
@@ -81,17 +81,13 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the SiteConfiguration object
-        *
-        * @param Config $s
+        * @param Config $config
         */
-       public function setConfig( Config $s ) {
-               $this->config = $s;
+       public function setConfig( Config $config ) {
+               $this->config = $config;
        }
 
        /**
-        * Get the Config object
-        *
         * @return Config
         */
        public function getConfig() {
@@ -103,8 +99,6 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Get the stats object
-        *
         * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
         *
         * @return IBufferingStatsdDataFactory
@@ -114,8 +108,6 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Get the timing object
-        *
         * @return Timing
         */
        public function getTiming() {
@@ -127,17 +119,13 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the WebRequest object
-        *
-        * @param WebRequest $r
+        * @param WebRequest $request
         */
-       public function setRequest( WebRequest $r ) {
-               $this->request = $r;
+       public function setRequest( WebRequest $request ) {
+               $this->request = $request;
        }
 
        /**
-        * Get the WebRequest object
-        *
         * @return WebRequest
         */
        public function getRequest() {
@@ -149,17 +137,13 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the Title object
-        *
-        * @param Title $t
+        * @param Title $title
         */
-       public function setTitle( Title $t ) {
-               $this->title = $t;
+       public function setTitle( Title $title ) {
+               $this->title = $title;
        }
 
        /**
-        * Get the Title object
-        *
         * @return Title|null
         */
        public function getTitle() {
@@ -189,13 +173,11 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the WikiPage object
-        *
         * @since 1.19
-        * @param WikiPage $p
+        * @param WikiPage $wikiPage
         */
-       public function setWikiPage( WikiPage $p ) {
-               $this->wikipage = $p;
+       public function setWikiPage( WikiPage $wikiPage ) {
+               $this->wikipage = $wikiPage;
        }
 
        /**
@@ -216,17 +198,13 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the OutputPage object
-        *
-        * @param OutputPage $o
+        * @param OutputPage $output
         */
-       public function setOutput( OutputPage $o ) {
-               $this->output = $o;
+       public function setOutput( OutputPage $output ) {
+               $this->output = $output;
        }
 
        /**
-        * Get the OutputPage object
-        *
         * @return OutputPage
         */
        public function getOutput() {
@@ -238,17 +216,13 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the User object
-        *
-        * @param User $u
+        * @param User $user
         */
-       public function setUser( User $u ) {
-               $this->user = $u;
+       public function setUser( User $user ) {
+               $this->user = $user;
        }
 
        /**
-        * Get the User object
-        *
         * @return User
         */
        public function getUser() {
@@ -260,18 +234,16 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the Language object
-        *
-        * @param Language|string $l Language instance or language code
+        * @param Language|string $language Language instance or language code
         * @throws MWException
         * @since 1.19
         */
-       public function setLanguage( $l ) {
-               if ( $l instanceof Language ) {
-                       $this->lang = $l;
-               } elseif ( is_string( $l ) ) {
-                       $l = RequestContext::sanitizeLangCode( $l );
-                       $obj = Language::factory( $l );
+       public function setLanguage( $language ) {
+               if ( $language instanceof Language ) {
+                       $this->lang = $language;
+               } elseif ( is_string( $language ) ) {
+                       $language = RequestContext::sanitizeLangCode( $language );
+                       $obj = Language::factory( $language );
                        $this->lang = $obj;
                } else {
                        throw new MWException( __METHOD__ . " was passed an invalid type of data." );
@@ -279,8 +251,6 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Get the Language object
-        *
         * @return Language
         * @since 1.19
         */
@@ -293,18 +263,14 @@ class DerivativeContext extends ContextSource implements MutableContext {
        }
 
        /**
-        * Set the Skin object
-        *
-        * @param Skin $s
+        * @param Skin $skin
         */
-       public function setSkin( Skin $s ) {
-               $this->skin = clone $s;
+       public function setSkin( Skin $skin ) {
+               $this->skin = clone $skin;
                $this->skin->setContext( $this );
        }
 
        /**
-        * Get the Skin object
-        *
         * @return Skin
         */
        public function getSkin() {
index 5a856cf..6e48e1e 100644 (file)
  * shutdown by separate persistence handler objects, for example.
  */
 interface IContextSource extends MessageLocalizer {
+
        /**
-        * Get the WebRequest object
-        *
         * @return WebRequest
         */
        public function getRequest();
 
        /**
-        * Get the Title object
-        *
         * @return Title|null
         */
        public function getTitle();
@@ -87,30 +84,22 @@ interface IContextSource extends MessageLocalizer {
        public function getWikiPage();
 
        /**
-        * Get the OutputPage object
-        *
         * @return OutputPage
         */
        public function getOutput();
 
        /**
-        * Get the User object
-        *
         * @return User
         */
        public function getUser();
 
        /**
-        * Get the Language object
-        *
         * @return Language
         * @since 1.19
         */
        public function getLanguage();
 
        /**
-        * Get the Skin object
-        *
         * @return Skin
         */
        public function getSkin();
@@ -124,8 +113,6 @@ interface IContextSource extends MessageLocalizer {
        public function getConfig();
 
        /**
-        * Get the stats object
-        *
         * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
         *
         * @since 1.25
@@ -134,8 +121,6 @@ interface IContextSource extends MessageLocalizer {
        public function getStats();
 
        /**
-        * Get the timing object
-        *
         * @since 1.27
         * @return Timing
         */
index 189b346..56ec960 100644 (file)
  */
 
 interface MutableContext {
+
        /**
-        * Set the Config object
-        *
         * @param Config $config
         */
        public function setConfig( Config $config );
 
        /**
-        * Set the WebRequest object
-        *
-        * @param WebRequest $r
+        * @param WebRequest $request
         */
-       public function setRequest( WebRequest $r );
+       public function setRequest( WebRequest $request );
 
        /**
-        * Set the Title object
-        *
-        * @param Title $t
+        * @param Title $title
         */
-       public function setTitle( Title $t );
+       public function setTitle( Title $title );
 
        /**
-        * Set the WikiPage object
-        *
-        * @param WikiPage $p
+        * @param WikiPage $wikiPage
         */
-       public function setWikiPage( WikiPage $p );
+       public function setWikiPage( WikiPage $wikiPage );
 
        /**
-        * Set the OutputPage object
-        *
-        * @param OutputPage $o
+        * @param OutputPage $output
         */
-       public function setOutput( OutputPage $o );
+       public function setOutput( OutputPage $output );
 
        /**
-        * Set the User object
-        *
-        * @param User $u
+        * @param User $user
         */
-       public function setUser( User $u );
+       public function setUser( User $user );
 
        /**
-        * Set the Language object
-        *
-        * @param Language|string $l Language instance or language code
+        * @param Language|string $language Language instance or language code
         */
-       public function setLanguage( $l );
+       public function setLanguage( $language );
 
        /**
-        * Set the Skin object
-        *
-        * @param Skin $s
+        * @param Skin $skin
         */
-       public function setSkin( Skin $s );
+       public function setSkin( Skin $skin );
 
 }
index 47d1684..6fedead 100644 (file)
@@ -101,17 +101,13 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the WebRequest object
-        *
-        * @param WebRequest $r
+        * @param WebRequest $request
         */
-       public function setRequest( WebRequest $r ) {
-               $this->request = $r;
+       public function setRequest( WebRequest $request ) {
+               $this->request = $request;
        }
 
        /**
-        * Get the WebRequest object
-        *
         * @return WebRequest
         */
        public function getRequest() {
@@ -129,8 +125,6 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Get the Stats object
-        *
         * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
         *
         * @return IBufferingStatsdDataFactory
@@ -140,8 +134,6 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Get the timing object
-        *
         * @return Timing
         */
        public function getTiming() {
@@ -154,8 +146,6 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the Title object
-        *
         * @param Title|null $title
         */
        public function setTitle( Title $title = null ) {
@@ -165,8 +155,6 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Get the Title object
-        *
         * @return Title|null
         */
        public function getTitle() {
@@ -212,18 +200,16 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the WikiPage object
-        *
         * @since 1.19
-        * @param WikiPage $p
+        * @param WikiPage $wikiPage
         */
-       public function setWikiPage( WikiPage $p ) {
-               $pageTitle = $p->getTitle();
+       public function setWikiPage( WikiPage $wikiPage ) {
+               $pageTitle = $wikiPage->getTitle();
                if ( !$this->hasTitle() || !$pageTitle->equals( $this->getTitle() ) ) {
                        $this->setTitle( $pageTitle );
                }
                // Defer this to the end since setTitle sets it to null.
-               $this->wikipage = $p;
+               $this->wikipage = $wikiPage;
        }
 
        /**
@@ -249,15 +235,13 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * @param OutputPage $o
+        * @param OutputPage $output
         */
-       public function setOutput( OutputPage $o ) {
-               $this->output = $o;
+       public function setOutput( OutputPage $output ) {
+               $this->output = $output;
        }
 
        /**
-        * Get the OutputPage object
-        *
         * @return OutputPage
         */
        public function getOutput() {
@@ -269,17 +253,13 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the User object
-        *
-        * @param User $u
+        * @param User $user
         */
-       public function setUser( User $u ) {
-               $this->user = $u;
+       public function setUser( User $user ) {
+               $this->user = $user;
        }
 
        /**
-        * Get the User object
-        *
         * @return User
         */
        public function getUser() {
@@ -311,18 +291,16 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the Language object
-        *
-        * @param Language|string $l Language instance or language code
+        * @param Language|string $language Language instance or language code
         * @throws MWException
         * @since 1.19
         */
-       public function setLanguage( $l ) {
-               if ( $l instanceof Language ) {
-                       $this->lang = $l;
-               } elseif ( is_string( $l ) ) {
-                       $l = self::sanitizeLangCode( $l );
-                       $obj = Language::factory( $l );
+       public function setLanguage( $language ) {
+               if ( $language instanceof Language ) {
+                       $this->lang = $language;
+               } elseif ( is_string( $language ) ) {
+                       $language = self::sanitizeLangCode( $language );
+                       $obj = Language::factory( $language );
                        $this->lang = $obj;
                } else {
                        throw new MWException( __METHOD__ . " was passed an invalid type of data." );
@@ -380,18 +358,14 @@ class RequestContext implements IContextSource, MutableContext {
        }
 
        /**
-        * Set the Skin object
-        *
-        * @param Skin $s
+        * @param Skin $skin
         */
-       public function setSkin( Skin $s ) {
-               $this->skin = clone $s;
+       public function setSkin( Skin $skin ) {
+               $this->skin = clone $skin;
                $this->skin->setContext( $this );
        }
 
        /**
-        * Get the Skin object
-        *
         * @return Skin
         */
        public function getSkin() {