From 9fb95da8195e86384f973b1edf878d9df3cbf2c3 Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Fri, 19 Apr 2024 15:10:15 +0200 Subject: [PATCH] Modernize the code a little bit For example: * Remove redundant PHPDoc blocks that just duplicate existing information and aren't needed any more with our current PHPCS rule set. * Add some very obvious type declarations. * Use ??= where it makes sense. Change-Id: I5c182cc961c6eeccead79ff49b0376eee2418acf --- includes/Hooks/NukeHookRunner.php | 6 +-- includes/SpecialNuke.php | 85 ++++++++----------------------- 2 files changed, 23 insertions(+), 68 deletions(-) diff --git a/includes/Hooks/NukeHookRunner.php b/includes/Hooks/NukeHookRunner.php index 68bccbb4..e12fa1bc 100644 --- a/includes/Hooks/NukeHookRunner.php +++ b/includes/Hooks/NukeHookRunner.php @@ -11,12 +11,8 @@ use MediaWiki\Title\Title; */ class NukeHookRunner implements NukeDeletePageHook, NukeGetNewPagesHook { - /** @var HookContainer */ - private $hookContainer; + private HookContainer $hookContainer; - /** - * @param HookContainer $hookContainer - */ public function __construct( HookContainer $hookContainer ) { $this->hookContainer = $hookContainer; } diff --git a/includes/SpecialNuke.php b/includes/SpecialNuke.php index 057d065e..319c2332 100644 --- a/includes/SpecialNuke.php +++ b/includes/SpecialNuke.php @@ -32,36 +32,14 @@ class SpecialNuke extends SpecialPage { /** @var NukeHookRunner|null */ private $hookRunner; - /** @var JobQueueGroup */ - private $jobQueueGroup; + private JobQueueGroup $jobQueueGroup; + private IConnectionProvider $dbProvider; + private PermissionManager $permissionManager; + private RepoGroup $repoGroup; + private UserFactory $userFactory; + private UserNamePrefixSearch $userNamePrefixSearch; + private UserNameUtils $userNameUtils; - /** @var IConnectionProvider */ - private $dbProvider; - - /** @var PermissionManager */ - private $permissionManager; - - /** @var RepoGroup */ - private $repoGroup; - - /** @var UserFactory */ - private $userFactory; - - /** @var UserNamePrefixSearch */ - private $userNamePrefixSearch; - - /** @var UserNameUtils */ - private $userNameUtils; - - /** - * @param JobQueueGroup $jobQueueGroup - * @param IConnectionProvider $dbProvider - * @param PermissionManager $permissionManager - * @param RepoGroup $repoGroup - * @param UserFactory $userFactory - * @param UserNamePrefixSearch $userNamePrefixSearch - * @param UserNameUtils $userNameUtils - */ public function __construct( JobQueueGroup $jobQueueGroup, IConnectionProvider $dbProvider, @@ -131,7 +109,6 @@ class SpecialNuke extends SpecialPage { if ( $pages ) { $this->doDelete( $pages, $reason ); - return; } } elseif ( $req->getRawVal( 'action' ) === 'submit' ) { @@ -151,7 +128,7 @@ class SpecialNuke extends SpecialPage { * * @param string $userName */ - protected function promptForm( $userName = '' ) { + protected function promptForm( $userName = '' ): void { $out = $this->getOutput(); $out->addWikiMsg( 'nuke-tools' ); @@ -208,12 +185,12 @@ class SpecialNuke extends SpecialPage { * @param int $limit * @param int|null $namespace */ - protected function listForm( $username, $reason, $limit, $namespace = null ) { + protected function listForm( $username, $reason, $limit, $namespace = null ): void { $out = $this->getOutput(); $pages = $this->getNewPages( $username, $limit, $namespace ); - if ( count( $pages ) === 0 ) { + if ( !$pages ) { if ( $username === '' ) { $out->addWikiMsg( 'nuke-nopages-global' ); } else { @@ -221,7 +198,6 @@ class SpecialNuke extends SpecialPage { } $this->promptForm( $username ); - return; } @@ -278,15 +254,10 @@ class SpecialNuke extends SpecialPage { 'name' => 'nukelist' ] ) . Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() ) . - $dropdown . $reasonField - ); - - // Select: All, None, Invert - $listToggle = new ListToggle( $this->getOutput() ); - $selectLinks = $listToggle->getHTML(); - - $out->addHTML( - $selectLinks . + $dropdown . + $reasonField . + // Select: All, None, Invert + ( new ListToggle( $this->getOutput() ) )->getHTML() . '