mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
Remove unused return values and reduce code complexity
Changes: * Do not return anything in a method that is not expected to return something. * Inline some previously hard to read code. * More specific type hints, if possible. Change-Id: I0e460899eea07d8733f638a11133adc3000f0542
This commit is contained in:
parent
cd15b4d9a3
commit
0dfd1f4ed1
|
@ -749,7 +749,7 @@ class SimpleCaptcha {
|
||||||
}
|
}
|
||||||
foreach ( $build as $key => $value ) {
|
foreach ( $build as $key => $value ) {
|
||||||
$regexes[] = $regexStart[$key] .
|
$regexes[] = $regexStart[$key] .
|
||||||
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $build[$key] ) ) .
|
str_replace( '/', '\/', preg_replace( '|\\\*/|', '/', $value ) ) .
|
||||||
$regexEnd[$key];
|
$regexEnd[$key];
|
||||||
}
|
}
|
||||||
return $regexes;
|
return $regexes;
|
||||||
|
@ -1111,7 +1111,7 @@ class SimpleCaptcha {
|
||||||
* Extract a list of all recognized HTTP links in the text.
|
* Extract a list of all recognized HTTP links in the text.
|
||||||
* @param Title $title
|
* @param Title $title
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @return array of strings
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function findLinks( $title, $text ) {
|
private function findLinks( $title, $text ) {
|
||||||
$parser = MediaWikiServices::getInstance()->getParser();
|
$parser = MediaWikiServices::getInstance()->getParser();
|
||||||
|
|
|
@ -13,12 +13,9 @@ class ConfirmEditHooks {
|
||||||
public static function getInstance() {
|
public static function getInstance() {
|
||||||
global $wgCaptcha, $wgCaptchaClass;
|
global $wgCaptcha, $wgCaptchaClass;
|
||||||
|
|
||||||
$class = $wgCaptchaClass;
|
|
||||||
if ( $class == null ) {
|
|
||||||
$class = 'SimpleCaptcha';
|
|
||||||
}
|
|
||||||
if ( !static::$instanceCreated ) {
|
if ( !static::$instanceCreated ) {
|
||||||
static::$instanceCreated = true;
|
static::$instanceCreated = true;
|
||||||
|
$class = $wgCaptchaClass ?: SimpleCaptcha::class;
|
||||||
$wgCaptcha = new $class;
|
$wgCaptcha = new $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,7 @@ class CaptchaAuthenticationRequest extends AuthenticationRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMetadata() {
|
public function getMetadata() {
|
||||||
$captcha = ConfirmEditHooks::getInstance();
|
return ( ConfirmEditHooks::getInstance() )->describeCaptchaType();
|
||||||
return $captcha->describeCaptchaType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function __set_state( $data ) {
|
public static function __set_state( $data ) {
|
||||||
|
|
|
@ -10,16 +10,13 @@ class SpecialCaptcha extends UnlistedSpecialPage {
|
||||||
|
|
||||||
$instance = ConfirmEditHooks::getInstance();
|
$instance = ConfirmEditHooks::getInstance();
|
||||||
|
|
||||||
switch ( $par ) {
|
if ( $par === 'image' && method_exists( $instance, 'showImage' ) ) {
|
||||||
case "image":
|
|
||||||
if ( method_exists( $instance, 'showImage' ) ) {
|
|
||||||
// @todo: Do this in a more OOP way
|
// @todo: Do this in a more OOP way
|
||||||
/** @phan-suppress-next-line PhanUndeclaredMethod */
|
/** @phan-suppress-next-line PhanUndeclaredMethod */
|
||||||
return $instance->showImage();
|
$instance->showImage();
|
||||||
}
|
return;
|
||||||
case "help":
|
|
||||||
default:
|
|
||||||
return $instance->showHelp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$instance->showHelp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,7 @@ class CaptchaCacheStore extends CaptchaStore {
|
||||||
|
|
||||||
public function retrieve( $index ) {
|
public function retrieve( $index ) {
|
||||||
$cache = $this->cache;
|
$cache = $this->cache;
|
||||||
$info = $cache->get( $cache->makeKey( 'captcha', $index ) );
|
return $cache->get( $cache->makeKey( 'captcha', $index ) ) ?: false;
|
||||||
if ( $info ) {
|
|
||||||
return $info;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear( $index ) {
|
public function clear( $index ) {
|
||||||
|
|
Loading…
Reference in a new issue