mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-18 02:41:01 +00:00
Merge "Remove unused return values and reduce code complexity"
This commit is contained in:
commit
f5f9c0971d
|
@ -750,7 +750,7 @@ class SimpleCaptcha {
|
|||
}
|
||||
foreach ( $build as $key => $value ) {
|
||||
$regexes[] = $regexStart[$key] .
|
||||
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $build[$key] ) ) .
|
||||
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $value ) ) .
|
||||
$regexEnd[$key];
|
||||
}
|
||||
return $regexes;
|
||||
|
@ -1112,7 +1112,7 @@ class SimpleCaptcha {
|
|||
* Extract a list of all recognized HTTP links in the text.
|
||||
* @param Title $title
|
||||
* @param string $text
|
||||
* @return array of strings
|
||||
* @return string[]
|
||||
*/
|
||||
private function findLinks( $title, $text ) {
|
||||
$parser = MediaWikiServices::getInstance()->getParser();
|
||||
|
|
|
@ -14,12 +14,9 @@ class ConfirmEditHooks {
|
|||
public static function getInstance() {
|
||||
global $wgCaptcha, $wgCaptchaClass;
|
||||
|
||||
$class = $wgCaptchaClass;
|
||||
if ( $class == null ) {
|
||||
$class = 'SimpleCaptcha';
|
||||
}
|
||||
if ( !static::$instanceCreated ) {
|
||||
static::$instanceCreated = true;
|
||||
$class = $wgCaptchaClass ?: SimpleCaptcha::class;
|
||||
$wgCaptcha = new $class;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@ class CaptchaAuthenticationRequest extends AuthenticationRequest {
|
|||
}
|
||||
|
||||
public function getMetadata() {
|
||||
$captcha = ConfirmEditHooks::getInstance();
|
||||
return $captcha->describeCaptchaType();
|
||||
return ( ConfirmEditHooks::getInstance() )->describeCaptchaType();
|
||||
}
|
||||
|
||||
public static function __set_state( $data ) {
|
||||
|
|
|
@ -10,16 +10,13 @@ class SpecialCaptcha extends UnlistedSpecialPage {
|
|||
|
||||
$instance = ConfirmEditHooks::getInstance();
|
||||
|
||||
switch ( $par ) {
|
||||
case "image":
|
||||
if ( method_exists( $instance, 'showImage' ) ) {
|
||||
if ( $par === 'image' && method_exists( $instance, 'showImage' ) ) {
|
||||
// @todo: Do this in a more OOP way
|
||||
/** @phan-suppress-next-line PhanUndeclaredMethod */
|
||||
return $instance->showImage();
|
||||
}
|
||||
case "help":
|
||||
default:
|
||||
return $instance->showHelp();
|
||||
$instance->showImage();
|
||||
return;
|
||||
}
|
||||
|
||||
$instance->showHelp();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,7 @@ class CaptchaCacheStore extends CaptchaStore {
|
|||
|
||||
public function retrieve( $index ) {
|
||||
$cache = $this->cache;
|
||||
$info = $cache->get( $cache->makeKey( 'captcha', $index ) );
|
||||
if ( $info ) {
|
||||
return $info;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $cache->get( $cache->makeKey( 'captcha', $index ) ) ?: false;
|
||||
}
|
||||
|
||||
public function clear( $index ) {
|
||||
|
|
Loading…
Reference in a new issue