summaryrefslogtreecommitdiff
path: root/includes/context/DerivativeContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/context/DerivativeContext.php')
-rw-r--r--includes/context/DerivativeContext.php47
1 files changed, 32 insertions, 15 deletions
diff --git a/includes/context/DerivativeContext.php b/includes/context/DerivativeContext.php
index 5adf3621..fd9bf963 100644
--- a/includes/context/DerivativeContext.php
+++ b/includes/context/DerivativeContext.php
@@ -30,7 +30,6 @@
* a different Title instance set on it.
*/
class DerivativeContext extends ContextSource {
-
/**
* @var WebRequest
*/
@@ -68,7 +67,7 @@ class DerivativeContext extends ContextSource {
/**
* Constructor
- * @param $context IContextSource Context to inherit from
+ * @param IContextSource $context Context to inherit from
*/
public function __construct( IContextSource $context ) {
$this->setContext( $context );
@@ -77,7 +76,7 @@ class DerivativeContext extends ContextSource {
/**
* Set the WebRequest object
*
- * @param $r WebRequest object
+ * @param WebRequest $r
*/
public function setRequest( WebRequest $r ) {
$this->request = $r;
@@ -99,9 +98,12 @@ class DerivativeContext extends ContextSource {
/**
* Set the Title object
*
- * @param $t Title object
+ * @param Title $t
*/
- public function setTitle( Title $t ) {
+ public function setTitle( $t ) {
+ if ( $t !== null && !$t instanceof Title ) {
+ throw new MWException( __METHOD__ . " expects an instance of Title" );
+ }
$this->title = $t;
}
@@ -140,7 +142,7 @@ class DerivativeContext extends ContextSource {
* Set the WikiPage object
*
* @since 1.19
- * @param $p WikiPage object
+ * @param WikiPage $p
*/
public function setWikiPage( WikiPage $p ) {
$this->wikipage = $p;
@@ -166,7 +168,7 @@ class DerivativeContext extends ContextSource {
/**
* Set the OutputPage object
*
- * @param $o OutputPage
+ * @param OutputPage $o
*/
public function setOutput( OutputPage $o ) {
$this->output = $o;
@@ -175,7 +177,7 @@ class DerivativeContext extends ContextSource {
/**
* Get the OutputPage object
*
- * @return OutputPage object
+ * @return OutputPage
*/
public function getOutput() {
if ( !is_null( $this->output ) ) {
@@ -188,7 +190,7 @@ class DerivativeContext extends ContextSource {
/**
* Set the User object
*
- * @param $u User
+ * @param User $u
*/
public function setUser( User $u ) {
$this->user = $u;
@@ -210,8 +212,8 @@ class DerivativeContext extends ContextSource {
/**
* Set the Language object
*
- * @deprecated 1.19 Use setLanguage instead
- * @param $l Mixed Language instance or language code
+ * @deprecated since 1.19 Use setLanguage instead
+ * @param Language|string $l Language instance or language code
*/
public function setLang( $l ) {
wfDeprecated( __METHOD__, '1.19' );
@@ -221,7 +223,8 @@ class DerivativeContext extends ContextSource {
/**
* 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
*/
public function setLanguage( $l ) {
@@ -237,7 +240,7 @@ class DerivativeContext extends ContextSource {
}
/**
- * @deprecated 1.19 Use getLanguage instead
+ * @deprecated since 1.19 Use getLanguage instead
* @return Language
*/
public function getLang() {
@@ -262,7 +265,7 @@ class DerivativeContext extends ContextSource {
/**
* Set the Skin object
*
- * @param $s Skin
+ * @param Skin $s
*/
public function setSkin( Skin $s ) {
$this->skin = clone $s;
@@ -282,5 +285,19 @@ class DerivativeContext extends ContextSource {
}
}
+ /**
+ * Get a message using the current context.
+ *
+ * This can't just inherit from ContextSource, since then
+ * it would set only the original context, and not take
+ * into account any changes.
+ *
+ * @param String Message name
+ * @param Variable number of message arguments
+ * @return Message
+ */
+ public function msg() {
+ $args = func_get_args();
+ return call_user_func_array( 'wfMessage', $args )->setContext( $this );
+ }
}
-