A few very minor code cleanups

A bunch of very minor code cleanups I collected in my local dev
environment the past months:
* Remove dead code.
* Make use of the ??= operator where possible.
* Fix inconsistent @var syntax.

Change-Id: Ie8de34f15503eb2bf0f6df855af55c212235dff3
This commit is contained in:
thiemowmde 2024-09-13 13:04:13 +02:00
parent 5a86fd08ff
commit 50f533c9e9
2 changed files with 4 additions and 10 deletions

View file

@ -282,7 +282,7 @@ class SimpleCaptcha {
public function showEditFormFields( EditPage $editPage, OutputPage $out ) {
$out->enableOOUI();
$page = $editPage->getArticle()->getPage();
$key = $key = CacheKeyHelper::getKeyForPage( $page );
$key = CacheKeyHelper::getKeyForPage( $page );
if ( !isset( $this->activatedCaptchas[$key] ) ) {
return;
}
@ -605,9 +605,7 @@ class SimpleCaptcha {
}
} else {
// Get link changes in the slowest way known to man
if ( $oldtext === null ) {
$oldtext = $this->loadText( $title, $section );
}
$oldtext ??= $this->loadText( $title, $section );
$oldLinks = $this->findLinks( $title, $oldtext );
$newLinks = $this->findLinks( $title, $newtext );
}
@ -635,9 +633,7 @@ class SimpleCaptcha {
);
}
// Custom regex checks. Reuse $oldtext if set above.
if ( $oldtext === null ) {
$oldtext = $this->loadText( $title, $section );
}
$oldtext ??= $this->loadText( $title, $section );
foreach ( $wgCaptchaRegexes as $regex ) {
$newMatches = [];

View file

@ -190,9 +190,7 @@ class GenerateFancyCaptchas extends Maintenance {
$captchasGenerated = iterator_count( $iter );
$filesToStore = [];
/**
* @var $fileInfo SplFileInfo
*/
/** @var SplFileInfo $fileInfo */
foreach ( $iter as $fileInfo ) {
if ( !$fileInfo->isFile() ) {
continue;