From 50f533c9e93ba839f6358b45613906ab82a77c6c Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Fri, 13 Sep 2024 13:04:13 +0200 Subject: [PATCH] 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 --- SimpleCaptcha/SimpleCaptcha.php | 10 +++------- maintenance/GenerateFancyCaptchas.php | 4 +--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/SimpleCaptcha/SimpleCaptcha.php b/SimpleCaptcha/SimpleCaptcha.php index 68f926407..8fbc9c501 100644 --- a/SimpleCaptcha/SimpleCaptcha.php +++ b/SimpleCaptcha/SimpleCaptcha.php @@ -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 = []; diff --git a/maintenance/GenerateFancyCaptchas.php b/maintenance/GenerateFancyCaptchas.php index 25d659b34..35bb9d9f4 100644 --- a/maintenance/GenerateFancyCaptchas.php +++ b/maintenance/GenerateFancyCaptchas.php @@ -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;