From: Siebrand Mazeland Date: Wed, 20 Nov 2013 05:21:57 +0000 (+0100) Subject: Update formatting and documentation in includes/context/ X-Git-Tag: 1.31.0-rc.0~18013 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=1cdc4ef09b16c6a1723cacb3965010106858cedd;p=lhc%2Fweb%2Fwiklou.git Update formatting and documentation in includes/context/ Change-Id: I8bfdbe8f6d9c325063678e24a9d604f18eb83fc3 --- diff --git a/includes/context/ContextSource.php b/includes/context/ContextSource.php index e13cfa88ce..0a3f18ff0f 100644 --- a/includes/context/ContextSource.php +++ b/includes/context/ContextSource.php @@ -41,9 +41,11 @@ abstract class ContextSource implements IContextSource { public function getContext() { if ( $this->context === null ) { $class = get_class( $this ); - wfDebug( __METHOD__ . " ($class): called and \$context is null. Using RequestContext::getMain() for sanity\n" ); + wfDebug( __METHOD__ . " ($class): called and \$context is null. " . + "Using RequestContext::getMain() for sanity\n" ); $this->context = RequestContext::getMain(); } + return $this->context; } @@ -130,6 +132,7 @@ abstract class ContextSource implements IContextSource { */ public function getLang() { wfDeprecated( __METHOD__, '1.19' ); + return $this->getLanguage(); } @@ -162,6 +165,7 @@ abstract class ContextSource implements IContextSource { */ public function msg( /* $args */ ) { $args = func_get_args(); + return call_user_func_array( array( $this->getContext(), 'msg' ), $args ); } diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php index fd9bf96338..e96269d94e 100644 --- a/includes/context/DerivativeContext.php +++ b/includes/context/DerivativeContext.php @@ -99,6 +99,7 @@ class DerivativeContext extends ContextSource { * Set the Title object * * @param Title $t + * @throws MWException */ public function setTitle( $t ) { if ( $t !== null && !$t instanceof Title ) { @@ -298,6 +299,7 @@ class DerivativeContext extends ContextSource { */ public function msg() { $args = func_get_args(); + return call_user_func_array( 'wfMessage', $args )->setContext( $this ); } } diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index 01ec57c086..04879e26d9 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -82,6 +82,7 @@ class RequestContext implements IContextSource { global $wgRequest; # fallback to $wg till we can improve this $this->request = $wgRequest; } + return $this->request; } @@ -89,6 +90,7 @@ class RequestContext implements IContextSource { * Set the Title object * * @param Title $t + * @throws MWException */ public function setTitle( $t ) { if ( $t !== null && !$t instanceof Title ) { @@ -109,6 +111,7 @@ class RequestContext implements IContextSource { global $wgTitle; # fallback to $wg till we can improve this $this->title = $wgTitle; } + return $this->title; } @@ -169,6 +172,7 @@ class RequestContext implements IContextSource { } $this->wikipage = WikiPage::factory( $title ); } + return $this->wikipage; } @@ -188,6 +192,7 @@ class RequestContext implements IContextSource { if ( $this->output === null ) { $this->output = new OutputPage( $this ); } + return $this->output; } @@ -209,6 +214,7 @@ class RequestContext implements IContextSource { if ( $this->user === null ) { $this->user = User::newFromSession( $this->getRequest() ); } + return $this->user; } @@ -269,6 +275,7 @@ class RequestContext implements IContextSource { */ public function getLang() { wfDeprecated( __METHOD__, '1.19' ); + return $this->getLanguage(); } @@ -364,6 +371,7 @@ class RequestContext implements IContextSource { $this->skin->setContext( $this ); wfProfileOut( __METHOD__ . '-createskin' ); } + return $this->skin; } @@ -377,6 +385,7 @@ class RequestContext implements IContextSource { */ public function msg() { $args = func_get_args(); + return call_user_func_array( 'wfMessage', $args )->setContext( $this ); } @@ -392,6 +401,7 @@ class RequestContext implements IContextSource { if ( $instance === null ) { $instance = new self; } + return $instance; } @@ -446,7 +456,7 @@ class RequestContext implements IContextSource { $user = User::newFromName( $params['ip'], false ); } - $importSessionFunction = function( User $user, array $params ) { + $importSessionFunction = function ( User $user, array $params ) { global $wgRequest, $wgUser; $context = RequestContext::getMain(); @@ -482,7 +492,7 @@ class RequestContext implements IContextSource { $importSessionFunction( $user, $params ); // Set callback to save and close the new session and reload the old one - return new ScopedCallback( function() use ( $importSessionFunction, $oUser, $oParams ) { + return new ScopedCallback( function () use ( $importSessionFunction, $oUser, $oParams ) { $importSessionFunction( $oUser, $oParams ); } ); } @@ -510,6 +520,7 @@ class RequestContext implements IContextSource { $context->setRequest( new FauxRequest( $request ) ); } $context->user = User::newFromName( '127.0.0.1', false ); + return $context; } }