Change-Id: I1896d7b1ab5d11d3a609fd97db7c503ad6c590e5
* member variable and provide accessors to it.
*/
abstract class ContextSource implements IContextSource {
* member variable and provide accessors to it.
*/
abstract class ContextSource implements IContextSource {
/**
* @var IContextSource
*/
/**
* @var IContextSource
*/
public function getContext() {
if ( $this->context === null ) {
$class = get_class( $this );
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;
$this->context = RequestContext::getMain();
}
return $this->context;
* Set the IContextSource object
*
* @since 1.18
* Set the IContextSource object
*
* @since 1.18
- * @param $context IContextSource
+ * @param IContextSource $context
*/
public function setContext( IContextSource $context ) {
$this->context = $context;
*/
public function setContext( IContextSource $context ) {
$this->context = $context;
* Get the OutputPage object
*
* @since 1.18
* Get the OutputPage object
*
* @since 1.18
- * @return OutputPage object
*/
public function getOutput() {
return $this->getContext()->getOutput();
*/
public function getOutput() {
return $this->getContext()->getOutput();
* Parameters are the same as wfMessage()
*
* @since 1.18
* Parameters are the same as wfMessage()
*
* @since 1.18
- * @return Message object
*/
public function msg( /* $args */ ) {
$args = func_get_args();
*/
public function msg( /* $args */ ) {
$args = func_get_args();
* a different Title instance set on it.
*/
class DerivativeContext extends ContextSource {
* a different Title instance set on it.
*/
class DerivativeContext extends ContextSource {
- * @param $context IContextSource Context to inherit from
+ * @param IContextSource $context Context to inherit from
*/
public function __construct( IContextSource $context ) {
$this->setContext( $context );
*/
public function __construct( IContextSource $context ) {
$this->setContext( $context );
/**
* Set the WebRequest object
*
/**
* Set the WebRequest object
*
- * @param $r WebRequest object
*/
public function setRequest( WebRequest $r ) {
$this->request = $r;
*/
public function setRequest( WebRequest $r ) {
$this->request = $r;
/**
* Set the Title object
*
/**
* Set the Title object
*
- * @param $t Title object
*/
public function setTitle( Title $t ) {
$this->title = $t;
*/
public function setTitle( Title $t ) {
$this->title = $t;
* Set the WikiPage object
*
* @since 1.19
* Set the WikiPage object
*
* @since 1.19
- * @param $p WikiPage object
*/
public function setWikiPage( WikiPage $p ) {
$this->wikipage = $p;
*/
public function setWikiPage( WikiPage $p ) {
$this->wikipage = $p;
/**
* Set the OutputPage object
*
/**
* Set the OutputPage object
*
*/
public function setOutput( OutputPage $o ) {
$this->output = $o;
*/
public function setOutput( OutputPage $o ) {
$this->output = $o;
/**
* Get the OutputPage object
*
/**
* Get the OutputPage object
*
- * @return OutputPage object
*/
public function getOutput() {
if ( !is_null( $this->output ) ) {
*/
public function getOutput() {
if ( !is_null( $this->output ) ) {
/**
* Set the User object
*
/**
* Set the User object
*
*/
public function setUser( User $u ) {
$this->user = $u;
*/
public function setUser( User $u ) {
$this->user = $u;
* Set the Language object
*
* @deprecated 1.19 Use setLanguage instead
* Set the Language object
*
* @deprecated 1.19 Use setLanguage instead
- * @param $l Mixed Language instance or language code
+ * @param Language|string $l Language instance or language code
*/
public function setLang( $l ) {
wfDeprecated( __METHOD__, '1.19' );
*/
public function setLang( $l ) {
wfDeprecated( __METHOD__, '1.19' );
/**
* Set the Language object
*
/**
* Set the Language object
*
- * @param $l Mixed Language instance or language code
+ * @param Language|string $l Language instance or language code
* @throws MWException
* @since 1.19
*/
* @throws MWException
* @since 1.19
*/
/**
* Set the Skin object
*
/**
* Set the Skin object
*
*/
public function setSkin( Skin $s ) {
$this->skin = clone $s;
*/
public function setSkin( Skin $s ) {
$this->skin = clone $s;
return $this->getContext()->getSkin();
}
}
return $this->getContext()->getSkin();
}
}
* Interface for objects which can provide a context on request.
*/
interface IContextSource {
* Interface for objects which can provide a context on request.
*/
interface IContextSource {
/**
* Get the WebRequest object
*
/**
* Get the WebRequest object
*
/**
* Get the OutputPage object
*
/**
* Get the OutputPage object
*
- * @return OutputPage object
*/
public function getOutput();
*/
public function getOutput();
/**
* Get a Message object with context set
*
/**
* Get a Message object with context set
*
- * @return Message object
*/
public function msg();
}
*/
public function msg();
}
* Group all the pieces relevant to the context of a request into one instance
*/
class RequestContext implements IContextSource {
* Group all the pieces relevant to the context of a request into one instance
*/
class RequestContext implements IContextSource {
/**
* Set the WebRequest object
*
/**
* Set the WebRequest object
*
- * @param $r WebRequest object
*/
public function setRequest( WebRequest $r ) {
$this->request = $r;
*/
public function setRequest( WebRequest $r ) {
$this->request = $r;
/**
* Set the Title object
*
/**
* Set the Title object
*
- * @param $t Title object
*/
public function setTitle( Title $t ) {
$this->title = $t;
*/
public function setTitle( Title $t ) {
$this->title = $t;
* Set the WikiPage object
*
* @since 1.19
* Set the WikiPage object
*
* @since 1.19
- * @param $p WikiPage object
*/
public function setWikiPage( WikiPage $p ) {
$contextTitle = $this->getTitle();
*/
public function setWikiPage( WikiPage $p ) {
$contextTitle = $this->getTitle();
/**
* Get the OutputPage object
*
/**
* Get the OutputPage object
*
- * @return OutputPage object
*/
public function getOutput() {
if ( $this->output === null ) {
*/
public function getOutput() {
if ( $this->output === null ) {
/**
* Set the User object
*
/**
* Set the User object
*
*/
public function setUser( User $u ) {
$this->user = $u;
*/
public function setUser( User $u ) {
$this->user = $u;
/**
* Accepts a language code and ensures it's sane. Outputs a cleaned up language
* code and replaces with $wgLanguageCode if not sane.
/**
* Accepts a language code and ensures it's sane. Outputs a cleaned up language
* code and replaces with $wgLanguageCode if not sane.
+ * @param string $code Language code
* @return string
*/
public static function sanitizeLangCode( $code ) {
* @return string
*/
public static function sanitizeLangCode( $code ) {
$code = strtolower( $code );
# Validate $code
$code = strtolower( $code );
# Validate $code
- if( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) {
+ if ( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) {
wfDebug( "Invalid user language code\n" );
$code = $wgLanguageCode;
}
wfDebug( "Invalid user language code\n" );
$code = $wgLanguageCode;
}
* Set the Language object
*
* @deprecated 1.19 Use setLanguage instead
* Set the Language object
*
* @deprecated 1.19 Use setLanguage instead
- * @param $l Mixed Language instance or language code
+ * @param Language|string $l Language instance or language code
*/
public function setLang( $l ) {
wfDeprecated( __METHOD__, '1.19' );
*/
public function setLang( $l ) {
wfDeprecated( __METHOD__, '1.19' );
/**
* Set the Language object
*
/**
* Set the Language object
*
- * @param $l Mixed Language instance or language code
+ * @param Language|string $l Language instance or language code
* @throws MWException
* @since 1.19
*/
* @throws MWException
* @since 1.19
*/
wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$code ) );
wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$code ) );
- if( $code === $wgLanguageCode ) {
+ if ( $code === $wgLanguageCode ) {
$this->lang = $wgContLang;
} else {
$obj = Language::factory( $code );
$this->lang = $wgContLang;
} else {
$obj = Language::factory( $code );
/**
* Set the Skin object
*
/**
* Set the Skin object
*
*/
public function setSkin( Skin $s ) {
$this->skin = clone $s;
*/
public function setSkin( Skin $s ) {
$this->skin = clone $s;
// If the hook worked try to set a skin from it
if ( $skin instanceof Skin ) {
$this->skin = $skin;
// If the hook worked try to set a skin from it
if ( $skin instanceof Skin ) {
$this->skin = $skin;
- } elseif ( is_string($skin) ) {
+ } elseif ( is_string( $skin ) ) {
$this->skin = Skin::newFromKey( $skin );
}
$this->skin = Skin::newFromKey( $skin );
}
// then go through the normal processing to load a skin
if ( $this->skin === null ) {
global $wgHiddenPrefs;
// then go through the normal processing to load a skin
if ( $this->skin === null ) {
global $wgHiddenPrefs;
- if( !in_array( 'skin', $wgHiddenPrefs ) ) {
+ if ( !in_array( 'skin', $wgHiddenPrefs ) ) {
# get the user skin
$userSkin = $this->getUser()->getOption( 'skin' );
$userSkin = $this->getRequest()->getVal( 'useskin', $userSkin );
# get the user skin
$userSkin = $this->getUser()->getOption( 'skin' );
$userSkin = $this->getRequest()->getVal( 'useskin', $userSkin );
* Get a Message object with context set
* Parameters are the same as wfMessage()
*
* Get a Message object with context set
* Parameters are the same as wfMessage()
*
- * @return Message object
*/
public function msg() {
$args = func_get_args();
*/
public function msg() {
$args = func_get_args();
/**
* Get the RequestContext object associated with the main request
*
/**
* Get the RequestContext object associated with the main request
*
- * @return RequestContext object
+ * @return RequestContext
*/
public static function getMain() {
static $instance = null;
*/
public static function getMain() {
static $instance = null;
* language or a uselang param in the fauxrequest data may change the lang
* - Skin will be based on the anonymous user, should be the wiki's default skin
*
* language or a uselang param in the fauxrequest data may change the lang
* - Skin will be based on the anonymous user, should be the wiki's default skin
*
- * @param $title Title Title to use for the extraneous request
- * @param $request Mixed A WebRequest or data to use for a FauxRequest
+ * @param Title $title Title to use for the extraneous request
+ * @param mixed $request A WebRequest or data to use for a FauxRequest
* @return RequestContext
*/
* @return RequestContext
*/
- public static function newExtraneousContext( Title $title, $request=array() ) {
+ public static function newExtraneousContext( Title $title, $request = array() ) {
$context = new self;
$context->setTitle( $title );
if ( $request instanceof WebRequest ) {
$context = new self;
$context->setTitle( $title );
if ( $request instanceof WebRequest ) {
$context->user = User::newFromName( '127.0.0.1', false );
return $context;
}
$context->user = User::newFromName( '127.0.0.1', false );
return $context;
}