From 096e4a709f0b7566c185263696d83ad937a6120a Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 8 Nov 2022 16:41:24 +0000 Subject: [PATCH] Use short array destructuring instead of list() Introduced in PHP 7.1. Because it's shorter and looks nice. Change-Id: I395e791aed6cc99b7ce1273f51c292e29360443a --- includes/DiscussionParser.php | 4 ++-- includes/EchoDiffParser.php | 6 +++--- includes/ForeignNotifications.php | 4 ++-- includes/Formatters/EchoEventPresentationModel.php | 4 ++-- includes/Formatters/EchoUserRightsPresentationModel.php | 2 +- maintenance/removeOrphanedEvents.php | 2 +- tests/phpunit/UserLocatorTest.php | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php index ef40b18f3..d8c216dc4 100644 --- a/includes/DiscussionParser.php +++ b/includes/DiscussionParser.php @@ -931,7 +931,7 @@ abstract class EchoDiscussionParser { return true; } - list( , $foundUser ) = $userData; + [ , $foundUser ] = $userData; $userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils(); return $userNameUtils->getCanonical( $foundUser, UserNameUtils::RIGOR_NONE ) === @@ -1008,7 +1008,7 @@ abstract class EchoDiscussionParser { continue; } - list( $signaturePos, $user ) = $userData; + [ $signaturePos, $user ] = $userData; $signature = substr( $line, $signaturePos ); $output[$user] = $signature; diff --git a/includes/EchoDiffParser.php b/includes/EchoDiffParser.php index 084f6e59a..a21f24326 100644 --- a/includes/EchoDiffParser.php +++ b/includes/EchoDiffParser.php @@ -191,9 +191,9 @@ class EchoDiffParser { $change = null; } // @@ -start,numLines +start,numLines @@ - list( , $left, $right ) = explode( ' ', $line, 3 ); - list( $this->leftPos ) = explode( ',', substr( $left, 1 ), 2 ); - list( $this->rightPos ) = explode( ',', substr( $right, 1 ), 2 ); + [ , $left, $right ] = explode( ' ', $line, 3 ); + [ $this->leftPos ] = explode( ',', substr( $left, 1 ), 2 ); + [ $this->rightPos ] = explode( ',', substr( $right, 1 ), 2 ); $this->leftPos = (int)$this->leftPos; $this->rightPos = (int)$this->rightPos; diff --git a/includes/ForeignNotifications.php b/includes/ForeignNotifications.php index 92a09457d..40dbe3238 100644 --- a/includes/ForeignNotifications.php +++ b/includes/ForeignNotifications.php @@ -205,7 +205,7 @@ class EchoForeignNotifications { $data = []; foreach ( $wikis as $wiki ) { $siteFromDB = $wgConf->siteFromDB( $wiki ); - list( $major, $minor ) = $siteFromDB; + [ $major, $minor ] = $siteFromDB; $server = $wgConf->get( 'wgServer', $wiki, $major, [ 'lang' => $minor, 'site' => $major ] ); $scriptPath = $wgConf->get( 'wgScriptPath', $wiki, $major, [ 'lang' => $minor, 'site' => $major ] ); $articlePath = $wgConf->get( 'wgArticlePath', $wiki, $major, [ 'lang' => $minor, 'site' => $major ] ); @@ -238,7 +238,7 @@ class EchoForeignNotifications { if ( $siteFromDB === null ) { $siteFromDB = $wgConf->siteFromDB( $wikiId ); } - list( $site, $langCode ) = $siteFromDB; + [ $site, $langCode ] = $siteFromDB; // try to fetch site name for this specific wiki, or fallback to the // general project's sitename if there is no override diff --git a/includes/Formatters/EchoEventPresentationModel.php b/includes/Formatters/EchoEventPresentationModel.php index be33c2c55..739ef7893 100644 --- a/includes/Formatters/EchoEventPresentationModel.php +++ b/includes/Formatters/EchoEventPresentationModel.php @@ -297,7 +297,7 @@ abstract class EchoEventPresentationModel implements JsonSerializable, MessageLo * the user is visible or not. * @par Example: * @code - * list( $formattedName, $genderName ) = $this->getAgentForOutput(); + * [ $formattedName, $genderName ] = $this->getAgentForOutput(); * $msg->params( $formattedName, $genderName ); * @endcode */ @@ -330,7 +330,7 @@ abstract class EchoEventPresentationModel implements JsonSerializable, MessageLo */ final protected function getMessageWithAgent( $key ) { $msg = $this->msg( $key ); - list( $formattedName, $genderName ) = $this->getAgentForOutput(); + [ $formattedName, $genderName ] = $this->getAgentForOutput(); $msg->params( $formattedName, $genderName ); return $msg; } diff --git a/includes/Formatters/EchoUserRightsPresentationModel.php b/includes/Formatters/EchoUserRightsPresentationModel.php index 27317de9b..a5b500590 100644 --- a/includes/Formatters/EchoUserRightsPresentationModel.php +++ b/includes/Formatters/EchoUserRightsPresentationModel.php @@ -17,7 +17,7 @@ class EchoUserRightsPresentationModel extends EchoEventPresentationModel { } public function getHeaderMessage() { - list( $formattedName, $genderName ) = $this->getAgentForOutput(); + [ $formattedName, $genderName ] = $this->getAgentForOutput(); $add = array_map( [ $this->language, 'embedBidi' ], $this->getLocalizedGroupNames( array_values( $this->event->getExtraParam( 'add', [] ) ) ) diff --git a/maintenance/removeOrphanedEvents.php b/maintenance/removeOrphanedEvents.php index 1351b1d92..a1b49d17a 100644 --- a/maintenance/removeOrphanedEvents.php +++ b/maintenance/removeOrphanedEvents.php @@ -42,7 +42,7 @@ class RemoveOrphanedEvents extends LoggedUpdateMaintenance { $targetsProcessedTotal = 0; while ( $startId < $maxId ) { $startId += $this->getBatchSize() * 1000; - list( $eventsProcessed, $targetsProcessed ) = $this->doMajorBatch( $startId ); + [ $eventsProcessed, $targetsProcessed ] = $this->doMajorBatch( $startId ); $eventsProcessedTotal += $eventsProcessed; $targetsProcessedTotal += $targetsProcessed; } diff --git a/tests/phpunit/UserLocatorTest.php b/tests/phpunit/UserLocatorTest.php index 6ce990d72..b72027c5b 100644 --- a/tests/phpunit/UserLocatorTest.php +++ b/tests/phpunit/UserLocatorTest.php @@ -71,7 +71,7 @@ class EchoUserLocatorTest extends MediaWikiIntegrationTestCase { */ public function testLocateTalkPageOwner( $message, $expect, Title $title = null ) { if ( $expect instanceof Closure ) { - list( $expect, $title ) = $expect(); + [ $expect, $title ] = $expect(); } $event = $this->createMock( EchoEvent::class ); $event->method( 'getTitle' ) @@ -103,7 +103,7 @@ class EchoUserLocatorTest extends MediaWikiIntegrationTestCase { * @dataProvider locateArticleCreatorProvider */ public function testLocateArticleCreator( $message, $initialize ) { - list( $expect, $title, $user ) = $initialize(); + [ $expect, $title, $user ] = $initialize(); $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title )->doUserEditContent( /* $content = */ ContentHandler::makeContent( 'content', $title ), /* $user = */ $user,