From be42e09aa866d7def54ead06c91d5dc9c8210ce5 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Mon, 26 Jun 2017 18:35:31 +0200 Subject: [PATCH 1/1] build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0 The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment. Will be fixed in next version, see T167168 Changed: - Remove duplicate newline at end of file - Add space between function and ( for closures - and -> &&, or -> || Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311 --- includes/MediaWikiServices.php | 2 +- includes/PageProps.php | 2 +- includes/ServiceWiring.php | 68 +++++++++---------- includes/WatchedItemQueryService.php | 2 +- includes/WatchedItemStore.php | 6 +- includes/Xml.php | 1 - includes/api/ApiQueryInfo.php | 6 +- includes/api/ApiQueryPrefixSearch.php | 2 +- includes/api/ApiQueryUsers.php | 2 +- includes/changes/EnhancedChangesList.php | 2 +- includes/diff/DifferenceEngine.php | 4 +- includes/filerepo/ForeignDBViaLBRepo.php | 2 +- includes/filerepo/LocalRepo.php | 2 +- includes/filerepo/file/LocalFile.php | 2 +- includes/htmlform/HTMLFormElement.php | 2 +- .../fields/HTMLUsersMultiselectField.php | 2 +- includes/installer/DatabaseInstaller.php | 2 +- includes/installer/Installer.php | 2 +- includes/libs/CSSMin.php | 2 +- includes/libs/HashRing.php | 2 +- .../filebackend/FileBackendMultiWrite.php | 6 +- includes/libs/objectcache/BagOStuff.php | 2 +- .../libs/rdbms/database/DatabaseSqlite.php | 1 - .../resultwrapper/FakeResultWrapper.php | 1 - .../rdbms/exception/DBTransactionError.php | 1 - includes/libs/rdbms/lbfactory/LBFactory.php | 2 +- includes/libs/stats/SamplingStatsdClient.php | 2 +- .../virtualrest/VirtualRESTServiceClient.php | 4 +- .../linkeddata/PageDataRequestHandler.php | 2 +- includes/logging/RightsLogFormatter.php | 4 +- includes/page/WikiPage.php | 2 +- includes/parser/Parser.php | 2 +- includes/profiler/ProfilerSectionOnly.php | 2 +- includes/profiler/ProfilerXhprof.php | 2 +- includes/registration/ExtensionProcessor.php | 2 +- includes/registration/ExtensionRegistry.php | 2 +- includes/search/SearchEngine.php | 10 +-- includes/search/SearchSuggestionSet.php | 4 +- includes/specialpage/SpecialPage.php | 2 +- includes/specials/SpecialBotPasswords.php | 6 +- .../specials/SpecialChangeContentModel.php | 2 +- includes/specials/SpecialMovepage.php | 2 +- includes/specials/SpecialUserrights.php | 6 +- includes/specials/SpecialVersion.php | 2 +- includes/tidy/Balancer.php | 2 +- includes/user/User.php | 4 +- includes/utils/BatchRowUpdate.php | 2 +- includes/utils/ZipDirectoryReader.php | 1 - maintenance/CodeCleanerGlobalsPass.inc | 1 - maintenance/validateRegistrationFile.php | 2 +- phpcs.xml | 2 +- tests/parser/ParserTestRunner.php | 6 +- tests/phpunit/MediaWikiTestCase.php | 2 +- .../GlobalFunctions/wfArrayFilterTest.php | 10 +-- tests/phpunit/includes/LinkerTest.php | 6 +- .../includes/MediaWikiServicesTest.php | 12 ++-- .../Services/ServiceContainerTest.php | 56 +++++++-------- .../phpunit/includes/Services/TestWiring1.php | 2 +- .../phpunit/includes/Services/TestWiring2.php | 2 +- .../WatchedItemQueryServiceUnitTest.php | 18 ++--- .../includes/WatchedItemStoreUnitTest.php | 58 ++++++++-------- tests/phpunit/includes/api/ApiPageSetTest.php | 2 +- .../api/ApiQueryWatchlistIntegrationTest.php | 2 +- .../includes/api/RandomImageGenerator.php | 2 +- .../includes/config/ConfigFactoryTest.php | 2 +- .../includes/content/ContentHandlerTest.php | 4 +- tests/phpunit/includes/jobqueue/JobTest.php | 2 +- .../includes/libs/DeferredStringifierTest.php | 6 +- .../includes/libs/ObjectFactoryTest.php | 12 ++-- .../includes/libs/XmlTypeCheckTest.php | 2 +- .../libs/objectcache/WANObjectCacheTest.php | 10 +-- .../resourceloader/ResourceLoaderTest.php | 2 +- .../search/SearchEnginePrefixTest.php | 6 +- .../search/SearchSuggestionSetTest.php | 4 +- .../includes/site/CachingSiteStoreTest.php | 2 +- .../includes/specials/SpecialSearchTest.php | 2 +- .../includes/utils/BatchRowUpdateTest.php | 6 +- 77 files changed, 216 insertions(+), 222 deletions(-) diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php index b63c769b08..6161ee7355 100644 --- a/includes/MediaWikiServices.php +++ b/includes/MediaWikiServices.php @@ -377,7 +377,7 @@ class MediaWikiServices extends ServiceContainer { parent::__construct(); // Register the given Config object as the bootstrap config service. - $this->defineService( 'BootstrapConfig', function() use ( $config ) { + $this->defineService( 'BootstrapConfig', function () use ( $config ) { return $config; } ); } diff --git a/includes/PageProps.php b/includes/PageProps.php index 382d089c5b..dac756ed75 100644 --- a/includes/PageProps.php +++ b/includes/PageProps.php @@ -55,7 +55,7 @@ class PageProps { } $previousValue = self::$instance; self::$instance = $store; - return new ScopedCallback( function() use ( $previousValue ) { + return new ScopedCallback( function () use ( $previousValue ) { self::$instance = $previousValue; } ); } diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 6afabedde1..2dfcc42b26 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -43,7 +43,7 @@ use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; return [ - 'DBLoadBalancerFactory' => function( MediaWikiServices $services ) { + 'DBLoadBalancerFactory' => function ( MediaWikiServices $services ) { $mainConfig = $services->getMainConfig(); $lbConf = MWLBFactory::applyDefaultConfig( @@ -56,12 +56,12 @@ return [ return new $class( $lbConf ); }, - 'DBLoadBalancer' => function( MediaWikiServices $services ) { + 'DBLoadBalancer' => function ( MediaWikiServices $services ) { // just return the default LB from the DBLoadBalancerFactory service return $services->getDBLoadBalancerFactory()->getMainLB(); }, - 'SiteStore' => function( MediaWikiServices $services ) { + 'SiteStore' => function ( MediaWikiServices $services ) { $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() ); // TODO: replace wfGetCache with a CacheFactory service. @@ -71,7 +71,7 @@ return [ return new CachingSiteStore( $rawSiteStore, $cache ); }, - 'SiteLookup' => function( MediaWikiServices $services ) { + 'SiteLookup' => function ( MediaWikiServices $services ) { $cacheFile = $services->getMainConfig()->get( 'SitesCacheFile' ); if ( $cacheFile !== false ) { @@ -82,7 +82,7 @@ return [ } }, - 'ConfigFactory' => function( MediaWikiServices $services ) { + 'ConfigFactory' => function ( MediaWikiServices $services ) { // Use the bootstrap config to initialize the ConfigFactory. $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' ); $factory = new ConfigFactory(); @@ -93,12 +93,12 @@ return [ return $factory; }, - 'MainConfig' => function( MediaWikiServices $services ) { + 'MainConfig' => function ( MediaWikiServices $services ) { // Use the 'main' config from the ConfigFactory service. return $services->getConfigFactory()->makeConfig( 'main' ); }, - 'InterwikiLookup' => function( MediaWikiServices $services ) { + 'InterwikiLookup' => function ( MediaWikiServices $services ) { global $wgContLang; // TODO: manage $wgContLang as a service $config = $services->getMainConfig(); return new ClassicInterwikiLookup( @@ -111,26 +111,26 @@ return [ ); }, - 'StatsdDataFactory' => function( MediaWikiServices $services ) { + 'StatsdDataFactory' => function ( MediaWikiServices $services ) { return new BufferingStatsdDataFactory( rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' ) ); }, - 'EventRelayerGroup' => function( MediaWikiServices $services ) { + 'EventRelayerGroup' => function ( MediaWikiServices $services ) { return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) ); }, - 'SearchEngineFactory' => function( MediaWikiServices $services ) { + 'SearchEngineFactory' => function ( MediaWikiServices $services ) { return new SearchEngineFactory( $services->getSearchEngineConfig() ); }, - 'SearchEngineConfig' => function( MediaWikiServices $services ) { + 'SearchEngineConfig' => function ( MediaWikiServices $services ) { global $wgContLang; return new SearchEngineConfig( $services->getMainConfig(), $wgContLang ); }, - 'SkinFactory' => function( MediaWikiServices $services ) { + 'SkinFactory' => function ( MediaWikiServices $services ) { $factory = new SkinFactory(); $names = $services->getMainConfig()->get( 'ValidSkinNames' ); @@ -153,7 +153,7 @@ return [ return $factory; }, - 'WatchedItemStore' => function( MediaWikiServices $services ) { + 'WatchedItemStore' => function ( MediaWikiServices $services ) { $store = new WatchedItemStore( $services->getDBLoadBalancer(), new HashBagOStuff( [ 'maxKeys' => 100 ] ), @@ -163,11 +163,11 @@ return [ return $store; }, - 'WatchedItemQueryService' => function( MediaWikiServices $services ) { + 'WatchedItemQueryService' => function ( MediaWikiServices $services ) { return new WatchedItemQueryService( $services->getDBLoadBalancer() ); }, - 'CryptRand' => function( MediaWikiServices $services ) { + 'CryptRand' => function ( MediaWikiServices $services ) { $secretKey = $services->getMainConfig()->get( 'SecretKey' ); return new CryptRand( [ @@ -178,7 +178,7 @@ return [ // for a little more variance 'wfWikiID', // If we have a secret key set then throw it into the state as well - function() use ( $secretKey ) { + function () use ( $secretKey ) { return $secretKey ?: ''; } ], @@ -192,7 +192,7 @@ return [ ); }, - 'CryptHKDF' => function( MediaWikiServices $services ) { + 'CryptHKDF' => function ( MediaWikiServices $services ) { $config = $services->getMainConfig(); $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' ); @@ -215,13 +215,13 @@ return [ ); }, - 'MediaHandlerFactory' => function( MediaWikiServices $services ) { + 'MediaHandlerFactory' => function ( MediaWikiServices $services ) { return new MediaHandlerFactory( $services->getMainConfig()->get( 'MediaHandlers' ) ); }, - 'MimeAnalyzer' => function( MediaWikiServices $services ) { + 'MimeAnalyzer' => function ( MediaWikiServices $services ) { $logger = LoggerFactory::getInstance( 'Mime' ); $mainConfig = $services->getMainConfig(); $params = [ @@ -274,7 +274,7 @@ return [ return new MimeMagic( $params ); }, - 'ProxyLookup' => function( MediaWikiServices $services ) { + 'ProxyLookup' => function ( MediaWikiServices $services ) { $mainConfig = $services->getMainConfig(); return new ProxyLookup( $mainConfig->get( 'SquidServers' ), @@ -282,26 +282,26 @@ return [ ); }, - 'Parser' => function( MediaWikiServices $services ) { + 'Parser' => function ( MediaWikiServices $services ) { $conf = $services->getMainConfig()->get( 'ParserConf' ); return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] ); }, - 'LinkCache' => function( MediaWikiServices $services ) { + 'LinkCache' => function ( MediaWikiServices $services ) { return new LinkCache( $services->getTitleFormatter(), $services->getMainWANObjectCache() ); }, - 'LinkRendererFactory' => function( MediaWikiServices $services ) { + 'LinkRendererFactory' => function ( MediaWikiServices $services ) { return new LinkRendererFactory( $services->getTitleFormatter(), $services->getLinkCache() ); }, - 'LinkRenderer' => function( MediaWikiServices $services ) { + 'LinkRenderer' => function ( MediaWikiServices $services ) { global $wgUser; if ( defined( 'MW_NO_SESSION' ) ) { @@ -311,11 +311,11 @@ return [ } }, - 'GenderCache' => function( MediaWikiServices $services ) { + 'GenderCache' => function ( MediaWikiServices $services ) { return new GenderCache(); }, - '_MediaWikiTitleCodec' => function( MediaWikiServices $services ) { + '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) { global $wgContLang; return new MediaWikiTitleCodec( @@ -325,15 +325,15 @@ return [ ); }, - 'TitleFormatter' => function( MediaWikiServices $services ) { + 'TitleFormatter' => function ( MediaWikiServices $services ) { return $services->getService( '_MediaWikiTitleCodec' ); }, - 'TitleParser' => function( MediaWikiServices $services ) { + 'TitleParser' => function ( MediaWikiServices $services ) { return $services->getService( '_MediaWikiTitleCodec' ); }, - 'MainObjectStash' => function( MediaWikiServices $services ) { + 'MainObjectStash' => function ( MediaWikiServices $services ) { $mainConfig = $services->getMainConfig(); $id = $mainConfig->get( 'MainStash' ); @@ -345,7 +345,7 @@ return [ return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] ); }, - 'MainWANObjectCache' => function( MediaWikiServices $services ) { + 'MainWANObjectCache' => function ( MediaWikiServices $services ) { $mainConfig = $services->getMainConfig(); $id = $mainConfig->get( 'MainWANCache' ); @@ -365,7 +365,7 @@ return [ return \ObjectCache::newWANCacheFromParams( $params ); }, - 'LocalServerObjectCache' => function( MediaWikiServices $services ) { + 'LocalServerObjectCache' => function ( MediaWikiServices $services ) { $mainConfig = $services->getMainConfig(); if ( function_exists( 'apc_fetch' ) ) { @@ -388,7 +388,7 @@ return [ return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] ); }, - 'VirtualRESTServiceClient' => function( MediaWikiServices $services ) { + 'VirtualRESTServiceClient' => function ( MediaWikiServices $services ) { $config = $services->getMainConfig()->get( 'VirtualRestConfig' ); $vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) ); @@ -406,11 +406,11 @@ return [ return $vrsClient; }, - 'ConfiguredReadOnlyMode' => function( MediaWikiServices $services ) { + 'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) { return new ConfiguredReadOnlyMode( $services->getMainConfig() ); }, - 'ReadOnlyMode' => function( MediaWikiServices $services ) { + 'ReadOnlyMode' => function ( MediaWikiServices $services ) { return new ReadOnlyMode( $services->getConfiguredReadOnlyMode(), $services->getDBLoadBalancer() diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php index 22d5439c06..1fafb24dbe 100644 --- a/includes/WatchedItemQueryService.php +++ b/includes/WatchedItemQueryService.php @@ -313,7 +313,7 @@ class WatchedItemQueryService { $allFields = get_object_vars( $row ); $rcKeys = array_filter( array_keys( $allFields ), - function( $key ) { + function ( $key ) { return substr( $key, 0, 3 ) === 'rc_'; } ); diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 06f93c6b99..69a9df2d57 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -104,7 +104,7 @@ class WatchedItemStore implements StatsdAwareInterface { } $previousValue = $this->deferredUpdatesAddCallableUpdateCallback; $this->deferredUpdatesAddCallableUpdateCallback = $callback; - return new ScopedCallback( function() use ( $previousValue ) { + return new ScopedCallback( function () use ( $previousValue ) { $this->deferredUpdatesAddCallableUpdateCallback = $previousValue; } ); } @@ -127,7 +127,7 @@ class WatchedItemStore implements StatsdAwareInterface { } $previousValue = $this->revisionGetTimestampFromIdCallback; $this->revisionGetTimestampFromIdCallback = $callback; - return new ScopedCallback( function() use ( $previousValue ) { + return new ScopedCallback( function () use ( $previousValue ) { $this->revisionGetTimestampFromIdCallback = $previousValue; } ); } @@ -821,7 +821,7 @@ class WatchedItemStore implements StatsdAwareInterface { // Calls DeferredUpdates::addCallableUpdate in normal operation call_user_func( $this->deferredUpdatesAddCallableUpdateCallback, - function() use ( $job ) { + function () use ( $job ) { $job->run(); } ); diff --git a/includes/Xml.php b/includes/Xml.php index 8289b818c1..d0164331e1 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -826,4 +826,3 @@ class Xml { return $s; } } - diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index c2cdfe4adc..6b8f98c7b9 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -766,7 +766,7 @@ class ApiQueryInfo extends ApiQueryBase { if ( $this->fld_watched ) { foreach ( $timestamps as $namespaceId => $dbKeys ) { $this->watched[$namespaceId] = array_map( - function( $x ) { + function ( $x ) { return $x !== false; }, $dbKeys @@ -847,7 +847,7 @@ class ApiQueryInfo extends ApiQueryBase { $timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age; } $titlesWithThresholds = array_map( - function( LinkTarget $target ) use ( $timestamps ) { + function ( LinkTarget $target ) use ( $timestamps ) { return [ $target, $timestamps[$target->getNamespace()][$target->getDBkey()] ]; @@ -860,7 +860,7 @@ class ApiQueryInfo extends ApiQueryBase { $titlesWithThresholds = array_merge( $titlesWithThresholds, array_map( - function( LinkTarget $target ) { + function ( LinkTarget $target ) { return [ $target, null ]; }, $this->missing diff --git a/includes/api/ApiQueryPrefixSearch.php b/includes/api/ApiQueryPrefixSearch.php index 5606f3c922..2fbc518b1e 100644 --- a/includes/api/ApiQueryPrefixSearch.php +++ b/includes/api/ApiQueryPrefixSearch.php @@ -54,7 +54,7 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase { $titles = $searchEngine->extractTitles( $searchEngine->completionSearchWithVariants( $search ) ); if ( $resultPageSet ) { - $resultPageSet->setRedirectMergePolicy( function( array $current, array $new ) { + $resultPageSet->setRedirectMergePolicy( function ( array $current, array $new ) { if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) { $current['index'] = $new['index']; } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index a5d06c824c..5b094cd908 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -214,7 +214,7 @@ class ApiQueryUsers extends ApiQueryBase { } if ( isset( $this->prop['groupmemberships'] ) ) { - $data[$key]['groupmemberships'] = array_map( function( $ugm ) { + $data[$key]['groupmemberships'] = array_map( function ( $ugm ) { return [ 'group' => $ugm->getGroup(), 'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ), diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index cbbbfebc85..64d4aa79e4 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -685,7 +685,7 @@ class EnhancedChangesList extends ChangesList { } $attribs = $data['attribs']; unset( $data['attribs'] ); - $attribs = wfArrayFilterByKey( $attribs, function( $key ) { + $attribs = wfArrayFilterByKey( $attribs, function ( $key ) { return $key === 'class' || Sanitizer::isReservedDataAttribute( $key ); } ); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index b0ab24488f..0b58cc1bc6 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -847,7 +847,7 @@ class DifferenceEngine extends ContextSource { * @return bool|string */ public function generateTextDiffBody( $otext, $ntext ) { - $diff = function() use ( $otext, $ntext ) { + $diff = function () use ( $otext, $ntext ) { $time = microtime( true ); $result = $this->textDiff( $otext, $ntext ); @@ -867,7 +867,7 @@ class DifferenceEngine extends ContextSource { * @param Status $status * @throws FatalError */ - $error = function( $status ) { + $error = function ( $status ) { throw new FatalError( $status->getWikiText() ); }; diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index f83fd1c813..bcd253fb4a 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -73,7 +73,7 @@ class ForeignDBViaLBRepo extends LocalRepo { * @return Closure */ protected function getDBFactory() { - return function( $index ) { + return function ( $index ) { return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki ); }; } diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index d91ab24e9c..20d51c254a 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -483,7 +483,7 @@ class LocalRepo extends FileRepo { * @return Closure */ protected function getDBFactory() { - return function( $index ) { + return function ( $index ) { return wfGetDB( $index ); }; } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index e1c2546d6b..a4122503a7 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -593,7 +593,7 @@ class LocalFile extends File { if ( $upgrade ) { $this->upgrading = true; // Defer updates unless in auto-commit CLI mode - DeferredUpdates::addCallableUpdate( function() { + DeferredUpdates::addCallableUpdate( function () { $this->upgrading = false; // avoid duplicate updates try { $this->upgradeRow(); diff --git a/includes/htmlform/HTMLFormElement.php b/includes/htmlform/HTMLFormElement.php index 089213cff5..10db90cca2 100644 --- a/includes/htmlform/HTMLFormElement.php +++ b/includes/htmlform/HTMLFormElement.php @@ -26,7 +26,7 @@ trait HTMLFormElement { // And it's not needed anymore after infusing, so we don't put it in JS config at all. $this->setAttributes( [ 'data-mw-modules' => implode( ',', $this->modules ) ] ); } - $this->registerConfigCallback( function( &$config ) { + $this->registerConfigCallback( function ( &$config ) { if ( $this->hideIf !== null ) { $config['hideIf'] = $this->hideIf; } diff --git a/includes/htmlform/fields/HTMLUsersMultiselectField.php b/includes/htmlform/fields/HTMLUsersMultiselectField.php index 8829f66877..53d1d06b23 100644 --- a/includes/htmlform/fields/HTMLUsersMultiselectField.php +++ b/includes/htmlform/fields/HTMLUsersMultiselectField.php @@ -23,7 +23,7 @@ class HTMLUsersMultiselectField extends HTMLUserTextField { $usersArray = explode( "\n", $request->getText( $this->mName ) ); // Remove empty lines - $usersArray = array_values( array_filter( $usersArray, function( $username ) { + $usersArray = array_values( array_filter( $usersArray, function ( $username ) { return trim( $username ) !== ''; } ) ); return $usersArray; diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 61135736bd..6c56b3d430 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -336,7 +336,7 @@ abstract class DatabaseInstaller { $services = \MediaWiki\MediaWikiServices::getInstance(); $connection = $status->value; - $services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) { + $services->redefineService( 'DBLoadBalancerFactory', function () use ( $connection ) { return LBFactorySingle::newFromConnection( $connection ); } ); } diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 70282248fb..168d7edbe1 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -384,7 +384,7 @@ abstract class Installer { // make sure we use the installer config as the main config $configRegistry = $baseConfig->get( 'ConfigRegistry' ); - $configRegistry['main'] = function() use ( $installerConfig ) { + $configRegistry['main'] = function () use ( $installerConfig ) { return $installerConfig; }; diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index c504f3531c..ea0f1b7c74 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -356,7 +356,7 @@ class CSSMin { // Re-insert comments $pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/'; - $source = preg_replace_callback( $pattern, function( $match ) use ( &$comments ) { + $source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) { return $comments[ $match[1] ]; }, $source ); diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php index 4ddb8131d5..21d79dce2c 100644 --- a/includes/libs/HashRing.php +++ b/includes/libs/HashRing.php @@ -179,7 +179,7 @@ class HashRing { if ( $this->liveRing === null || $this->ejectionNextExpiry <= $now ) { $this->ejectionExpiries = array_filter( $this->ejectionExpiries, - function( $expiry ) use ( $now ) { + function ( $expiry ) use ( $now ) { return ( $expiry > $now ); } ); diff --git a/includes/libs/filebackend/FileBackendMultiWrite.php b/includes/libs/filebackend/FileBackendMultiWrite.php index 53bce33dad..e374532044 100644 --- a/includes/libs/filebackend/FileBackendMultiWrite.php +++ b/includes/libs/filebackend/FileBackendMultiWrite.php @@ -196,7 +196,7 @@ class FileBackendMultiWrite extends FileBackend { if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) { // Bind $scopeLock to the callback to preserve locks DeferredUpdates::addCallableUpdate( - function() use ( $backend, $realOps, $opts, $scopeLock, $relevantPaths ) { + function () use ( $backend, $realOps, $opts, $scopeLock, $relevantPaths ) { wfDebugLog( 'FileOperationReplication', "'{$backend->getName()}' async replication; paths: " . FormatJson::encode( $relevantPaths ) ); @@ -508,7 +508,7 @@ class FileBackendMultiWrite extends FileBackend { $realOps = $this->substOpBatchPaths( $ops, $backend ); if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) { DeferredUpdates::addCallableUpdate( - function() use ( $backend, $realOps ) { + function () use ( $backend, $realOps ) { $backend->doQuickOperations( $realOps ); } ); @@ -562,7 +562,7 @@ class FileBackendMultiWrite extends FileBackend { $realParams = $this->substOpPaths( $params, $backend ); if ( $this->asyncWrites ) { DeferredUpdates::addCallableUpdate( - function() use ( $backend, $method, $realParams ) { + function () use ( $backend, $method, $realParams ) { $backend->$method( $realParams ); } ); diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 77c4259a0d..7cd678b035 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -475,7 +475,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { $lSince = microtime( true ); // lock timestamp - return new ScopedCallback( function() use ( $key, $lSince, $expiry ) { + return new ScopedCallback( function () use ( $key, $lSince, $expiry ) { $latency = .050; // latency skew (err towards keeping lock present) $age = ( microtime( true ) - $lSince + $latency ); if ( ( $age + $latency ) >= $expiry ) { diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index 60b685562e..9242414dfe 100644 --- a/includes/libs/rdbms/database/DatabaseSqlite.php +++ b/includes/libs/rdbms/database/DatabaseSqlite.php @@ -1046,4 +1046,3 @@ class DatabaseSqlite extends Database { } class_alias( DatabaseSqlite::class, 'DatabaseSqlite' ); - diff --git a/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php b/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php index fd7af110e5..493cde8d9c 100644 --- a/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php +++ b/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php @@ -63,4 +63,3 @@ class FakeResultWrapper extends ResultWrapper { } class_alias( FakeResultWrapper::class, 'FakeResultWrapper' ); - diff --git a/includes/libs/rdbms/exception/DBTransactionError.php b/includes/libs/rdbms/exception/DBTransactionError.php index fd79773e47..62a078cdba 100644 --- a/includes/libs/rdbms/exception/DBTransactionError.php +++ b/includes/libs/rdbms/exception/DBTransactionError.php @@ -28,4 +28,3 @@ class DBTransactionError extends DBExpectedError { } class_alias( DBTransactionError::class, 'DBTransactionError' ); - diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php index 3567204a82..919f103be1 100644 --- a/includes/libs/rdbms/lbfactory/LBFactory.php +++ b/includes/libs/rdbms/lbfactory/LBFactory.php @@ -530,7 +530,7 @@ abstract class LBFactory implements ILBFactory { $prefix ); - $this->forEachLB( function( ILoadBalancer $lb ) use ( $prefix ) { + $this->forEachLB( function ( ILoadBalancer $lb ) use ( $prefix ) { $lb->setDomainPrefix( $prefix ); } ); } diff --git a/includes/libs/stats/SamplingStatsdClient.php b/includes/libs/stats/SamplingStatsdClient.php index a8af7142c4..526f12013d 100644 --- a/includes/libs/stats/SamplingStatsdClient.php +++ b/includes/libs/stats/SamplingStatsdClient.php @@ -55,7 +55,7 @@ class SamplingStatsdClient extends StatsdClient { $samplingRates = [ '*' => $sampleRate ]; } if ( $samplingRates ) { - array_walk( $data, function( $item ) use ( $samplingRates ) { + array_walk( $data, function ( $item ) use ( $samplingRates ) { /** @var $item StatsdData */ foreach ( $samplingRates as $pattern => $rate ) { if ( fnmatch( $pattern, $item->getKey(), FNM_NOESCAPE ) ) { diff --git a/includes/libs/virtualrest/VirtualRESTServiceClient.php b/includes/libs/virtualrest/VirtualRESTServiceClient.php index 1b7545a892..324933054a 100644 --- a/includes/libs/virtualrest/VirtualRESTServiceClient.php +++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php @@ -103,7 +103,7 @@ class VirtualRESTServiceClient { * @return array (prefix,VirtualRESTService) or (null,null) if none found */ public function getMountAndService( $path ) { - $cmpFunc = function( $a, $b ) { + $cmpFunc = function ( $a, $b ) { $al = substr_count( $a, '/' ); $bl = substr_count( $b, '/' ); if ( $al === $bl ) { @@ -207,7 +207,7 @@ class VirtualRESTServiceClient { } // Function to get IDs that won't collide with keys in $armoredIndexMap - $idFunc = function() use ( &$curUniqueId ) { + $idFunc = function () use ( &$curUniqueId ) { return $curUniqueId++; }; diff --git a/includes/linkeddata/PageDataRequestHandler.php b/includes/linkeddata/PageDataRequestHandler.php index d26b304d4d..43cb44c854 100644 --- a/includes/linkeddata/PageDataRequestHandler.php +++ b/includes/linkeddata/PageDataRequestHandler.php @@ -38,7 +38,7 @@ class PageDataRequestHandler { $parts = explode( '/', $subPage, 2 ); if ( $parts !== 2 ) { $slot = $parts[0]; - if ( $slot === 'main' or $slot === '' ) { + if ( $slot === 'main' || $slot === '' ) { return true; } } diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php index 791330c160..4b4d19f4fb 100644 --- a/includes/logging/RightsLogFormatter.php +++ b/includes/logging/RightsLogFormatter.php @@ -176,7 +176,7 @@ class RightsLogFormatter extends LogFormatter { $oldmetadata =& $params['oldmetadata']; // unset old metadata entry to ensure metadata goes at the end of the params array unset( $params['oldmetadata'] ); - $params['oldmetadata'] = array_map( function( $index ) use ( $params, $oldmetadata ) { + $params['oldmetadata'] = array_map( function ( $index ) use ( $params, $oldmetadata ) { $result = [ 'group' => $params['4:array:oldgroups'][$index] ]; if ( isset( $oldmetadata[$index] ) ) { $result += $oldmetadata[$index]; @@ -194,7 +194,7 @@ class RightsLogFormatter extends LogFormatter { $newmetadata =& $params['newmetadata']; // unset old metadata entry to ensure metadata goes at the end of the params array unset( $params['newmetadata'] ); - $params['newmetadata'] = array_map( function( $index ) use ( $params, $newmetadata ) { + $params['newmetadata'] = array_map( function ( $index ) use ( $params, $newmetadata ) { $result = [ 'group' => $params['5:array:newgroups'][$index] ]; if ( isset( $newmetadata[$index] ) ) { $result += $newmetadata[$index]; diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 0e23a88c1d..5c7c7fef3b 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3334,7 +3334,7 @@ class WikiPage implements Page, IDBAccessObject { HTMLFileCache::clearFileCache( $title ); $revid = $revision ? $revision->getId() : null; - DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) { + DeferredUpdates::addCallableUpdate( function () use ( $title, $revid ) { InfoAction::invalidateCache( $title, $revid ); } ); } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index c83198fdad..b0d0e5c8eb 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -6070,7 +6070,7 @@ class Parser { $e = new Exception; $this->mInParse = $e->getTraceAsString(); - $recursiveCheck = new ScopedCallback( function() { + $recursiveCheck = new ScopedCallback( function () { $this->mInParse = false; } ); diff --git a/includes/profiler/ProfilerSectionOnly.php b/includes/profiler/ProfilerSectionOnly.php index 0ce8087675..251da52b35 100644 --- a/includes/profiler/ProfilerSectionOnly.php +++ b/includes/profiler/ProfilerSectionOnly.php @@ -73,7 +73,7 @@ class ProfilerSectionOnly extends Profiler { */ protected function getFunctionReport() { $data = $this->getFunctionStats(); - usort( $data, function( $a, $b ) { + usort( $data, function ( $a, $b ) { if ( $a['real'] === $b['real'] ) { return 0; } diff --git a/includes/profiler/ProfilerXhprof.php b/includes/profiler/ProfilerXhprof.php index 1bf4f54583..833bbf0db9 100644 --- a/includes/profiler/ProfilerXhprof.php +++ b/includes/profiler/ProfilerXhprof.php @@ -201,7 +201,7 @@ class ProfilerXhprof extends Profiler { */ protected function getFunctionReport() { $data = $this->getFunctionStats(); - usort( $data, function( $a, $b ) { + usort( $data, function ( $a, $b ) { if ( $a['real'] === $b['real'] ) { return 0; } diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 39a8a3dec1..ce262bd23e 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -378,7 +378,7 @@ class ExtensionProcessor implements Processor { protected function extractExtensionMessagesFiles( $dir, array $info ) { if ( isset( $info['ExtensionMessagesFiles'] ) ) { - $this->globals["wgExtensionMessagesFiles"] += array_map( function( $file ) use ( $dir ) { + $this->globals["wgExtensionMessagesFiles"] += array_map( function ( $file ) use ( $dir ) { return "$dir/$file"; }, $info['ExtensionMessagesFiles'] ); } diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 0c5a67e9a7..eac04a9b89 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -400,7 +400,7 @@ class ExtensionRegistry { protected function processAutoLoader( $dir, array $info ) { if ( isset( $info['AutoloadClasses'] ) ) { // Make paths absolute, relative to the JSON file - return array_map( function( $file ) use ( $dir ) { + return array_map( function ( $file ) use ( $dir ) { return "$dir/$file"; }, $info['AutoloadClasses'] ); } else { diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 4473bb2927..ac95e7c706 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -236,7 +236,7 @@ abstract class SearchEngine { if ( $namespaces ) { // Filter namespaces to only keep valid ones $validNs = $this->searchableNamespaces(); - $namespaces = array_filter( $namespaces, function( $ns ) use( $validNs ) { + $namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) { return $ns < 0 || isset( $validNs[$ns] ); } ); } else { @@ -464,7 +464,7 @@ abstract class SearchEngine { } } - $ns = array_map( function( $space ) { + $ns = array_map( function ( $space ) { return $space == NS_MEDIA ? NS_FILE : $space; }, $ns ); @@ -550,7 +550,7 @@ abstract class SearchEngine { * @return Title[] */ public function extractTitles( SearchSuggestionSet $completionResults ) { - return $completionResults->map( function( SearchSuggestion $sugg ) { + return $completionResults->map( function ( SearchSuggestion $sugg ) { return $sugg->getSuggestedTitle(); } ); } @@ -564,14 +564,14 @@ abstract class SearchEngine { protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) { $search = trim( $search ); // preload the titles with LinkBatch - $titles = $suggestions->map( function( SearchSuggestion $sugg ) { + $titles = $suggestions->map( function ( SearchSuggestion $sugg ) { return $sugg->getSuggestedTitle(); } ); $lb = new LinkBatch( $titles ); $lb->setCaller( __METHOD__ ); $lb->execute(); - $results = $suggestions->map( function( SearchSuggestion $sugg ) { + $results = $suggestions->map( function ( SearchSuggestion $sugg ) { return $sugg->getSuggestedTitle()->getPrefixedText(); } ); diff --git a/includes/search/SearchSuggestionSet.php b/includes/search/SearchSuggestionSet.php index caad38852e..6d54dada4e 100644 --- a/includes/search/SearchSuggestionSet.php +++ b/includes/search/SearchSuggestionSet.php @@ -180,7 +180,7 @@ class SearchSuggestionSet { */ public static function fromTitles( array $titles ) { $score = count( $titles ); - $suggestions = array_map( function( $title ) use ( &$score ) { + $suggestions = array_map( function ( $title ) use ( &$score ) { return SearchSuggestion::fromTitle( $score--, $title ); }, $titles ); return new SearchSuggestionSet( $suggestions ); @@ -196,7 +196,7 @@ class SearchSuggestionSet { */ public static function fromStrings( array $titles ) { $score = count( $titles ); - $suggestions = array_map( function( $title ) use ( &$score ) { + $suggestions = array_map( function ( $title ) use ( &$score ) { return SearchSuggestion::fromText( $score--, $title ); }, $titles ); return new SearchSuggestionSet( $suggestions ); diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php index 9594952d02..67c14d81e2 100644 --- a/includes/specialpage/SpecialPage.php +++ b/includes/specialpage/SpecialPage.php @@ -456,7 +456,7 @@ class SpecialPage implements MessageLocalizer { $searchEngine->setLimitOffset( $limit, $offset ); $searchEngine->setNamespaces( [] ); $result = $searchEngine->defaultPrefixSearch( $search ); - return array_map( function( Title $t ) { + return array_map( function ( Title $t ) { return $t->getPrefixedText(); }, $result ); } diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php index 1dd78d7cfc..dfdbb067c0 100644 --- a/includes/specials/SpecialBotPasswords.php +++ b/includes/specials/SpecialBotPasswords.php @@ -123,7 +123,7 @@ class SpecialBotPasswords extends FormSpecialPage { $showGrants ), 'default' => array_map( - function( $g ) { + function ( $g ) { return "grant-$g"; }, $this->botPassword->getGrants() @@ -131,14 +131,14 @@ class SpecialBotPasswords extends FormSpecialPage { 'tooltips' => array_combine( array_map( 'MWGrants::getGrantsLink', $showGrants ), array_map( - function( $rights ) use ( $lang ) { + function ( $rights ) use ( $lang ) { return $lang->semicolonList( array_map( 'User::getRightDescription', $rights ) ); }, array_intersect_key( MWGrants::getRightsByGrant(), array_flip( $showGrants ) ) ) ), 'force-options-on' => array_map( - function( $g ) { + function ( $g ) { return "grant-$g"; }, MWGrants::getHiddenGrants() diff --git a/includes/specials/SpecialChangeContentModel.php b/includes/specials/SpecialChangeContentModel.php index 8eaae4ca0f..bee6a39832 100644 --- a/includes/specials/SpecialChangeContentModel.php +++ b/includes/specials/SpecialChangeContentModel.php @@ -115,7 +115,7 @@ class SpecialChangeContentModel extends FormSpecialPage { 'reason' => [ 'type' => 'text', 'name' => 'reason', - 'validation-callback' => function( $reason ) { + 'validation-callback' => function ( $reason ) { $match = EditPage::matchSummarySpamRegex( $reason ); if ( $match ) { return $this->msg( 'spamprotectionmatch', $match )->parse(); diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index a2b5be4354..46d7cf7a87 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -105,7 +105,7 @@ class MovePageForm extends UnlistedSpecialPage { $permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user ); if ( count( $permErrors ) ) { // Auto-block user's IP if the account was "hard" blocked - DeferredUpdates::addCallableUpdate( function() use ( $user ) { + DeferredUpdates::addCallableUpdate( function () use ( $user ) { $user->spreadAnyEditBlock(); } ); throw new PermissionsError( 'move', $permErrors ); diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 002b47cf7e..d0a0317fa8 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -344,7 +344,7 @@ class UserrightsPage extends SpecialPage { // UNLESS the user can only add this group (not remove it) and the expiry time // is being brought forward (T156784) $add = array_filter( $add, - function( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) { + function ( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) { if ( isset( $groupExpiries[$group] ) && !in_array( $group, $removable ) && isset( $ugms[$group] ) && @@ -437,12 +437,12 @@ class UserrightsPage extends SpecialPage { // make sure $oldUGMs and $newUGMs are in the same order, and serialise // each UGM object to a simplified array - $oldUGMs = array_map( function( $group ) use ( $oldUGMs ) { + $oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) { return isset( $oldUGMs[$group] ) ? self::serialiseUgmForLog( $oldUGMs[$group] ) : null; }, $oldGroups ); - $newUGMs = array_map( function( $group ) use ( $newUGMs ) { + $newUGMs = array_map( function ( $group ) use ( $newUGMs ) { return isset( $newUGMs[$group] ) ? self::serialiseUgmForLog( $newUGMs[$group] ) : null; diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index caa0e1fe8b..30c4a0be8f 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -511,7 +511,7 @@ class SpecialVersion extends SpecialPage { // in their proper section continue; } - $authors = array_map( function( $arr ) { + $authors = array_map( function ( $arr ) { // If a homepage is set, link to it if ( isset( $arr['homepage'] ) ) { return "[{$arr['homepage']} {$arr['name']}]"; diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index 3467b49cae..b0c12e4c20 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -1891,7 +1891,7 @@ class Balancer { $bad = array_uintersect_assoc( $this->allowedHtmlElements, BalanceSets::$unsupportedSet[BalanceSets::HTML_NAMESPACE], - function( $a, $b ) { + function ( $a, $b ) { // Ignore the values (just intersect the keys) by saying // all values are equal to each other. return 0; diff --git a/includes/user/User.php b/includes/user/User.php index 4d16594dd5..52c14f7c54 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -2506,7 +2506,7 @@ class User implements IDBAccessObject { $cache->delete( $key, 1 ); } else { wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle( - function() use ( $cache, $key ) { + function () use ( $cache, $key ) { $cache->delete( $key ); }, __METHOD__ @@ -3698,7 +3698,7 @@ class User implements IDBAccessObject { } // Try to update the DB post-send and only if needed... - DeferredUpdates::addCallableUpdate( function() use ( $title, $oldid ) { + DeferredUpdates::addCallableUpdate( function () use ( $title, $oldid ) { if ( !$this->getNewtalk() ) { return; // no notifications to clear } diff --git a/includes/utils/BatchRowUpdate.php b/includes/utils/BatchRowUpdate.php index 39b65c3fb3..fc8bde9ae6 100644 --- a/includes/utils/BatchRowUpdate.php +++ b/includes/utils/BatchRowUpdate.php @@ -77,7 +77,7 @@ class BatchRowUpdate { $this->reader = $reader; $this->writer = $writer; $this->generator = $generator; - $this->output = function() { + $this->output = function () { }; // nop } diff --git a/includes/utils/ZipDirectoryReader.php b/includes/utils/ZipDirectoryReader.php index dd67fa8c4b..f0ace2ccb3 100644 --- a/includes/utils/ZipDirectoryReader.php +++ b/includes/utils/ZipDirectoryReader.php @@ -715,4 +715,3 @@ class ZipDirectoryReader { } } } - diff --git a/maintenance/CodeCleanerGlobalsPass.inc b/maintenance/CodeCleanerGlobalsPass.inc index 5e8e754796..9ccf6d63b1 100644 --- a/maintenance/CodeCleanerGlobalsPass.inc +++ b/maintenance/CodeCleanerGlobalsPass.inc @@ -49,4 +49,3 @@ class CodeCleanerGlobalsPass extends \Psy\CodeCleaner\CodeCleanerPass { return $nodes; } } - diff --git a/maintenance/validateRegistrationFile.php b/maintenance/validateRegistrationFile.php index 9906990bb5..aa1f668d3b 100644 --- a/maintenance/validateRegistrationFile.php +++ b/maintenance/validateRegistrationFile.php @@ -8,7 +8,7 @@ class ValidateRegistrationFile extends Maintenance { $this->addArg( 'path', 'Path to extension.json/skin.json file.', true ); } public function execute() { - $validator = new ExtensionJsonValidator( function( $msg ) { + $validator = new ExtensionJsonValidator( function ( $msg ) { $this->error( $msg, 1 ); } ); $validator->checkDependencies(); diff --git a/phpcs.xml b/phpcs.xml index 440604ea1e..197cc7860b 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -38,7 +38,7 @@ . - + */languages/messages/Messages*.php diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index f44b0d5e26..3ae3561e68 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -240,7 +240,7 @@ class ParserTestRunner { 'name' => 'nullLockManager', 'class' => 'NullLockManager', ] ]; - $reset = function() { + $reset = function () { LockManagerGroup::destroySingletons(); }; $setup[] = $reset; @@ -288,7 +288,7 @@ class ParserTestRunner { MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' ); MediaWikiServices::getInstance()->redefineService( 'MediaHandlerFactory', - function() { + function () { return new MockMediaHandlerFactory(); } ); @@ -428,7 +428,7 @@ class ParserTestRunner { * @return ScopedCallback */ protected function createTeardownObject( $teardown, $nextTeardown = null ) { - return new ScopedCallback( function() use ( $teardown, $nextTeardown ) { + return new ScopedCallback( function () use ( $teardown, $nextTeardown ) { // Schedule teardown snippets in reverse order $teardown = array_reverse( $teardown ); diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index df3d5681d7..c1ada45af9 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -309,7 +309,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { ConfigFactory $oldFactory, array $configurations ) { - return function( MediaWikiServices $services ) use ( $oldFactory, $configurations ) { + return function ( MediaWikiServices $services ) use ( $oldFactory, $configurations ) { $factory = new ConfigFactory(); // clone configurations from $oldFactory that are not overwritten by $configurations diff --git a/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php b/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php index afd80ff7a2..388aee79d1 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php +++ b/tests/phpunit/includes/GlobalFunctions/wfArrayFilterTest.php @@ -3,19 +3,19 @@ class WfArrayFilterTest extends \PHPUnit_Framework_TestCase { public function testWfArrayFilter() { $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilter( $arr, function( $val, $key ) { + $filtered = wfArrayFilter( $arr, function ( $val, $key ) { return $key !== 'b'; } ); $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilter( $arr, function( $val, $key ) { + $filtered = wfArrayFilter( $arr, function ( $val, $key ) { return $val !== 2; } ); $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); $arr = [ 'a', 'b', 'c' ]; - $filtered = wfArrayFilter( $arr, function( $val, $key ) { + $filtered = wfArrayFilter( $arr, function ( $val, $key ) { return $key !== 0; } ); $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered ); @@ -23,13 +23,13 @@ class WfArrayFilterTest extends \PHPUnit_Framework_TestCase { public function testWfArrayFilterByKey() { $arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ]; - $filtered = wfArrayFilterByKey( $arr, function( $key ) { + $filtered = wfArrayFilterByKey( $arr, function ( $key ) { return $key !== 'b'; } ); $this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered ); $arr = [ 'a', 'b', 'c' ]; - $filtered = wfArrayFilterByKey( $arr, function( $key ) { + $filtered = wfArrayFilterByKey( $arr, function ( $key ) { return $key !== 0; } ); $this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered ); diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 3edf99f2e2..2ca5935225 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -385,21 +385,21 @@ class LinkerTest extends MediaWikiLangTestCase { return [ // Override $html [ - function( $dummy, $title, $options, &$html, &$attribs, &$ret ) { + function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) { $html = 'foobar'; }, 'foobar' ], // Modify $attribs [ - function( $dummy, $title, $options, &$html, &$attribs, &$ret ) { + function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) { $attribs['bar'] = 'baz'; }, 'Special:BlankPage' ], // Fully override return value and abort hook [ - function( $dummy, $title, $options, &$html, &$attribs, &$ret ) { + function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) { $ret = 'blahblahblah'; return false; }, diff --git a/tests/phpunit/includes/MediaWikiServicesTest.php b/tests/phpunit/includes/MediaWikiServicesTest.php index 037faa6fff..b4e9626904 100644 --- a/tests/phpunit/includes/MediaWikiServicesTest.php +++ b/tests/phpunit/includes/MediaWikiServicesTest.php @@ -77,7 +77,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $newServices->defineService( 'Test', - function() use ( $service1 ) { + function () use ( $service1 ) { return $service1; } ); @@ -121,7 +121,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $newServices->defineService( 'Test', - function() use ( &$instantiatorReturnValues ) { + function () use ( &$instantiatorReturnValues ) { return array_shift( $instantiatorReturnValues ); } ); @@ -150,7 +150,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $newServices->redefineService( 'DBLoadBalancerFactory', - function() use ( $lbFactory ) { + function () use ( $lbFactory ) { return $lbFactory; } ); @@ -194,7 +194,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $newServices->defineService( 'Test', - function() use ( &$instantiatorReturnValues ) { + function () use ( &$instantiatorReturnValues ) { return array_shift( $instantiatorReturnValues ); } ); @@ -217,7 +217,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $services->defineService( 'Test', - function() use ( &$serviceCounter ) { + function () use ( &$serviceCounter ) { $serviceCounter++; $service = $this->createMock( 'MediaWiki\Services\DestructibleService' ); $service->expects( $this->once() )->method( 'destroy' ); @@ -247,7 +247,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase { $services->defineService( 'Test', - function() { + function () { $service = $this->createMock( 'MediaWiki\Services\DestructibleService' ); $service->expects( $this->never() )->method( 'destroy' ); return $service; diff --git a/tests/phpunit/includes/Services/ServiceContainerTest.php b/tests/phpunit/includes/Services/ServiceContainerTest.php index 617e39cf9d..b68ee48b51 100644 --- a/tests/phpunit/includes/Services/ServiceContainerTest.php +++ b/tests/phpunit/includes/Services/ServiceContainerTest.php @@ -20,7 +20,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $this->assertEmpty( $names ); $name = 'TestService92834576'; - $services->defineService( $name, function() { + $services->defineService( $name, function () { return null; } ); @@ -34,7 +34,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $name = 'TestService92834576'; $this->assertFalse( $services->hasService( $name ) ); - $services->defineService( $name, function() { + $services->defineService( $name, function () { return null; } ); @@ -50,7 +50,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $services->defineService( $name, - function( $actualLocator, $extra ) use ( $services, $theService, &$count ) { + function ( $actualLocator, $extra ) use ( $services, $theService, &$count ) { $count++; PHPUnit_Framework_Assert::assertSame( $services, $actualLocator ); PHPUnit_Framework_Assert::assertSame( $extra, 'Foo' ); @@ -79,14 +79,14 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $services->defineService( 'Foo', - function() { + function () { return new stdClass(); } ); $services->defineService( 'Bar', - function() { + function () { return new stdClass(); } ); @@ -122,7 +122,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $theService = new stdClass(); $name = 'TestService92834576'; - $services->defineService( $name, function( $actualLocator ) use ( $services, $theService ) { + $services->defineService( $name, function ( $actualLocator ) use ( $services, $theService ) { PHPUnit_Framework_Assert::assertSame( $services, $actualLocator ); return $theService; } ); @@ -137,13 +137,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $theService = new stdClass(); $name = 'TestService92834576'; - $services->defineService( $name, function() use ( $theService ) { + $services->defineService( $name, function () use ( $theService ) { return $theService; } ); $this->setExpectedException( 'MediaWiki\Services\ServiceAlreadyDefinedException' ); - $services->defineService( $name, function() use ( $theService ) { + $services->defineService( $name, function () use ( $theService ) { return $theService; } ); } @@ -152,10 +152,10 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $services = $this->newServiceContainer(); $wiring = [ - 'Foo' => function() { + 'Foo' => function () { return 'Foo!'; }, - 'Bar' => function() { + 'Bar' => function () { return 'Bar!'; }, ]; @@ -170,13 +170,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $services = $this->newServiceContainer(); $wiring = [ - 'Foo' => function() { + 'Foo' => function () { return 'Foo!'; }, - 'Bar' => function() { + 'Bar' => function () { return 'Bar!'; }, - 'Car' => function() { + 'Car' => function () { return 'FUBAR!'; }, ]; @@ -187,7 +187,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { // define a service before importing, so we can later check that // existing service instances survive importWiring() - $newServices->defineService( 'Car', function() { + $newServices->defineService( 'Car', function () { return 'Car!'; } ); @@ -196,7 +196,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { // Define another service, so we can later check that extra wiring // is not lost. - $newServices->defineService( 'Xar', function() { + $newServices->defineService( 'Xar', function () { return 'Xar!'; } ); @@ -249,7 +249,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $theService1 = new stdClass(); $name = 'TestService92834576'; - $services->defineService( $name, function() { + $services->defineService( $name, function () { PHPUnit_Framework_Assert::fail( 'The original instantiator function should not get called' ); @@ -258,7 +258,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { // redefine before instantiation $services->redefineService( $name, - function( $actualLocator, $extra ) use ( $services, $theService1 ) { + function ( $actualLocator, $extra ) use ( $services, $theService1 ) { PHPUnit_Framework_Assert::assertSame( $services, $actualLocator ); PHPUnit_Framework_Assert::assertSame( 'Foo', $extra ); return $theService1; @@ -275,14 +275,14 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $theService1 = new stdClass(); $name = 'TestService92834576'; - $services->defineService( $name, function() { + $services->defineService( $name, function () { return 'Foo'; } ); // disable the service. we should be able to redefine it anyway. $services->disableService( $name ); - $services->redefineService( $name, function() use ( $theService1 ) { + $services->redefineService( $name, function () use ( $theService1 ) { return $theService1; } ); @@ -298,7 +298,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' ); - $services->redefineService( $name, function() use ( $theService ) { + $services->redefineService( $name, function () use ( $theService ) { return $theService; } ); } @@ -309,7 +309,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $theService = new stdClass(); $name = 'TestService92834576'; - $services->defineService( $name, function() { + $services->defineService( $name, function () { return 'Foo'; } ); @@ -318,7 +318,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $this->setExpectedException( 'MediaWiki\Services\CannotReplaceActiveServiceException' ); - $services->redefineService( $name, function() use ( $theService ) { + $services->redefineService( $name, function () use ( $theService ) { return $theService; } ); } @@ -331,13 +331,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $destructible->expects( $this->once() ) ->method( 'destroy' ); - $services->defineService( 'Foo', function() use ( $destructible ) { + $services->defineService( 'Foo', function () use ( $destructible ) { return $destructible; } ); - $services->defineService( 'Bar', function() { + $services->defineService( 'Bar', function () { return new stdClass(); } ); - $services->defineService( 'Qux', function() { + $services->defineService( 'Qux', function () { return new stdClass(); } ); @@ -377,7 +377,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' ); - $services->redefineService( $name, function() use ( $theService ) { + $services->redefineService( $name, function () use ( $theService ) { return $theService; } ); } @@ -390,11 +390,11 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase { $destructible->expects( $this->once() ) ->method( 'destroy' ); - $services->defineService( 'Foo', function() use ( $destructible ) { + $services->defineService( 'Foo', function () use ( $destructible ) { return $destructible; } ); - $services->defineService( 'Bar', function() { + $services->defineService( 'Bar', function () { return new stdClass(); } ); diff --git a/tests/phpunit/includes/Services/TestWiring1.php b/tests/phpunit/includes/Services/TestWiring1.php index 186021a98a..b6ff4eb3b4 100644 --- a/tests/phpunit/includes/Services/TestWiring1.php +++ b/tests/phpunit/includes/Services/TestWiring1.php @@ -4,7 +4,7 @@ */ return [ - 'Foo' => function() { + 'Foo' => function () { return 'Foo!'; }, ]; diff --git a/tests/phpunit/includes/Services/TestWiring2.php b/tests/phpunit/includes/Services/TestWiring2.php index 3b4fff03e4..dfff64f048 100644 --- a/tests/phpunit/includes/Services/TestWiring2.php +++ b/tests/phpunit/includes/Services/TestWiring2.php @@ -4,7 +4,7 @@ */ return [ - 'Bar' => function() { + 'Bar' => function () { return 'Bar!'; }, ]; diff --git a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php index 872c580fa8..6b436a8d6d 100644 --- a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php +++ b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php @@ -21,9 +21,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $this->isType( 'array' ), $this->isType( 'int' ) ) - ->will( $this->returnCallback( function( $a, $conj ) { + ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function( $s ) { + return join( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); @@ -31,7 +31,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $mock->expects( $this->any() ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; } ) ); @@ -41,7 +41,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $mock->expects( $this->any() ) ->method( 'bitAnd' ) - ->willReturnCallback( function( $a, $b ) { + ->willReturnCallback( function ( $a, $b ) { return "($a & $b)"; } ); @@ -106,12 +106,12 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $mock->expects( $this->any() ) ->method( 'isAllowed' ) - ->will( $this->returnCallback( function( $action ) use ( $notAllowedAction ) { + ->will( $this->returnCallback( function ( $action ) use ( $notAllowedAction ) { return $action !== $notAllowedAction; } ) ); $mock->expects( $this->any() ) ->method( 'isAllowedAny' ) - ->will( $this->returnCallback( function() use ( $notAllowedAction ) { + ->will( $this->returnCallback( function () use ( $notAllowedAction ) { $actions = func_get_args(); return !in_array( $notAllowedAction, $actions ); } ) ); @@ -1450,7 +1450,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $mockDb = $this->getMockDb(); $mockDb->expects( $this->any() ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; } ) ); $mockDb->expects( $this->any() ) @@ -1459,9 +1459,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { $this->isType( 'array' ), $this->isType( 'int' ) ) - ->will( $this->returnCallback( function( $a, $conj ) { + ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function( $s ) { + return join( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); diff --git a/tests/phpunit/includes/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/WatchedItemStoreUnitTest.php index f31028da6f..fa81eb1f23 100644 --- a/tests/phpunit/includes/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/WatchedItemStoreUnitTest.php @@ -48,7 +48,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->getMock(); $mock->expects( $this->any() ) ->method( 'makeKey' ) - ->will( $this->returnCallback( function() { + ->will( $this->returnCallback( function () { return implode( ':', func_get_args() ); } ) ); return $mock; @@ -313,12 +313,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->will( $this->returnValue( 7 ) ); $mockDb->expects( $this->exactly( 1 ) ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; } ) ); $mockDb->expects( $this->exactly( 1 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); @@ -351,12 +351,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $mockDb = $this->getMockDb(); $mockDb->expects( $this->exactly( 2 * 3 ) ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; } ) ); $mockDb->expects( $this->exactly( 3 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); $mockDb->expects( $this->any() ) @@ -365,9 +365,9 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $this->isType( 'array' ), $this->isType( 'int' ) ) - ->will( $this->returnCallback( function( $a, $conj ) { + ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function( $s ) { + return join( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); @@ -446,12 +446,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $mockDb = $this->getMockDb(); $mockDb->expects( $this->exactly( 2 * 3 ) ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; } ) ); $mockDb->expects( $this->exactly( 3 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); $mockDb->expects( $this->any() ) @@ -460,9 +460,9 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $this->isType( 'array' ), $this->isType( 'int' ) ) - ->will( $this->returnCallback( function( $a, $conj ) { + ->will( $this->returnCallback( function ( $a, $conj ) { $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR '; - return join( $sqlConj, array_map( function( $s ) { + return join( $sqlConj, array_map( function ( $s ) { return '(' . $s . ')'; }, $a ) ); @@ -1970,7 +1970,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { // Note: This does not actually assert the job is correct $callableCallCounter = 0; - $mockCallback = function( $callable ) use ( &$callableCallCounter ) { + $mockCallback = function ( $callable ) use ( &$callableCallCounter ) { $callableCallCounter++; $this->assertInternalType( 'callable', $callable ); }; @@ -2011,7 +2011,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { // Note: This does not actually assert the job is correct $callableCallCounter = 0; - $mockCallback = function( $callable ) use ( &$callableCallCounter ) { + $mockCallback = function ( $callable ) use ( &$callableCallCounter ) { $callableCallCounter++; $this->assertInternalType( 'callable', $callable ); }; @@ -2105,13 +2105,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $callableCallCounter = 0; $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( - function( $callable ) use ( &$callableCallCounter, $title, $user ) { + function ( $callable ) use ( &$callableCallCounter, $title, $user ) { $callableCallCounter++; $this->verifyCallbackJob( $callable, $title, $user->getId(), - function( $time ) { + function ( $time ) { return $time === null; } ); @@ -2172,13 +2172,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $addUpdateCallCounter = 0; $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback( - function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { + function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { $addUpdateCallCounter++; $this->verifyCallbackJob( $callable, $title, $user->getId(), - function( $time ) { + function ( $time ) { return $time !== null && $time > '20151212010101'; } ); @@ -2187,7 +2187,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $getTimestampCallCounter = 0; $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback( - function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { + function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { $getTimestampCallCounter++; $this->assertEquals( $title, $titleParam ); $this->assertEquals( $oldid, $oldidParam ); @@ -2248,13 +2248,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $callableCallCounter = 0; $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( - function( $callable ) use ( &$callableCallCounter, $title, $user ) { + function ( $callable ) use ( &$callableCallCounter, $title, $user ) { $callableCallCounter++; $this->verifyCallbackJob( $callable, $title, $user->getId(), - function( $time ) { + function ( $time ) { return $time === null; } ); @@ -2315,13 +2315,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $addUpdateCallCounter = 0; $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback( - function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { + function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { $addUpdateCallCounter++; $this->verifyCallbackJob( $callable, $title, $user->getId(), - function( $time ) { + function ( $time ) { return $time === '30151212010101'; } ); @@ -2330,7 +2330,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $getTimestampCallCounter = 0; $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback( - function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { + function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { $getTimestampCallCounter++; $this->assertEquals( $title, $titleParam ); $this->assertEquals( $oldid, $oldidParam ); @@ -2393,13 +2393,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $addUpdateCallCounter = 0; $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback( - function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { + function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) { $addUpdateCallCounter++; $this->verifyCallbackJob( $callable, $title, $user->getId(), - function( $time ) { + function ( $time ) { return $time === false; } ); @@ -2408,7 +2408,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { $getTimestampCallCounter = 0; $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback( - function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { + function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) { $getTimestampCallCounter++; $this->assertEquals( $title, $titleParam ); $this->assertEquals( $oldid, $oldidParam ); @@ -2454,7 +2454,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); $mockDb->expects( $this->exactly( 1 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); @@ -2484,7 +2484,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); $mockDb->expects( $this->exactly( 0 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); @@ -2515,7 +2515,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); $mockDb->expects( $this->exactly( 1 ) ) ->method( 'timestamp' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return 'TS' . $value . 'TS'; } ) ); $mockDb->expects( $this->once() ) diff --git a/tests/phpunit/includes/api/ApiPageSetTest.php b/tests/phpunit/includes/api/ApiPageSetTest.php index 8a2146a15b..1aa0a133b9 100644 --- a/tests/phpunit/includes/api/ApiPageSetTest.php +++ b/tests/phpunit/includes/api/ApiPageSetTest.php @@ -14,7 +14,7 @@ class ApiPageSetTest extends ApiTestCase { ], 'A simple merge policy adds the redirect data in' => [ - function( $current, $new ) { + function ( $current, $new ) { if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) { $current['index'] = $new['index']; } diff --git a/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php b/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php index b508928381..4f4453fd1b 100644 --- a/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php +++ b/tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php @@ -210,7 +210,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase { // not checking values of all keys of the actual item, so removing unwanted keys from comparison $actualItemsOnlyComparedValues = array_map( - function( array $item ) use ( $keysUsedInValueComparison ) { + function ( array $item ) use ( $keysUsedInValueComparison ) { return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) ); }, $actualItems diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index d5c17ee8ba..50a59f97e8 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -87,7 +87,7 @@ class RandomImageGenerator { __DIR__ . '/words.txt' ] as $dictionaryFile ) { - if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) { + if ( is_file( $dictionaryFile ) && is_readable( $dictionaryFile ) ) { $this->dictionaryFile = $dictionaryFile; break; } diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php index 8a766187c8..ba38128f17 100644 --- a/tests/phpunit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/includes/config/ConfigFactoryTest.php @@ -63,7 +63,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { // define new config instance $newFactory = new ConfigFactory(); $newFactory->register( 'foo', 'GlobalVarConfig::newInstance' ); - $newFactory->register( 'bar', function() { + $newFactory->register( 'bar', function () { return new HashConfig(); } ); diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php index 403bee17b1..ee79ffa40f 100644 --- a/tests/phpunit/includes/content/ContentHandlerTest.php +++ b/tests/phpunit/includes/content/ContentHandlerTest.php @@ -28,7 +28,7 @@ class ContentHandlerTest extends MediaWikiTestCase { CONTENT_MODEL_CSS => 'CssContentHandler', CONTENT_MODEL_TEXT => 'TextContentHandler', 'testing' => 'DummyContentHandlerForTesting', - 'testing-callbacks' => function( $modelId ) { + 'testing-callbacks' => function ( $modelId ) { return new DummyContentHandlerForTesting( $modelId ); } ], @@ -418,7 +418,7 @@ class ContentHandlerTest extends MediaWikiTestCase { $searchEngine->expects( $this->any() ) ->method( 'makeSearchFieldMapping' ) - ->will( $this->returnCallback( function( $name, $type ) { + ->will( $this->returnCallback( function ( $name, $type ) { return new DummySearchIndexFieldDefinition( $name, $type ); } ) ); diff --git a/tests/phpunit/includes/jobqueue/JobTest.php b/tests/phpunit/includes/jobqueue/JobTest.php index 00c47c8ae8..6723a0bf9b 100644 --- a/tests/phpunit/includes/jobqueue/JobTest.php +++ b/tests/phpunit/includes/jobqueue/JobTest.php @@ -112,7 +112,7 @@ class JobTest extends MediaWikiTestCase { public function provideTestJobFactory() { return [ 'class name' => [ 'NullJob' ], - 'closure' => [ function( Title $title, array $params ) { + 'closure' => [ function ( Title $title, array $params ) { return new NullJob( $title, $params ); } ], 'function' => [ [ $this, 'newNullJob' ] ], diff --git a/tests/phpunit/includes/libs/DeferredStringifierTest.php b/tests/phpunit/includes/libs/DeferredStringifierTest.php index 5e1970b5e6..cba293926e 100644 --- a/tests/phpunit/includes/libs/DeferredStringifierTest.php +++ b/tests/phpunit/includes/libs/DeferredStringifierTest.php @@ -17,7 +17,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase { // No args [ [ - function() { + function () { return 'foo'; } ], @@ -26,7 +26,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase { // Has args [ [ - function( $i ) { + function ( $i ) { return $i; }, 'bar' @@ -41,7 +41,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase { * it is never converted to a string */ public function testCallbackNotCalled() { - $ds = new DeferredStringifier( function() { + $ds = new DeferredStringifier( function () { throw new Exception( 'This should not be reached!' ); } ); // No exception was thrown diff --git a/tests/phpunit/includes/libs/ObjectFactoryTest.php b/tests/phpunit/includes/libs/ObjectFactoryTest.php index 3e0a61ee7c..35a7b6028d 100644 --- a/tests/phpunit/includes/libs/ObjectFactoryTest.php +++ b/tests/phpunit/includes/libs/ObjectFactoryTest.php @@ -27,13 +27,13 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture', 'args' => [ - function() { + function () { return 'wrapped'; }, 'unwrapped', ], 'calls' => [ - 'setter' => [ function() { + 'setter' => [ function () { return 'wrapped'; }, ], ], @@ -54,13 +54,13 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture', 'args' => [ - function() { + function () { return 'wrapped'; }, 'unwrapped', ], 'calls' => [ - 'setter' => [ function() { + 'setter' => [ function () { return 'wrapped'; }, ], ], @@ -74,11 +74,11 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase { $obj = ObjectFactory::getObjectFromSpec( [ 'class' => 'ObjectFactoryTestFixture', - 'args' => [ function() { + 'args' => [ function () { return 'unwrapped'; }, ], 'calls' => [ - 'setter' => [ function() { + 'setter' => [ function () { return 'unwrapped'; }, ], ], diff --git a/tests/phpunit/includes/libs/XmlTypeCheckTest.php b/tests/phpunit/includes/libs/XmlTypeCheckTest.php index 7f9a772aa7..5c5eeaa702 100644 --- a/tests/phpunit/includes/libs/XmlTypeCheckTest.php +++ b/tests/phpunit/includes/libs/XmlTypeCheckTest.php @@ -66,7 +66,7 @@ XML; null, false, [ - 'processing_instruction_handler' => function() use ( &$called ) { + 'processing_instruction_handler' => function () use ( &$called ) { $called = true; } ] diff --git a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php index 2b0436614e..3d405faf3d 100644 --- a/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php +++ b/tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php @@ -176,7 +176,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $priorValue = null; $priorAsOf = null; $wasSet = 0; - $func = function( $old, &$ttl, &$opts, $asOf ) + $func = function ( $old, &$ttl, &$opts, $asOf ) use ( &$wasSet, &$priorValue, &$priorAsOf, $value ) { ++$wasSet; @@ -583,7 +583,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $value = wfRandomString(); $calls = 0; - $func = function() use ( &$calls, $value, $cache, $key ) { + $func = function () use ( &$calls, $value, $cache, $key ) { ++$calls; // Immediately kill any mutex rather than waiting a second $cache->delete( $cache::MUTEX_KEY_PREFIX . $key ); @@ -625,7 +625,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $value = wfRandomString(); $calls = 0; - $func = function( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) { + $func = function ( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) { ++$calls; $setOpts['since'] = microtime( true ) - 10; // Immediately kill any mutex rather than waiting a second @@ -659,7 +659,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $busyValue = wfRandomString(); $calls = 0; - $func = function() use ( &$calls, $value, $cache, $key ) { + $func = function () use ( &$calls, $value, $cache, $key ) { ++$calls; // Immediately kill any mutex rather than waiting a second $cache->delete( $cache::MUTEX_KEY_PREFIX . $key ); @@ -921,7 +921,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase { $value = wfRandomString(); $wasSet = 0; - $func = function( $old, &$ttl ) use ( &$wasSet, $value ) { + $func = function ( $old, &$ttl ) use ( &$wasSet, $value ) { ++$wasSet; return $value; }; diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 79d0784c27..f5a08904ea 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -199,7 +199,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { * @covers ResourceLoader::getModule */ public function testGetModuleFactory() { - $factory = function( array $info ) { + $factory = function ( array $info ) { $this->assertArrayHasKey( 'kitten', $info ); return new ResourceLoaderTestModule( $info ); }; diff --git a/tests/phpunit/includes/search/SearchEnginePrefixTest.php b/tests/phpunit/includes/search/SearchEnginePrefixTest.php index fbbcee5897..4c5bab3fcc 100644 --- a/tests/phpunit/includes/search/SearchEnginePrefixTest.php +++ b/tests/phpunit/includes/search/SearchEnginePrefixTest.php @@ -185,7 +185,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase { public function testSearch( array $case ) { $this->search->setLimitOffset( 3 ); $results = $this->search->defaultPrefixSearch( $case['query'] ); - $results = array_map( function( Title $t ) { + $results = array_map( function ( Title $t ) { return $t->getPrefixedText(); }, $results ); @@ -203,7 +203,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase { public function testSearchWithOffset( array $case ) { $this->search->setLimitOffset( 3, 1 ); $results = $this->search->defaultPrefixSearch( $case['query'] ); - $results = array_map( function( Title $t ) { + $results = array_map( function ( Title $t ) { return $t->getPrefixedText(); }, $results ); @@ -349,7 +349,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase { $search->setLimitOffset( 3 ); $results = $search->completionSearch( $case['query'] ); - $results = $results->map( function( SearchSuggestion $s ) { + $results = $results->map( function ( SearchSuggestion $s ) { return $s->getText(); } ); diff --git a/tests/phpunit/includes/search/SearchSuggestionSetTest.php b/tests/phpunit/includes/search/SearchSuggestionSetTest.php index 60559fcafc..28c69fa4b1 100644 --- a/tests/phpunit/includes/search/SearchSuggestionSetTest.php +++ b/tests/phpunit/includes/search/SearchSuggestionSetTest.php @@ -43,7 +43,7 @@ class SearchSuggestionSetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( 3, $set->getBestScore() ); $this->assertEquals( 1, $suggestion->getScore() ); - $scores = $set->map( function( $s ) { + $scores = $set->map( function ( $s ) { return $s->getScore(); } ); $sorted = $scores; @@ -80,7 +80,7 @@ class SearchSuggestionSetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals( 6, $set->getBestScore() ); $this->assertEquals( 6, $suggestion->getScore() ); - $scores = $set->map( function( $s ) { + $scores = $set->map( function ( $s ) { return $s->getScore(); } ); $sorted = $scores; diff --git a/tests/phpunit/includes/site/CachingSiteStoreTest.php b/tests/phpunit/includes/site/CachingSiteStoreTest.php index 7e37907be0..adf95e6cde 100644 --- a/tests/phpunit/includes/site/CachingSiteStoreTest.php +++ b/tests/phpunit/includes/site/CachingSiteStoreTest.php @@ -101,7 +101,7 @@ class CachingSiteStoreTest extends MediaWikiTestCase { $dbSiteStore->expects( $this->any() ) ->method( 'getSites' ) - ->will( $this->returnCallback( function() { + ->will( $this->returnCallback( function () { $siteList = new SiteList(); $siteList->setSite( $this->getTestSite() ); diff --git a/tests/phpunit/includes/specials/SpecialSearchTest.php b/tests/phpunit/includes/specials/SpecialSearchTest.php index 4e9d826360..94924ee1e7 100644 --- a/tests/phpunit/includes/specials/SpecialSearchTest.php +++ b/tests/phpunit/includes/specials/SpecialSearchTest.php @@ -183,7 +183,7 @@ class SpecialSearchTest extends MediaWikiTestCase { $rewrittenQuery, array $resultTitles ) { - $results = array_map( function( $title ) { + $results = array_map( function ( $title ) { return SearchResult::newFromTitle( $title ); }, $resultTitles ); diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php index 6506d58e21..017e97d357 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -36,7 +36,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase { $batchSize = 2; $reader = new BatchRowIterator( $db, 'some_table', 'id_field', $batchSize ); - $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function() { + $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function () { static $i = 0; return [ 'id_field' => ++$i ]; } ); @@ -171,7 +171,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase { public function testReaderSelectConditionsMultiplePrimaryKeys( $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3 ) { - $results = $this->genSelectResult( $batchSize, $batchSize * 3, function() { + $results = $this->genSelectResult( $batchSize, $batchSize * 3, function () { static $i = 0, $j = 100, $k = 1000; return [ 'id_field' => ++$i, 'foo' => ++$j, 'bar' => ++$k ]; } ); @@ -204,7 +204,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase { ->will( $this->consecutivelyReturnFromSelect( $retvals ) ); $db->expects( $this->any() ) ->method( 'addQuotes' ) - ->will( $this->returnCallback( function( $value ) { + ->will( $this->returnCallback( function ( $value ) { return "'$value'"; // not real quoting: doesn't matter in test } ) ); -- 2.20.1