X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FStatus.php;h=932fd2a65078c6b9343a2c41e44a48d413067c02;hp=877d2218a29e332ba52b330a41e6d9d1881bb962;hb=25242105e8fd03c9900250bdf9ea91be9a286625;hpb=4e021bb8d4741d5af0f02942fe3c33a19e7fabca diff --git a/includes/Status.php b/includes/Status.php index 877d2218a2..932fd2a650 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -38,7 +38,7 @@ * so that a lack of error-handling will be explicit. */ class Status extends StatusValue { - /** @var callable */ + /** @var callable|false */ public $cleanCallback = false; /** @@ -78,7 +78,8 @@ class Status extends StatusValue { function __get( $name ) { if ( $name === 'ok' ) { return $this->isOK(); - } elseif ( $name === 'errors' ) { + } + if ( $name === 'errors' ) { return $this->getErrors(); } @@ -109,11 +110,12 @@ class Status extends StatusValue { * the error messages, and one that contains the warnings, only. The returned array is * defined as: * [ - * 0 => object(Status) # the Status with error messages, only + * 0 => object(Status) # The Status with error messages, only * 1 => object(Status) # The Status with warning messages, only * ] * * @return Status[] + * @suppress PhanUndeclaredProperty Status vs StatusValue */ public function splitByErrorType() { list( $errorsOnlyStatus, $warningsOnlyStatus ) = parent::splitByErrorType(); @@ -148,21 +150,18 @@ class Status extends StatusValue { } /** - * @param string|Language|null $lang Language to use for processing + * @param string|Language|null|StubUserLang $lang Language to use for processing * messages, or null to default to the user language. - * @return Language + * @return Language|StubUserLang */ protected function languageFromParam( $lang ) { - global $wgLang; - if ( $lang === null ) { - // @todo: Use RequestContext::getMain()->getLanguage() instead - return $wgLang; - } elseif ( $lang instanceof Language || $lang instanceof StubUserLang ) { + return RequestContext::getMain()->getLanguage(); + } + if ( $lang instanceof Language || $lang instanceof StubUserLang ) { return $lang; - } else { - return Language::factory( $lang ); } + return Language::factory( $lang ); } /** @@ -171,14 +170,14 @@ class Status extends StatusValue { * @param string|bool $shortContext A short enclosing context message name, to * be used when there is a single error * @param string|bool $longContext A long enclosing context message name, for a list - * @param string|Language|null $lang Language to use for processing messages + * @param string|Language|null|StubUserLang $lang Language to use for processing messages * @return string */ public function getWikiText( $shortContext = false, $longContext = false, $lang = null ) { $lang = $this->languageFromParam( $lang ); $rawErrors = $this->getErrors(); - if ( count( $rawErrors ) == 0 ) { + if ( count( $rawErrors ) === 0 ) { if ( $this->isOK() ) { $this->fatal( 'internalerror_info', __METHOD__ . " called for a good result, this is incorrect\n" ); @@ -188,7 +187,7 @@ class Status extends StatusValue { } $rawErrors = $this->getErrors(); // just added a fatal } - if ( count( $rawErrors ) == 1 ) { + if ( count( $rawErrors ) === 1 ) { $s = $this->getErrorMessage( $rawErrors[0], $lang )->plain(); if ( $shortContext ) { $s = wfMessage( $shortContext, $s )->inLanguage( $lang )->plain(); @@ -234,7 +233,7 @@ class Status extends StatusValue { $lang = $this->languageFromParam( $lang ); $rawErrors = $this->getErrors(); - if ( count( $rawErrors ) == 0 ) { + if ( count( $rawErrors ) === 0 ) { if ( $this->isOK() ) { $this->fatal( 'internalerror_info', __METHOD__ . " called for a good result, this is incorrect\n" ); @@ -244,7 +243,7 @@ class Status extends StatusValue { } $rawErrors = $this->getErrors(); // just added a fatal } - if ( count( $rawErrors ) == 1 ) { + if ( count( $rawErrors ) === 1 ) { $s = $this->getErrorMessage( $rawErrors[0], $lang ); if ( $shortContext ) { $s = wfMessage( $shortContext, $s )->inLanguage( $lang ); @@ -297,7 +296,7 @@ class Status extends StatusValue { } elseif ( is_string( $error ) ) { $msg = wfMessage( $error ); } else { - throw new UnexpectedValueException( "Got " . get_class( $error ) . " for key." ); + throw new UnexpectedValueException( 'Got ' . get_class( $error ) . ' for key.' ); } $msg->inLanguage( $this->languageFromParam( $lang ) ); @@ -388,6 +387,7 @@ class Status extends StatusValue { /** * Don't save the callback when serializing, because Closures can't be * serialized and we're going to clear it in __wakeup anyway. + * @return array */ function __sleep() { $keys = array_keys( get_object_vars( $this ) );