aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/ActorMigration.php8
-rw-r--r--includes/CommentStore.php4
-rw-r--r--includes/ContentSecurityPolicy.php2
-rw-r--r--includes/FauxResponse.php2
-rw-r--r--includes/FileDeleteForm.php2
-rw-r--r--includes/ForeignResourceManager.php4
-rw-r--r--includes/GlobalFunctions.php8
-rw-r--r--includes/LinkFilter.php4
-rw-r--r--includes/Linker.php4
-rw-r--r--includes/MediaWiki.php2
-rw-r--r--includes/MediaWikiServices.php2
-rw-r--r--includes/MovePage.php2
-rw-r--r--includes/OutputPage.php4
-rw-r--r--includes/PageProps.php4
-rw-r--r--includes/PathRouter.php2
-rw-r--r--includes/Pingback.php2
-rw-r--r--includes/Rest/EntryPoint.php2
-rw-r--r--includes/Rest/Handler/ActionModuleBasedHandler.php2
-rw-r--r--includes/Rest/Handler/MediaLinksHandler.php2
-rw-r--r--includes/Rest/Handler/SearchHandler.php6
-rw-r--r--includes/Revision/RevisionSlots.php8
-rw-r--r--includes/Revision/RevisionStore.php4
-rw-r--r--includes/Revision/SlotRecord.php2
-rw-r--r--includes/Revision/SlotRoleRegistry.php2
-rw-r--r--includes/ServiceWiring.php278
-rw-r--r--includes/Setup.php4
-rw-r--r--includes/SiteStats.php2
-rw-r--r--includes/Status.php4
-rw-r--r--includes/Storage/DerivedPageDataUpdater.php4
-rw-r--r--includes/Storage/NameTableStoreFactory.php2
-rw-r--r--includes/Storage/PageEditStash.php2
-rw-r--r--includes/Storage/PageUpdater.php6
-rw-r--r--includes/Storage/SqlBlobStore.php2
-rw-r--r--includes/Title.php10
-rw-r--r--includes/WebResponse.php2
-rw-r--r--includes/actions/InfoAction.php2
-rw-r--r--includes/actions/RollbackAction.php2
-rw-r--r--includes/api/ApiAuthManagerHelper.php8
-rw-r--r--includes/api/ApiBase.php4
-rw-r--r--includes/api/ApiBlock.php2
-rw-r--r--includes/api/ApiFormatXml.php4
-rw-r--r--includes/api/ApiMain.php4
-rw-r--r--includes/api/ApiParse.php4
-rw-r--r--includes/api/ApiQueryBacklinks.php2
-rw-r--r--includes/api/ApiQueryBacklinksprop.php2
-rw-r--r--includes/api/ApiQueryContributors.php2
-rw-r--r--includes/api/ApiQueryFileRepoInfo.php4
-rw-r--r--includes/api/ApiQueryImageInfo.php6
-rw-r--r--includes/api/ApiQueryInfo.php4
-rw-r--r--includes/api/ApiQueryPrefixSearch.php2
-rw-r--r--includes/api/ApiQuerySearch.php2
-rw-r--r--includes/api/ApiQuerySiteinfo.php2
-rw-r--r--includes/api/ApiQueryTags.php2
-rw-r--r--includes/api/ApiQueryUsers.php2
-rw-r--r--includes/api/ApiRemoveAuthenticationData.php2
-rw-r--r--includes/api/ApiRollback.php2
-rw-r--r--includes/api/ApiTokens.php2
-rw-r--r--includes/api/ApiWatch.php2
-rw-r--r--includes/api/Validator/ApiParamValidator.php2
-rw-r--r--includes/auth/AuthManager.php4
-rw-r--r--includes/auth/AuthenticationRequest.php4
-rw-r--r--includes/auth/ButtonAuthenticationRequest.php2
-rw-r--r--includes/auth/LocalPasswordPrimaryAuthenticationProvider.php2
-rw-r--r--includes/block/BlockErrorFormatter.php2
-rw-r--r--includes/block/BlockRestrictionStore.php6
-rw-r--r--includes/block/DatabaseBlock.php6
-rw-r--r--includes/block/DatabaseBlockStore.php2
-rw-r--r--includes/cache/BacklinkCache.php2
-rw-r--r--includes/cache/LinkBatch.php2
-rw-r--r--includes/changes/ChangesListBooleanFilter.php2
-rw-r--r--includes/changes/ChangesListFilter.php4
-rw-r--r--includes/changes/ChangesListFilterGroup.php8
-rw-r--r--includes/changes/EnhancedChangesList.php2
-rw-r--r--includes/changes/RecentChange.php4
-rw-r--r--includes/changetags/ChangeTags.php12
-rw-r--r--includes/collation/NumericUppercaseCollation.php2
-rw-r--r--includes/context/RequestContext.php4
-rw-r--r--includes/db/CloneDatabase.php2
-rw-r--r--includes/db/MWLBFactory.php2
-rw-r--r--includes/deferred/CdnCacheUpdate.php2
-rw-r--r--includes/deferred/DeferredUpdates.php6
-rw-r--r--includes/deferred/LinksDeletionUpdate.php2
-rw-r--r--includes/deferred/SiteStatsUpdate.php2
-rw-r--r--includes/diff/TextSlotDiffRenderer.php2
-rw-r--r--includes/exception/MWExceptionHandler.php6
-rw-r--r--includes/export/XmlDumpWriter.php12
-rw-r--r--includes/filebackend/FileBackendGroup.php2
-rw-r--r--includes/filerepo/ForeignDBRepo.php2
-rw-r--r--includes/filerepo/LocalRepo.php4
-rw-r--r--includes/filerepo/RepoGroup.php2
-rw-r--r--includes/filerepo/file/File.php2
-rw-r--r--includes/filerepo/file/ForeignDBFile.php2
-rw-r--r--includes/filerepo/file/LocalFile.php4
-rw-r--r--includes/htmlform/fields/HTMLNamespacesMultiselectField.php2
-rw-r--r--includes/htmlform/fields/HTMLTitlesMultiselectField.php2
-rw-r--r--includes/htmlform/fields/HTMLUsersMultiselectField.php2
-rw-r--r--includes/http/GuzzleHttpRequest.php2
-rw-r--r--includes/installer/DatabaseInstaller.php2
-rw-r--r--includes/installer/Installer.php8
-rw-r--r--includes/jobqueue/JobQueueDB.php6
-rw-r--r--includes/jobqueue/JobQueueGroup.php2
-rw-r--r--includes/jobqueue/JobQueueRedis.php2
-rw-r--r--includes/jobqueue/JobRunner.php2
-rw-r--r--includes/jobqueue/jobs/AssembleUploadChunksJob.php2
-rw-r--r--includes/jobqueue/jobs/PublishStashedFileJob.php2
-rw-r--r--includes/jobqueue/utils/PurgeJobUtils.php2
-rw-r--r--includes/language/converters/EnConverter.php4
-rw-r--r--includes/libs/ArrayUtils.php2
-rw-r--r--includes/libs/CSSMin.php6
-rw-r--r--includes/libs/HashRing.php6
-rw-r--r--includes/libs/ParamValidator/ParamValidator.php4
-rw-r--r--includes/libs/ParamValidator/TypeDef/EnumDef.php2
-rw-r--r--includes/libs/ParamValidator/TypeDef/ExpiryDef.php2
-rw-r--r--includes/libs/StatusValue.php4
-rw-r--r--includes/libs/StringUtils.php4
-rw-r--r--includes/libs/Timing.php2
-rw-r--r--includes/libs/XhprofData.php2
-rw-r--r--includes/libs/filebackend/FileBackendMultiWrite.php4
-rw-r--r--includes/libs/filebackend/HTTPFileStreamer.php4
-rw-r--r--includes/libs/filebackend/SwiftFileBackend.php2
-rw-r--r--includes/libs/http/HttpAcceptParser.php4
-rw-r--r--includes/libs/http/MultiHttpClient.php8
-rw-r--r--includes/libs/lockmanager/MemcLockManager.php2
-rw-r--r--includes/libs/lockmanager/PostgreSqlLockManager.php2
-rw-r--r--includes/libs/objectcache/MemcachedBagOStuff.php2
-rw-r--r--includes/libs/objectcache/MultiWriteBagOStuff.php2
-rw-r--r--includes/libs/objectcache/WinCacheBagOStuff.php2
-rw-r--r--includes/libs/objectcache/wancache/WANObjectCache.php8
-rw-r--r--includes/libs/objectcache/wancache/WANObjectCacheReaper.php2
-rw-r--r--includes/libs/rdbms/database/Database.php10
-rw-r--r--includes/libs/rdbms/lbfactory/LBFactory.php24
-rw-r--r--includes/libs/rdbms/loadbalancer/LoadBalancer.php40
-rw-r--r--includes/libs/stats/SamplingStatsdClient.php2
-rw-r--r--includes/libs/virtualrest/VirtualRESTServiceClient.php4
-rw-r--r--includes/logging/RightsLogFormatter.php4
-rw-r--r--includes/mail/UserMailer.php2
-rw-r--r--includes/media/DjVuHandler.php2
-rw-r--r--includes/media/SvgHandler.php2
-rw-r--r--includes/media/TransformationalImageHandler.php2
-rw-r--r--includes/objectcache/ObjectCache.php2
-rw-r--r--includes/objectcache/SqlBagOStuff.php4
-rw-r--r--includes/page/PageArchive.php2
-rw-r--r--includes/page/WikiPage.php16
-rw-r--r--includes/pager/IndexPager.php2
-rw-r--r--includes/parser/CoreParserFunctions.php6
-rw-r--r--includes/parser/LinkHolderArray.php4
-rw-r--r--includes/parser/Parser.php10
-rw-r--r--includes/parser/ParserOptions.php10
-rw-r--r--includes/parser/ParserOutput.php6
-rw-r--r--includes/parser/Sanitizer.php6
-rw-r--r--includes/preferences/DefaultPreferencesFactory.php2
-rw-r--r--includes/preferences/MultiTitleFilter.php2
-rw-r--r--includes/preferences/SignatureValidator.php2
-rw-r--r--includes/profiler/ProfilerSectionOnly.php2
-rw-r--r--includes/profiler/ProfilerXhprof.php2
-rw-r--r--includes/profiler/output/ProfilerOutputText.php6
-rw-r--r--includes/registration/ExtensionProcessor.php4
-rw-r--r--includes/resourceloader/ResourceLoader.php2
-rw-r--r--includes/resourceloader/ResourceLoaderFileModule.php2
-rw-r--r--includes/resourceloader/ResourceLoaderModule.php6
-rw-r--r--includes/resourceloader/ResourceLoaderOOUIImageModule.php4
-rw-r--r--includes/resourceloader/ResourceLoaderSkinModule.php4
-rw-r--r--includes/resourceloader/ResourceLoaderWikiModule.php2
-rw-r--r--includes/search/FauxSearchResultSet.php2
-rw-r--r--includes/search/PrefixSearch.php2
-rw-r--r--includes/search/SearchEngine.php10
-rw-r--r--includes/search/SearchResultSet.php2
-rw-r--r--includes/search/SearchResultTrait.php2
-rw-r--r--includes/search/SearchSuggestionSet.php4
-rw-r--r--includes/search/StringPrefixSearch.php2
-rw-r--r--includes/session/SessionBackend.php2
-rw-r--r--includes/session/SessionManager.php2
-rw-r--r--includes/site/MediaWikiPageNameNormalizer.php2
-rw-r--r--includes/skins/SkinFallback.php4
-rw-r--r--includes/specialpage/AuthManagerSpecialPage.php2
-rw-r--r--includes/specialpage/ChangesListSpecialPage.php90
-rw-r--r--includes/specialpage/DisabledSpecialPage.php2
-rw-r--r--includes/specialpage/FormSpecialPage.php2
-rw-r--r--includes/specialpage/SpecialPage.php2
-rw-r--r--includes/specials/SpecialBlock.php2
-rw-r--r--includes/specials/SpecialBotPasswords.php8
-rw-r--r--includes/specials/SpecialFileDuplicateSearch.php2
-rw-r--r--includes/specials/SpecialMovepage.php2
-rw-r--r--includes/specials/SpecialNewpages.php2
-rw-r--r--includes/specials/SpecialRecentChanges.php8
-rw-r--r--includes/specials/SpecialResetTokens.php2
-rw-r--r--includes/specials/SpecialSearch.php2
-rw-r--r--includes/specials/SpecialUserrights.php2
-rw-r--r--includes/specials/SpecialVersion.php4
-rw-r--r--includes/specials/SpecialWatchlist.php2
-rw-r--r--includes/specials/SpecialWhatLinksHere.php2
-rw-r--r--includes/specials/pagers/BlockListPager.php2
-rw-r--r--includes/tidy/RemexDriver.php2
-rw-r--r--includes/upload/UploadBase.php2
-rw-r--r--includes/user/CentralIdLookup.php4
-rw-r--r--includes/user/User.php2
-rw-r--r--includes/user/UserRightsProxy.php2
-rw-r--r--includes/user/WatchlistNotificationManager.php2
-rw-r--r--includes/utils/BatchRowUpdate.php2
-rw-r--r--includes/watcheditem/WatchedItemQueryService.php2
-rw-r--r--includes/watcheditem/WatchedItemStore.php4
201 files changed, 552 insertions, 552 deletions
diff --git a/includes/ActorMigration.php b/includes/ActorMigration.php
index 91b6ee35f91b..1a4bd581380e 100644
--- a/includes/ActorMigration.php
+++ b/includes/ActorMigration.php
@@ -365,7 +365,7 @@ class ActorMigration {
if ( isset( self::$tempTables[$key] ) ) {
$func = __METHOD__;
- $callback = function ( $pk, array $extra ) use ( $dbw, $key, $id, $func ) {
+ $callback = static function ( $pk, array $extra ) use ( $dbw, $key, $id, $func ) {
$t = self::$tempTables[$key];
$set = [ $t['field'] => $id ];
foreach ( $t['extra'] as $to => $from ) {
@@ -384,12 +384,12 @@ class ActorMigration {
};
} else {
$ret[$actor] = $id;
- $callback = function ( $pk, array $extra ) {
+ $callback = static function ( $pk, array $extra ) {
};
}
} elseif ( isset( self::$tempTables[$key] ) ) {
$func = __METHOD__;
- $callback = function ( $pk, array $extra ) use ( $key, $func ) {
+ $callback = static function ( $pk, array $extra ) use ( $key, $func ) {
$t = self::$tempTables[$key];
foreach ( $t['extra'] as $to => $from ) {
if ( !array_key_exists( $from, $extra ) ) {
@@ -398,7 +398,7 @@ class ActorMigration {
}
};
} else {
- $callback = function ( $pk, array $extra ) {
+ $callback = static function ( $pk, array $extra ) {
};
}
return [ $ret, $callback ];
diff --git a/includes/CommentStore.php b/includes/CommentStore.php
index 1015c1a6eb4e..8e42a5fefa00 100644
--- a/includes/CommentStore.php
+++ b/includes/CommentStore.php
@@ -511,7 +511,7 @@ class CommentStore {
$t = $this->tempTables[$key];
$func = __METHOD__;
$commentId = $comment->id;
- $callback = function ( $id ) use ( $dbw, $commentId, $t, $func ) {
+ $callback = static function ( $id ) use ( $dbw, $commentId, $t, $func ) {
$dbw->insert(
$t['table'],
[
@@ -598,7 +598,7 @@ class CommentStore {
list( $fields, $callback ) = $this->insertInternal( $dbw, $key, $comment, $data );
if ( !$callback ) {
- $callback = function () {
+ $callback = static function () {
// Do nothing.
};
}
diff --git a/includes/ContentSecurityPolicy.php b/includes/ContentSecurityPolicy.php
index 05fe82b7c969..d9d906dbe6a5 100644
--- a/includes/ContentSecurityPolicy.php
+++ b/includes/ContentSecurityPolicy.php
@@ -410,7 +410,7 @@ class ContentSecurityPolicy {
// img-src unspecified they should be in default-src. Similarly,
// the DescriptionStylesheetUrl only needs to be in style-src
// (or default-src if style-src unspecified).
- $callback = function ( $repo, &$urls ) {
+ $callback = static function ( $repo, &$urls ) {
$urls[] = $repo->getZoneUrl( 'public' );
$urls[] = $repo->getZoneUrl( 'transcoded' );
$urls[] = $repo->getZoneUrl( 'thumb' );
diff --git a/includes/FauxResponse.php b/includes/FauxResponse.php
index 014c2590920d..50a9639139f7 100644
--- a/includes/FauxResponse.php
+++ b/includes/FauxResponse.php
@@ -94,7 +94,7 @@ class FauxResponse extends WebResponse {
global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
- $options = array_filter( $options, function ( $a ) {
+ $options = array_filter( $options, static function ( $a ) {
return $a !== null;
} ) + [
'prefix' => $wgCookiePrefix,
diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php
index 05f9df5e5016..8985fe3d59e4 100644
--- a/includes/FileDeleteForm.php
+++ b/includes/FileDeleteForm.php
@@ -233,7 +233,7 @@ class FileDeleteForm {
$logEntry->addTags( $tags );
$logid = $logEntry->insert();
$dbw->onTransactionPreCommitOrIdle(
- function () use ( $logEntry, $logid ) {
+ static function () use ( $logEntry, $logid ) {
$logEntry->publish( $logid );
},
__METHOD__
diff --git a/includes/ForeignResourceManager.php b/includes/ForeignResourceManager.php
index f720234097e3..cf5df42283e3 100644
--- a/includes/ForeignResourceManager.php
+++ b/includes/ForeignResourceManager.php
@@ -70,10 +70,10 @@ class ForeignResourceManager {
) {
$this->registryFile = $registryFile;
$this->libDir = $libDir;
- $this->infoPrinter = $infoPrinter ?? function ( $_ ) {
+ $this->infoPrinter = $infoPrinter ?? static function ( $_ ) {
};
$this->errorPrinter = $errorPrinter ?? $this->infoPrinter;
- $this->verbosePrinter = $verbosePrinter ?? function ( $_ ) {
+ $this->verbosePrinter = $verbosePrinter ?? static function ( $_ ) {
};
// Use a temporary directory under the destination directory instead
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index d6706de11880..5cdbe1acf0fa 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -865,7 +865,7 @@ function wfParseUrl( $url ) {
function wfExpandIRI( $url ) {
return preg_replace_callback(
'/((?:%[89A-F][0-9A-F])+)/i',
- function ( array $matches ) {
+ static function ( array $matches ) {
return urldecode( $matches[1] );
},
wfExpandUrl( $url )
@@ -1383,7 +1383,7 @@ function wfBacktrace( $raw = null ) {
$traceFormat = "<ul>\n%s</ul>\n";
}
- $frames = array_map( function ( $frame ) use ( $frameFormat ) {
+ $frames = array_map( static function ( $frame ) use ( $frameFormat ) {
$file = !empty( $frame['file'] ) ? basename( $frame['file'] ) : '-';
$line = $frame['line'] ?? '-';
$call = $frame['function'];
@@ -2815,12 +2815,12 @@ function wfThumbIsStandard( File $file, array $params ) {
// Expand limits to account for multipliers
foreach ( $multipliers as $multiplier ) {
$thumbLimits = array_merge( $thumbLimits, array_map(
- function ( $width ) use ( $multiplier ) {
+ static function ( $width ) use ( $multiplier ) {
return round( $width * $multiplier );
}, $wgThumbLimits )
);
$imageLimits = array_merge( $imageLimits, array_map(
- function ( $pair ) use ( $multiplier ) {
+ static function ( $pair ) use ( $multiplier ) {
return [
round( $pair[0] * $multiplier ),
round( $pair[1] * $multiplier ),
diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php
index 1f522471f160..335f2ae45ff8 100644
--- a/includes/LinkFilter.php
+++ b/includes/LinkFilter.php
@@ -115,7 +115,7 @@ class LinkFilter {
}
$host = preg_replace_callback(
'<[^' . $okChars . ']>',
- function ( $m ) {
+ static function ( $m ) {
return rawurlencode( $m[0] );
},
strtolower( $host )
@@ -154,7 +154,7 @@ class LinkFilter {
// IPv4?
$b = '(?:0*25[0-5]|0*2[0-4][0-9]|0*1[0-9][0-9]|0*[0-9]?[0-9])';
if ( preg_match( "/^(?:{$b}\.){3}{$b}$|^(?:{$b}\.){1,3}\*$/", $host ) ) {
- return 'V4.' . implode( '.', array_map( function ( $v ) {
+ return 'V4.' . implode( '.', array_map( static function ( $v ) {
return $v === '*' ? $v : (int)$v;
}, explode( '.', $host ) ) ) . '.';
}
diff --git a/includes/Linker.php b/includes/Linker.php
index f58f11d0edab..81d289bb7262 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1241,7 +1241,7 @@ class Linker {
// zero-width assertions optional, so wrap them in a non-capturing
// group.
'!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!',
- function ( $match ) use ( $title, $local, $wikiId, &$append ) {
+ static function ( $match ) use ( $title, $local, $wikiId, &$append ) {
global $wgLang;
// Ensure all match positions are defined
@@ -1343,7 +1343,7 @@ class Linker {
\]\]
([^[]*) # 3. link trail (the text up until the next link)
/x',
- function ( $match ) use ( $title, $local, $wikiId ) {
+ static function ( $match ) use ( $title, $local, $wikiId ) {
$services = MediaWikiServices::getInstance();
$medians = '(?:';
diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index f506c13395bc..f16ad08036c8 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -946,7 +946,7 @@ class MediaWiki {
// GUI-ify and stash the page output in MediaWiki::doPreOutputCommit() while
// ChronologyProtector synchronizes DB positions or replicas across all datacenters.
$buffer = null;
- $outputWork = function () use ( $output, &$buffer ) {
+ $outputWork = static function () use ( $output, &$buffer ) {
if ( $buffer === null ) {
$buffer = $output->output( true );
}
diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php
index e017055936d8..56319c0d89c3 100644
--- a/includes/MediaWikiServices.php
+++ b/includes/MediaWikiServices.php
@@ -534,7 +534,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', static function () use ( $config ) {
return $config;
} );
}
diff --git a/includes/MovePage.php b/includes/MovePage.php
index cdc994cab663..9c3d5bd1d2d7 100644
--- a/includes/MovePage.php
+++ b/includes/MovePage.php
@@ -154,7 +154,7 @@ class MovePage {
$this->oldTitle = $oldTitle;
$this->newTitle = $newTitle;
- $services = function () {
+ $services = static function () {
// BC hack. Use a closure so this can be unit-tested.
return MediaWikiServices::getInstance();
};
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 89197eb414c2..a314b90fdde5 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -1916,7 +1916,7 @@ class OutputPage extends ContextSource {
if ( $this->getConfig()->get( 'ImagePreconnect' ) && count( $parserOutput->getImages() ) ) {
$preconnect = [];
$repoGroup = MediaWikiServices::getInstance()->getRepoGroup();
- $repoGroup->forEachForeignRepo( function ( $repo ) use ( &$preconnect ) {
+ $repoGroup->forEachForeignRepo( static function ( $repo ) use ( &$preconnect ) {
$preconnect[] = wfParseUrl( $repo->getZoneUrl( 'thumb' ) )['host'];
} );
$preconnect[] = wfParseUrl( $repoGroup->getLocalRepo()->getZoneUrl( 'thumb' ) )['host'];
@@ -3008,7 +3008,7 @@ class OutputPage extends ContextSource {
// Filter out modules handled by buildExemptModules()
$moduleStyles = array_filter( $moduleStyles,
- function ( $name ) use ( $rl, $context, &$exemptGroups, &$exemptStates ) {
+ static function ( $name ) use ( $rl, $context, &$exemptGroups, &$exemptStates ) {
$module = $rl->getModule( $name );
if ( $module ) {
$group = $module->getGroup();
diff --git a/includes/PageProps.php b/includes/PageProps.php
index 340064701ccc..da672ff57055 100644
--- a/includes/PageProps.php
+++ b/includes/PageProps.php
@@ -66,12 +66,12 @@ class PageProps {
MediaWikiServices::getInstance()->redefineService(
'PageProps',
- function () use ( $store ) {
+ static function () use ( $store ) {
return $store;
}
);
- return new ScopedCallback( function () {
+ return new ScopedCallback( static function () {
MediaWikiServices::getInstance()->resetServiceForTesting( 'PageProps' );
} );
}
diff --git a/includes/PathRouter.php b/includes/PathRouter.php
index eb88d84a1b0e..60205ac7c02d 100644
--- a/includes/PathRouter.php
+++ b/includes/PathRouter.php
@@ -392,7 +392,7 @@ class PathRouter {
protected static function expandParamValue( $pathMatches, $key, $value ) {
$error = false;
- $replacer = function ( $m ) use ( $pathMatches, $key, &$error ) {
+ $replacer = static function ( $m ) use ( $pathMatches, $key, &$error ) {
if ( $m[1] == "key" ) {
if ( $key === null ) {
$error = true;
diff --git a/includes/Pingback.php b/includes/Pingback.php
index 6fc7b3112382..ac6ff197dc34 100644
--- a/includes/Pingback.php
+++ b/includes/Pingback.php
@@ -297,7 +297,7 @@ class Pingback {
// or DB_MASTER have issues, allow this to be turned off completely. (T269516)
return;
}
- DeferredUpdates::addCallableUpdate( function () {
+ DeferredUpdates::addCallableUpdate( static function () {
// Avoid re-use of $config as that would hold the same object from
// the outer call via Setup.php, all the way here through post-send.
$instance = new Pingback(
diff --git a/includes/Rest/EntryPoint.php b/includes/Rest/EntryPoint.php
index b8580d4f0ab6..67ab7ef84b87 100644
--- a/includes/Rest/EntryPoint.php
+++ b/includes/Rest/EntryPoint.php
@@ -59,7 +59,7 @@ class EntryPoint {
[ 'includes/Rest/coreRoutes.json' ],
$conf->get( 'RestAPIAdditionalRouteFiles' )
);
- array_walk( $routeFiles, function ( &$val, $key ) {
+ array_walk( $routeFiles, static function ( &$val, $key ) {
global $IP;
$val = "$IP/$val";
} );
diff --git a/includes/Rest/Handler/ActionModuleBasedHandler.php b/includes/Rest/Handler/ActionModuleBasedHandler.php
index 0e6209d566b5..a36c462f1542 100644
--- a/includes/Rest/Handler/ActionModuleBasedHandler.php
+++ b/includes/Rest/Handler/ActionModuleBasedHandler.php
@@ -101,7 +101,7 @@ abstract class ActionModuleBasedHandler extends Handler {
$group,
[
'class' => get_class( $module ),
- 'factory' => function () use ( $module ) {
+ 'factory' => static function () use ( $module ) {
return $module;
}
]
diff --git a/includes/Rest/Handler/MediaLinksHandler.php b/includes/Rest/Handler/MediaLinksHandler.php
index fd5d624fc1f2..8a56bc5bfeaa 100644
--- a/includes/Rest/Handler/MediaLinksHandler.php
+++ b/includes/Rest/Handler/MediaLinksHandler.php
@@ -117,7 +117,7 @@ class MediaLinksHandler extends SimpleHandler {
// caching model would be necessary, if caching is ever added to this endpoint.
// TODO: make RepoGroup::findFiles take Authority
$user = User::newFromIdentity( $this->getAuthority()->getActor() );
- $findTitles = array_map( function ( $title ) use ( $user ) {
+ $findTitles = array_map( static function ( $title ) use ( $user ) {
return [
'title' => $title,
'private' => $user,
diff --git a/includes/Rest/Handler/SearchHandler.php b/includes/Rest/Handler/SearchHandler.php
index 3cc99e15262a..2b8303ad74a6 100644
--- a/includes/Rest/Handler/SearchHandler.php
+++ b/includes/Rest/Handler/SearchHandler.php
@@ -227,7 +227,7 @@ class SearchHandler extends Handler {
* @return array[] of pageId => [ $title, null, $result ]
*/
private function buildResultFromPageInfos( array $pageInfos ): array {
- return array_map( function ( $pageInfo ) {
+ return array_map( static function ( $pageInfo ) {
list( $title, $sugg, $result ) = $pageInfo;
return [
'id' => $title->getArticleID(),
@@ -276,7 +276,7 @@ class SearchHandler extends Handler {
$this->getHookRunner()->onSearchResultProvideDescription( $pageIdentities, $descriptions );
- return array_map( function ( $description ) {
+ return array_map( static function ( $description ) {
return [ 'description' => $description ];
}, $descriptions );
}
@@ -309,7 +309,7 @@ class SearchHandler extends Handler {
public function execute() {
$searchEngine = $this->createSearchEngine();
$pageInfos = $this->doSearch( $searchEngine );
- $pageIdentities = array_map( function ( $pageInfo ) {
+ $pageIdentities = array_map( static function ( $pageInfo ) {
list( $title ) = $pageInfo;
return new SearchResultPageIdentityValue(
$title->getArticleID(),
diff --git a/includes/Revision/RevisionSlots.php b/includes/Revision/RevisionSlots.php
index bd32a02cc08f..7956cea18342 100644
--- a/includes/Revision/RevisionSlots.php
+++ b/includes/Revision/RevisionSlots.php
@@ -148,7 +148,7 @@ class RevisionSlots {
* @return int
*/
public function computeSize() {
- return array_reduce( $this->getSlots(), function ( $accu, SlotRecord $slot ) {
+ return array_reduce( $this->getSlots(), static function ( $accu, SlotRecord $slot ) {
return $accu + $slot->getSize();
}, 0 );
}
@@ -197,7 +197,7 @@ class RevisionSlots {
return SlotRecord::base36Sha1( '' );
}
- return array_reduce( $slots, function ( $accu, SlotRecord $slot ) {
+ return array_reduce( $slots, static function ( $accu, SlotRecord $slot ) {
return $accu === null
? $slot->getSha1()
: SlotRecord::base36Sha1( $accu . $slot->getSha1() );
@@ -215,7 +215,7 @@ class RevisionSlots {
public function getOriginalSlots() {
return array_filter(
$this->getSlots(),
- function ( SlotRecord $slot ) {
+ static function ( SlotRecord $slot ) {
return !$slot->isInherited();
}
);
@@ -232,7 +232,7 @@ class RevisionSlots {
public function getInheritedSlots() {
return array_filter(
$this->getSlots(),
- function ( SlotRecord $slot ) {
+ static function ( SlotRecord $slot ) {
return $slot->isInherited();
}
);
diff --git a/includes/Revision/RevisionStore.php b/includes/Revision/RevisionStore.php
index 6370f20335f8..7c410c96f35c 100644
--- a/includes/Revision/RevisionStore.php
+++ b/includes/Revision/RevisionStore.php
@@ -693,7 +693,7 @@ class RevisionStore
}
$fname = __METHOD__;
$dbw->onTransactionResolution(
- function ( $trigger, IDatabase $dbw ) use ( $fname ) {
+ static function ( $trigger, IDatabase $dbw ) use ( $fname ) {
$dbw->unlock( 'fix-for-T202032', $fname );
},
__METHOD__
@@ -1808,7 +1808,7 @@ class RevisionStore
$result->setResult(
true,
array_map(
- function ( $row )
+ static function ( $row )
use ( $queryFlags, $titlesByPageKey, $result, $newRevisionRecord, $revIdField ) {
try {
if ( !isset( $titlesByPageKey[$row->_page_key] ) ) {
diff --git a/includes/Revision/SlotRecord.php b/includes/Revision/SlotRecord.php
index 96dc238b7745..a047032ed4d9 100644
--- a/includes/Revision/SlotRecord.php
+++ b/includes/Revision/SlotRecord.php
@@ -65,7 +65,7 @@ class SlotRecord {
public static function newWithSuppressedContent( SlotRecord $slot ) {
$row = $slot->row;
- return new SlotRecord( $row, function () {
+ return new SlotRecord( $row, static function () {
throw new SuppressedDataException( 'Content suppressed!' );
} );
}
diff --git a/includes/Revision/SlotRoleRegistry.php b/includes/Revision/SlotRoleRegistry.php
index 910b65842364..ed54cf113881 100644
--- a/includes/Revision/SlotRoleRegistry.php
+++ b/includes/Revision/SlotRoleRegistry.php
@@ -110,7 +110,7 @@ class SlotRoleRegistry {
$this->defineRole(
$role,
- function ( $role ) use ( $model, $layout ) {
+ static function ( $role ) use ( $model, $layout ) {
return new SlotRoleHandler( $role, $model, $layout );
}
);
diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index ee914538e2da..d4b7749cc314 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -137,7 +137,7 @@ use Wikimedia\Services\RecursiveServiceDependencyException;
use Wikimedia\UUID\GlobalIdGenerator;
return [
- 'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
+ 'ActorMigration' => static function ( MediaWikiServices $services ) : ActorMigration {
return new ActorMigration(
SCHEMA_COMPAT_NEW,
$services->getUserFactory(),
@@ -145,7 +145,7 @@ return [
);
},
- 'ActorStoreFactory' => function ( MediaWikiServices $services ) : ActorStoreFactory {
+ 'ActorStoreFactory' => static function ( MediaWikiServices $services ) : ActorStoreFactory {
return new ActorStoreFactory(
new ServiceOptions( ActorStoreFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getDBLoadBalancerFactory(),
@@ -154,7 +154,7 @@ return [
);
},
- 'AuthManager' => function ( MediaWikiServices $services ) : AuthManager {
+ 'AuthManager' => static function ( MediaWikiServices $services ) : AuthManager {
$authManager = new AuthManager(
RequestContext::getMain()->getRequest(),
$services->getMainConfig(),
@@ -170,9 +170,9 @@ return [
return $authManager;
},
- 'BadFileLookup' => function ( MediaWikiServices $services ) : BadFileLookup {
+ 'BadFileLookup' => static function ( MediaWikiServices $services ) : BadFileLookup {
return new BadFileLookup(
- function () {
+ static function () {
return wfMessage( 'bad_image_list' )->inContentLanguage()->plain();
},
$services->getLocalServerObjectCache(),
@@ -182,11 +182,11 @@ return [
);
},
- 'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
+ 'BlobStore' => static function ( MediaWikiServices $services ) : BlobStore {
return $services->getService( '_SqlBlobStore' );
},
- 'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
+ 'BlobStoreFactory' => static function ( MediaWikiServices $services ) : BlobStoreFactory {
return new BlobStoreFactory(
$services->getDBLoadBalancerFactory(),
$services->getExternalStoreAccess(),
@@ -196,13 +196,13 @@ return [
);
},
- 'BlockErrorFormatter' => function ( MediaWikiServices $services ) : BlockErrorFormatter {
+ 'BlockErrorFormatter' => static function ( MediaWikiServices $services ) : BlockErrorFormatter {
return new BlockErrorFormatter(
$services->getUserFactory()
);
},
- 'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
+ 'BlockManager' => static function ( MediaWikiServices $services ) : BlockManager {
return new BlockManager(
new ServiceOptions(
BlockManager::CONSTRUCTOR_OPTIONS,
@@ -214,7 +214,7 @@ return [
);
},
- 'BlockPermissionCheckerFactory' => function (
+ 'BlockPermissionCheckerFactory' => static function (
MediaWikiServices $services
) : BlockPermissionCheckerFactory {
return new BlockPermissionCheckerFactory(
@@ -226,17 +226,17 @@ return [
);
},
- 'BlockRestrictionStore' => function ( MediaWikiServices $services ) : BlockRestrictionStore {
+ 'BlockRestrictionStore' => static function ( MediaWikiServices $services ) : BlockRestrictionStore {
return new BlockRestrictionStore(
$services->getDBLoadBalancer()
);
},
- 'BlockUserFactory' => function ( MediaWikiServices $services ) : BlockUserFactory {
+ 'BlockUserFactory' => static function ( MediaWikiServices $services ) : BlockUserFactory {
return $services->getService( '_UserBlockCommandFactory' );
},
- 'BlockUtils' => function ( MediaWikiServices $services ) : BlockUtils {
+ 'BlockUtils' => static function ( MediaWikiServices $services ) : BlockUtils {
return new BlockUtils(
new ServiceOptions(
BlockUtils::CONSTRUCTOR_OPTIONS,
@@ -246,18 +246,18 @@ return [
);
},
- 'ChangeTagDefStore' => function ( MediaWikiServices $services ) : NameTableStore {
+ 'ChangeTagDefStore' => static function ( MediaWikiServices $services ) : NameTableStore {
return $services->getNameTableStoreFactory()->getChangeTagDef();
},
- 'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
+ 'CommentStore' => static function ( MediaWikiServices $services ) : CommentStore {
return new CommentStore(
$services->getContentLanguage(),
MIGRATION_NEW
);
},
- 'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
+ 'ConfigFactory' => static function ( MediaWikiServices $services ) : ConfigFactory {
// Use the bootstrap config to initialize the ConfigFactory.
$registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
$factory = new ConfigFactory();
@@ -268,11 +268,11 @@ return [
return $factory;
},
- 'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
+ 'ConfigRepository' => static function ( MediaWikiServices $services ) : ConfigRepository {
return new ConfigRepository( $services->getConfigFactory() );
},
- 'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
+ 'ConfiguredReadOnlyMode' => static function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
$config = $services->getMainConfig();
return new ConfiguredReadOnlyMode(
$config->get( 'ReadOnly' ),
@@ -280,7 +280,7 @@ return [
);
},
- 'ContentHandlerFactory' => function ( MediaWikiServices $services ) : IContentHandlerFactory {
+ 'ContentHandlerFactory' => static function ( MediaWikiServices $services ) : IContentHandlerFactory {
$contentHandlerConfig = $services->getMainConfig()->get( 'ContentHandlers' );
return new ContentHandlerFactory(
@@ -291,20 +291,20 @@ return [
);
},
- 'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
+ 'ContentLanguage' => static function ( MediaWikiServices $services ) : Language {
return $services->getLanguageFactory()->getLanguage(
$services->getMainConfig()->get( 'LanguageCode' ) );
},
- 'ContentModelChangeFactory' => function ( MediaWikiServices $services ) : ContentModelChangeFactory {
+ 'ContentModelChangeFactory' => static function ( MediaWikiServices $services ) : ContentModelChangeFactory {
return $services->getService( '_PageCommandFactory' );
},
- 'ContentModelStore' => function ( MediaWikiServices $services ) : NameTableStore {
+ 'ContentModelStore' => static function ( MediaWikiServices $services ) : NameTableStore {
return $services->getNameTableStoreFactory()->getContentModels();
},
- 'ContributionsLookup' => function ( MediaWikiServices $services ) : ContributionsLookup {
+ 'ContributionsLookup' => static function ( MediaWikiServices $services ) : ContributionsLookup {
return new ContributionsLookup(
$services->getRevisionStore(),
$services->getLinkRenderer(),
@@ -316,13 +316,13 @@ return [
);
},
- 'CriticalSectionProvider' => function ( MediaWikiServices $services ) : CriticalSectionProvider {
+ 'CriticalSectionProvider' => static function ( MediaWikiServices $services ) : CriticalSectionProvider {
$config = $services->getMainConfig();
$limit = $config->get( 'CommandLineMode' ) ? INF : $config->get( 'CriticalSectionTimeLimit' );
return RequestTimeout::singleton()->createCriticalSectionProvider( $limit );
},
- 'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
+ 'CryptHKDF' => static function ( MediaWikiServices $services ) : CryptHKDF {
$config = $services->getMainConfig();
$secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
@@ -343,7 +343,7 @@ return [
return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
},
- 'DatabaseBlockStore' => function ( MediaWikiServices $services ) : DatabaseBlockStore {
+ 'DatabaseBlockStore' => static function ( MediaWikiServices $services ) : DatabaseBlockStore {
return new DatabaseBlockStore(
new ServiceOptions(
DatabaseBlockStore::CONSTRUCTOR_OPTIONS,
@@ -359,17 +359,17 @@ return [
);
},
- 'DateFormatterFactory' => function ( MediaWikiServices $services ) : DateFormatterFactory {
+ 'DateFormatterFactory' => static function ( MediaWikiServices $services ) : DateFormatterFactory {
return new DateFormatterFactory();
},
- 'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
+ 'DBLoadBalancer' => static function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
// just return the default LB from the DBLoadBalancerFactory service
return $services->getDBLoadBalancerFactory()->getMainLB();
},
'DBLoadBalancerFactory' =>
- function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
+ static function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
$mainConfig = $services->getMainConfig();
try {
@@ -412,22 +412,22 @@ return [
return $instance;
},
- 'Emailer' => function ( MediaWikiServices $services ) : IEmailer {
+ 'Emailer' => static function ( MediaWikiServices $services ) : IEmailer {
return new Emailer();
},
- 'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
+ 'EventRelayerGroup' => static function ( MediaWikiServices $services ) : EventRelayerGroup {
return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
},
- 'ExternalStoreAccess' => function ( MediaWikiServices $services ) : ExternalStoreAccess {
+ 'ExternalStoreAccess' => static function ( MediaWikiServices $services ) : ExternalStoreAccess {
return new ExternalStoreAccess(
$services->getExternalStoreFactory(),
LoggerFactory::getInstance( 'ExternalStore' )
);
},
- 'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
+ 'ExternalStoreFactory' => static function ( MediaWikiServices $services ) : ExternalStoreFactory {
$config = $services->getMainConfig();
$writeStores = $config->get( 'DefaultExternalStore' );
@@ -439,7 +439,7 @@ return [
);
},
- 'FileBackendGroup' => function ( MediaWikiServices $services ) : FileBackendGroup {
+ 'FileBackendGroup' => static function ( MediaWikiServices $services ) : FileBackendGroup {
$mainConfig = $services->getMainConfig();
$ld = WikiMap::getCurrentWikiDbDomain();
@@ -474,7 +474,7 @@ return [
);
},
- 'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
+ 'GenderCache' => static function ( MediaWikiServices $services ) : GenderCache {
$nsInfo = $services->getNamespaceInfo();
// Database layer may be disabled, so processing without database connection
$dbLoadBalancer = $services->isServiceDisabled( 'DBLoadBalancer' )
@@ -483,7 +483,7 @@ return [
return new GenderCache( $nsInfo, $dbLoadBalancer, $services->get( '_DefaultOptionsLookup' ) );
},
- 'GlobalIdGenerator' => function ( MediaWikiServices $services ) : GlobalIdGenerator {
+ 'GlobalIdGenerator' => static function ( MediaWikiServices $services ) : GlobalIdGenerator {
$mainConfig = $services->getMainConfig();
return new GlobalIdGenerator(
@@ -494,19 +494,19 @@ return [
$mainConfig->get( 'CommandLineMode' )
? new EmptyBagOStuff()
: $services->getLocalServerObjectCache(),
- function ( $command ) {
+ static function ( $command ) {
return wfShellExec( $command );
}
);
},
- 'GroupPermissionsLookup' => function ( MediaWikiServices $services ) : GroupPermissionsLookup {
+ 'GroupPermissionsLookup' => static function ( MediaWikiServices $services ) : GroupPermissionsLookup {
return new GroupPermissionsLookup(
new ServiceOptions( GroupPermissionsLookup::CONSTRUCTOR_OPTIONS, $services->getMainConfig() )
);
},
- 'HookContainer' => function ( MediaWikiServices $services ) : HookContainer {
+ 'HookContainer' => static function ( MediaWikiServices $services ) : HookContainer {
$extRegistry = ExtensionRegistry::getInstance();
$extDeprecatedHooks = $extRegistry->getAttribute( 'DeprecatedHooks' );
$deprecatedHooks = new DeprecatedHooks( $extDeprecatedHooks );
@@ -517,7 +517,7 @@ return [
);
},
- 'HtmlCacheUpdater' => function ( MediaWikiServices $services ) : HtmlCacheUpdater {
+ 'HtmlCacheUpdater' => static function ( MediaWikiServices $services ) : HtmlCacheUpdater {
$config = $services->getMainConfig();
return new HtmlCacheUpdater(
@@ -529,7 +529,7 @@ return [
},
'HttpRequestFactory' =>
- function ( MediaWikiServices $services ) : HttpRequestFactory {
+ static function ( MediaWikiServices $services ) : HttpRequestFactory {
return new HttpRequestFactory(
new ServiceOptions(
HttpRequestFactory::CONSTRUCTOR_OPTIONS,
@@ -539,7 +539,7 @@ return [
);
},
- 'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
+ 'InterwikiLookup' => static function ( MediaWikiServices $services ) : InterwikiLookup {
$config = $services->getMainConfig();
return new ClassicInterwikiLookup(
$services->getContentLanguage(),
@@ -552,7 +552,7 @@ return [
);
},
- 'JobRunner' => function ( MediaWikiServices $services ) : JobRunner {
+ 'JobRunner' => static function ( MediaWikiServices $services ) : JobRunner {
return new JobRunner(
new ServiceOptions( JobRunner::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getDBLoadBalancerFactory(),
@@ -564,11 +564,11 @@ return [
);
},
- 'JsonCodec' => function ( MediaWikiServices $services ) : JsonCodec {
+ 'JsonCodec' => static function ( MediaWikiServices $services ) : JsonCodec {
return new JsonCodec();
},
- 'LanguageConverterFactory' => function ( MediaWikiServices $services ) : LanguageConverterFactory {
+ 'LanguageConverterFactory' => static function ( MediaWikiServices $services ) : LanguageConverterFactory {
$usePigLatinVariant = $services->getMainConfig()->get( 'UsePigLatinVariant' );
$isConversionDisabled = $services->getMainConfig()->get( 'DisableLangConversion' );
$isTitleConversionDisabled = $services->getMainConfig()->get( 'DisableTitleConversion' );
@@ -576,13 +576,13 @@ return [
$usePigLatinVariant,
$isConversionDisabled,
$isTitleConversionDisabled,
- function () use ( $services ) {
+ static function () use ( $services ) {
return $services->getContentLanguage();
}
);
},
- 'LanguageFactory' => function ( MediaWikiServices $services ) : LanguageFactory {
+ 'LanguageFactory' => static function ( MediaWikiServices $services ) : LanguageFactory {
return new LanguageFactory(
new ServiceOptions( LanguageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getLocalisationCache(),
@@ -593,7 +593,7 @@ return [
);
},
- 'LanguageFallback' => function ( MediaWikiServices $services ) : LanguageFallback {
+ 'LanguageFallback' => static function ( MediaWikiServices $services ) : LanguageFallback {
return new LanguageFallback(
$services->getMainConfig()->get( 'LanguageCode' ),
$services->getLocalisationCache(),
@@ -601,7 +601,7 @@ return [
);
},
- 'LanguageNameUtils' => function ( MediaWikiServices $services ) : LanguageNameUtils {
+ 'LanguageNameUtils' => static function ( MediaWikiServices $services ) : LanguageNameUtils {
return new LanguageNameUtils(
new ServiceOptions(
LanguageNameUtils::CONSTRUCTOR_OPTIONS,
@@ -611,7 +611,7 @@ return [
);
},
- 'LinkBatchFactory' => function ( MediaWikiServices $services ) : LinkBatchFactory {
+ 'LinkBatchFactory' => static function ( MediaWikiServices $services ) : LinkBatchFactory {
return new LinkBatchFactory(
$services->getLinkCache(),
$services->getTitleFormatter(),
@@ -621,7 +621,7 @@ return [
);
},
- 'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
+ 'LinkCache' => static function ( MediaWikiServices $services ) : LinkCache {
// Database layer may be disabled, so processing without database connection
$dbLoadBalancer = $services->isServiceDisabled( 'DBLoadBalancer' )
? null
@@ -634,7 +634,7 @@ return [
);
},
- 'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
+ 'LinkRenderer' => static function ( MediaWikiServices $services ) : LinkRenderer {
if ( defined( 'MW_NO_SESSION' ) ) {
return $services->getLinkRendererFactory()->create();
} else {
@@ -646,7 +646,7 @@ return [
}
},
- 'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
+ 'LinkRendererFactory' => static function ( MediaWikiServices $services ) : LinkRendererFactory {
return new LinkRendererFactory(
$services->getTitleFormatter(),
$services->getLinkCache(),
@@ -656,7 +656,7 @@ return [
);
},
- 'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache {
+ 'LocalisationCache' => static function ( MediaWikiServices $services ) : LocalisationCache {
$conf = $services->getMainConfig()->get( 'LocalisationCacheConf' );
$logger = LoggerFactory::getInstance( 'localisation' );
@@ -680,7 +680,7 @@ return [
),
$store,
$logger,
- [ function () use ( $services ) {
+ [ static function () use ( $services ) {
// NOTE: Make sure we use the same cache object that is assigned in the
// constructor of the MessageBlobStore class used by ResourceLoader.
// T231866: Avoid circular dependency via ResourceLoader.
@@ -691,11 +691,11 @@ return [
);
},
- 'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
+ 'LocalServerObjectCache' => static function ( MediaWikiServices $services ) : BagOStuff {
return ObjectCache::makeLocalServerCache();
},
- 'LockManagerGroupFactory' => function ( MediaWikiServices $services ) : LockManagerGroupFactory {
+ 'LockManagerGroupFactory' => static function ( MediaWikiServices $services ) : LockManagerGroupFactory {
return new LockManagerGroupFactory(
WikiMap::getCurrentWikiDbDomain()->getId(),
$services->getMainConfig()->get( 'LockManagers' ),
@@ -703,19 +703,19 @@ return [
);
},
- 'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
+ 'MagicWordFactory' => static function ( MediaWikiServices $services ) : MagicWordFactory {
return new MagicWordFactory(
$services->getContentLanguage(),
$services->getHookContainer()
);
},
- 'MainConfig' => function ( MediaWikiServices $services ) : Config {
+ 'MainConfig' => static function ( MediaWikiServices $services ) : Config {
// Use the 'main' config from the ConfigFactory service.
return $services->getConfigFactory()->makeConfig( 'main' );
},
- 'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
+ 'MainObjectStash' => static function ( MediaWikiServices $services ) : BagOStuff {
$mainConfig = $services->getMainConfig();
$id = $mainConfig->get( 'MainStash' );
@@ -735,7 +735,7 @@ return [
return $store;
},
- 'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
+ 'MainWANObjectCache' => static function ( MediaWikiServices $services ) : WANObjectCache {
$mainConfig = $services->getMainConfig();
$wanId = $mainConfig->get( 'MainWANCache' );
@@ -780,17 +780,17 @@ return [
return $instance;
},
- 'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
+ 'MediaHandlerFactory' => static function ( MediaWikiServices $services ) : MediaHandlerFactory {
return new MediaHandlerFactory(
$services->getMainConfig()->get( 'MediaHandlers' )
);
},
- 'MergeHistoryFactory' => function ( MediaWikiServices $services ) : MergeHistoryFactory {
+ 'MergeHistoryFactory' => static function ( MediaWikiServices $services ) : MergeHistoryFactory {
return $services->getService( '_PageCommandFactory' );
},
- 'MessageCache' => function ( MediaWikiServices $services ) : MessageCache {
+ 'MessageCache' => static function ( MediaWikiServices $services ) : MessageCache {
$mainConfig = $services->getMainConfig();
$clusterCache = ObjectCache::getInstance( $mainConfig->get( 'MessageCacheType' ) );
$srvCache = $mainConfig->get( 'UseLocalMessageCache' )
@@ -818,11 +818,11 @@ return [
);
},
- 'MessageFormatterFactory' => function ( MediaWikiServices $services ) : IMessageFormatterFactory {
+ 'MessageFormatterFactory' => static function ( MediaWikiServices $services ) : IMessageFormatterFactory {
return new MessageFormatterFactory();
},
- 'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
+ 'MimeAnalyzer' => static function ( MediaWikiServices $services ) : MimeAnalyzer {
$logger = LoggerFactory::getInstance( 'Mime' );
$mainConfig = $services->getMainConfig();
$hookRunner = new HookRunner( $services->getHookContainer() );
@@ -831,7 +831,7 @@ return [
'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
'guessCallback' =>
- function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime )
+ static function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime )
use ( $logger, $hookRunner ) {
// Also test DjVu
$deja = new DjVuImage( $file );
@@ -845,11 +845,11 @@ return [
$hookRunner->onMimeMagicGuessFromContent(
$mimeAnalyzer, $head, $tail, $file, $mime );
},
- 'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) use ( $hookRunner ) {
+ 'extCallback' => static function ( $mimeAnalyzer, $ext, &$mime ) use ( $hookRunner ) {
// Media handling extensions can improve the MIME detected
$hookRunner->onMimeMagicImproveFromExtension( $mimeAnalyzer, $ext, $mime );
},
- 'initCallback' => function ( $mimeAnalyzer ) use ( $hookRunner ) {
+ 'initCallback' => static function ( $mimeAnalyzer ) use ( $hookRunner ) {
// Allow media handling extensions adding MIME-types and MIME-info
$hookRunner->onMimeMagicInit( $mimeAnalyzer );
},
@@ -867,7 +867,7 @@ return [
$detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
if ( $detectorCmd ) {
$factory = $services->getShellCommandFactory();
- $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
+ $params['detectCallback'] = static function ( $file ) use ( $detectorCmd, $factory ) {
$result = $factory->create()
// $wgMimeDetectorCommand can contain commands with parameters
->unsafeParams( $detectorCmd )
@@ -880,18 +880,18 @@ return [
return new MimeAnalyzer( $params );
},
- 'MovePageFactory' => function ( MediaWikiServices $services ) : MovePageFactory {
+ 'MovePageFactory' => static function ( MediaWikiServices $services ) : MovePageFactory {
return $services->getService( '_PageCommandFactory' );
},
- 'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
+ 'NamespaceInfo' => static function ( MediaWikiServices $services ) : NamespaceInfo {
return new NamespaceInfo(
new ServiceOptions( NamespaceInfo::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getHookContainer()
);
},
- 'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
+ 'NameTableStoreFactory' => static function ( MediaWikiServices $services ) : NameTableStoreFactory {
return new NameTableStoreFactory(
$services->getDBLoadBalancerFactory(),
$services->getMainWANObjectCache(),
@@ -899,11 +899,11 @@ return [
);
},
- 'ObjectFactory' => function ( MediaWikiServices $services ) : ObjectFactory {
+ 'ObjectFactory' => static function ( MediaWikiServices $services ) : ObjectFactory {
return new ObjectFactory( $services );
},
- 'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
+ 'OldRevisionImporter' => static function ( MediaWikiServices $services ) : OldRevisionImporter {
return new ImportableOldRevisionImporter(
true,
LoggerFactory::getInstance( 'OldRevisionImporter' ),
@@ -914,7 +914,7 @@ return [
);
},
- 'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
+ 'PageEditStash' => static function ( MediaWikiServices $services ) : PageEditStash {
$config = $services->getMainConfig();
return new PageEditStash(
@@ -929,23 +929,23 @@ return [
);
},
- 'PageProps' => function ( MediaWikiServices $services ) : PageProps {
+ 'PageProps' => static function ( MediaWikiServices $services ) : PageProps {
return new PageProps(
$services->getLinkBatchFactory(),
$services->getDBLoadBalancer()
);
},
- 'Parser' => function ( MediaWikiServices $services ) : Parser {
+ 'Parser' => static function ( MediaWikiServices $services ) : Parser {
return $services->getParserFactory()->create();
},
- 'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
+ 'ParserCache' => static function ( MediaWikiServices $services ) : ParserCache {
return $services->getParserCacheFactory()
->getParserCache( ParserCacheFactory::DEFAULT_NAME );
},
- 'ParserCacheFactory' => function ( MediaWikiServices $services ) : ParserCacheFactory {
+ 'ParserCacheFactory' => static function ( MediaWikiServices $services ) : ParserCacheFactory {
$config = $services->getMainConfig();
$cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
$wanCache = $services->getMainWANObjectCache();
@@ -963,7 +963,7 @@ return [
);
},
- 'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
+ 'ParserFactory' => static function ( MediaWikiServices $services ) : ParserFactory {
$options = new ServiceOptions( Parser::CONSTRUCTOR_OPTIONS,
// 'class'
// Note that this value is ignored by ParserFactory and is always
@@ -992,7 +992,7 @@ return [
);
},
- 'ParserOutputAccess' => function ( MediaWikiServices $services ) : ParserOutputAccess {
+ 'ParserOutputAccess' => static function ( MediaWikiServices $services ) : ParserOutputAccess {
return new ParserOutputAccess(
$services->getParserCache(),
$services->getParserCacheFactory()->getRevisionOutputCache( 'rcache' ),
@@ -1003,7 +1003,7 @@ return [
);
},
- 'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
+ 'PasswordFactory' => static function ( MediaWikiServices $services ) : PasswordFactory {
$config = $services->getMainConfig();
return new PasswordFactory(
$config->get( 'PasswordConfig' ),
@@ -1011,7 +1011,7 @@ return [
);
},
- 'PasswordReset' => function ( MediaWikiServices $services ) : PasswordReset {
+ 'PasswordReset' => static function ( MediaWikiServices $services ) : PasswordReset {
$options = new ServiceOptions( PasswordReset::CONSTRUCTOR_OPTIONS, $services->getMainConfig() );
return new PasswordReset(
$options,
@@ -1027,7 +1027,7 @@ return [
},
'PerDbNameStatsdDataFactory' =>
- function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
+ static function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
$config = $services->getMainConfig();
$wiki = $config->get( 'DBname' );
return new PrefixingStatsdDataFactoryProxy(
@@ -1036,7 +1036,7 @@ return [
);
},
- 'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
+ 'PermissionManager' => static function ( MediaWikiServices $services ) : PermissionManager {
return new PermissionManager(
new ServiceOptions(
PermissionManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
@@ -1052,7 +1052,7 @@ return [
);
},
- 'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
+ 'PreferencesFactory' => static function ( MediaWikiServices $services ) : PreferencesFactory {
$factory = new DefaultPreferencesFactory(
new ServiceOptions(
DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
@@ -1070,7 +1070,7 @@ return [
return $factory;
},
- 'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
+ 'ProxyLookup' => static function ( MediaWikiServices $services ) : ProxyLookup {
$mainConfig = $services->getMainConfig();
return new ProxyLookup(
$mainConfig->get( 'CdnServers' ),
@@ -1078,14 +1078,14 @@ return [
);
},
- 'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
+ 'ReadOnlyMode' => static function ( MediaWikiServices $services ) : ReadOnlyMode {
return new ReadOnlyMode(
$services->getConfiguredReadOnlyMode(),
$services->getDBLoadBalancer()
);
},
- 'RepoGroup' => function ( MediaWikiServices $services ) : RepoGroup {
+ 'RepoGroup' => static function ( MediaWikiServices $services ) : RepoGroup {
$config = $services->getMainConfig();
return new RepoGroup(
$config->get( 'LocalFileRepo' ),
@@ -1094,7 +1094,7 @@ return [
);
},
- 'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
+ 'ResourceLoader' => static function ( MediaWikiServices $services ) : ResourceLoader {
// @todo This should not take a Config object, but it's not so easy to remove because it
// exposes it in a getter, which is actually used.
global $IP;
@@ -1154,7 +1154,7 @@ return [
return $rl;
},
- 'RevertedTagUpdateManager' => function ( MediaWikiServices $services ) : RevertedTagUpdateManager {
+ 'RevertedTagUpdateManager' => static function ( MediaWikiServices $services ) : RevertedTagUpdateManager {
$editResultCache = new EditResultCache(
$services->getMainObjectStash(),
$services->getDBLoadBalancer(),
@@ -1171,15 +1171,15 @@ return [
);
},
- 'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
+ 'RevisionFactory' => static function ( MediaWikiServices $services ) : RevisionFactory {
return $services->getRevisionStore();
},
- 'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
+ 'RevisionLookup' => static function ( MediaWikiServices $services ) : RevisionLookup {
return $services->getRevisionStore();
},
- 'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
+ 'RevisionRenderer' => static function ( MediaWikiServices $services ) : RevisionRenderer {
$renderer = new RevisionRenderer(
$services->getDBLoadBalancer(),
$services->getSlotRoleRegistry()
@@ -1189,11 +1189,11 @@ return [
return $renderer;
},
- 'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
+ 'RevisionStore' => static function ( MediaWikiServices $services ) : RevisionStore {
return $services->getRevisionStoreFactory()->getRevisionStore();
},
- 'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
+ 'RevisionStoreFactory' => static function ( MediaWikiServices $services ) : RevisionStoreFactory {
$config = $services->getMainConfig();
if ( $config->has( 'MultiContentRevisionSchemaMigrationStage' ) ) {
@@ -1221,7 +1221,7 @@ return [
return $store;
},
- 'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
+ 'SearchEngineConfig' => static function ( MediaWikiServices $services ) : SearchEngineConfig {
// @todo This should not take a Config object, but it's not so easy to remove because it
// exposes it in a getter, which is actually used.
return new SearchEngineConfig(
@@ -1232,14 +1232,14 @@ return [
);
},
- 'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
+ 'SearchEngineFactory' => static function ( MediaWikiServices $services ) : SearchEngineFactory {
return new SearchEngineFactory(
$services->getSearchEngineConfig(),
$services->getHookContainer()
);
},
- 'ShellboxClientFactory' => function ( MediaWikiServices $services ) : ShellboxClientFactory {
+ 'ShellboxClientFactory' => static function ( MediaWikiServices $services ) : ShellboxClientFactory {
return new ShellboxClientFactory(
$services->getHttpRequestFactory(),
$services->getMainConfig()->get( 'ShellboxUrl' ),
@@ -1247,7 +1247,7 @@ return [
);
},
- 'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
+ 'ShellCommandFactory' => static function ( MediaWikiServices $services ) : CommandFactory {
$config = $services->getMainConfig();
$limits = [
@@ -1267,14 +1267,14 @@ return [
return $factory;
},
- 'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
+ 'SiteLookup' => static function ( MediaWikiServices $services ) : SiteLookup {
// Use SiteStore as the SiteLookup as well. This was originally separated
// to allow for a cacheable read-only interface, but this was never used.
// SiteStore has caching (see below).
return $services->getSiteStore();
},
- 'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
+ 'SiteStore' => static function ( MediaWikiServices $services ) : SiteStore {
$rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
$cache = $services->getLocalServerObjectCache();
@@ -1286,7 +1286,7 @@ return [
},
/** @suppress PhanTypeInvalidCallableArrayKey */
- 'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
+ 'SkinFactory' => static function ( MediaWikiServices $services ) : SkinFactory {
$factory = new SkinFactory(
$services->getObjectFactory(),
(array)$services->getMainConfig()->get( 'SkipSkins' )
@@ -1334,7 +1334,7 @@ return [
return $factory;
},
- 'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
+ 'SlotRoleRegistry' => static function ( MediaWikiServices $services ) : SlotRoleRegistry {
$config = $services->getMainConfig();
$contentHandlerFactory = $services->getContentHandlerFactory();
@@ -1342,7 +1342,7 @@ return [
$services->getSlotRoleStore()
);
- $registry->defineRole( 'main', function () use ( $config, $contentHandlerFactory ) {
+ $registry->defineRole( 'main', static function () use ( $config, $contentHandlerFactory ) {
return new MainSlotRoleHandler(
$config->get( 'NamespaceContentModels' ),
$contentHandlerFactory
@@ -1352,18 +1352,18 @@ return [
return $registry;
},
- 'SlotRoleStore' => function ( MediaWikiServices $services ) : NameTableStore {
+ 'SlotRoleStore' => static function ( MediaWikiServices $services ) : NameTableStore {
return $services->getNameTableStoreFactory()->getSlotRoles();
},
- 'SpamChecker' => function ( MediaWikiServices $services ) : SpamChecker {
+ 'SpamChecker' => static function ( MediaWikiServices $services ) : SpamChecker {
return new SpamChecker(
(array)$services->getMainConfig()->get( 'SpamRegex' ),
(array)$services->getMainConfig()->get( 'SummarySpamRegex' )
);
},
- 'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
+ 'SpecialPageFactory' => static function ( MediaWikiServices $services ) : SpecialPageFactory {
return new SpecialPageFactory(
new ServiceOptions(
SpecialPageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
@@ -1373,13 +1373,13 @@ return [
);
},
- 'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
+ 'StatsdDataFactory' => static function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
return new BufferingStatsdDataFactory(
rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
);
},
- 'TalkPageNotificationManager' => function (
+ 'TalkPageNotificationManager' => static function (
MediaWikiServices $services
) : TalkPageNotificationManager {
return new TalkPageNotificationManager(
@@ -1392,34 +1392,34 @@ return [
);
},
- 'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory {
+ 'TempFSFileFactory' => static function ( MediaWikiServices $services ) : TempFSFileFactory {
return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) );
},
- 'TitleFactory' => function ( MediaWikiServices $services ) : TitleFactory {
+ 'TitleFactory' => static function ( MediaWikiServices $services ) : TitleFactory {
return new TitleFactory();
},
- 'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
+ 'TitleFormatter' => static function ( MediaWikiServices $services ) : TitleFormatter {
return $services->getService( '_MediaWikiTitleCodec' );
},
- 'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
+ 'TitleParser' => static function ( MediaWikiServices $services ) : TitleParser {
return $services->getService( '_MediaWikiTitleCodec' );
},
- 'UnblockUserFactory' => function ( MediaWikiServices $services ) : UnblockUserFactory {
+ 'UnblockUserFactory' => static function ( MediaWikiServices $services ) : UnblockUserFactory {
return $services->getService( '_UserBlockCommandFactory' );
},
- 'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
+ 'UploadRevisionImporter' => static function ( MediaWikiServices $services ) : UploadRevisionImporter {
return new ImportableUploadRevisionImporter(
$services->getMainConfig()->get( 'EnableUploads' ),
LoggerFactory::getInstance( 'UploadRevisionImporter' )
);
},
- 'UserCache' => function ( MediaWikiServices $services ) : UserCache {
+ 'UserCache' => static function ( MediaWikiServices $services ) : UserCache {
return new UserCache(
LoggerFactory::getInstance( 'UserCache' ),
$services->getDBLoadBalancer(),
@@ -1427,7 +1427,7 @@ return [
);
},
- 'UserEditTracker' => function ( MediaWikiServices $services ) : UserEditTracker {
+ 'UserEditTracker' => static function ( MediaWikiServices $services ) : UserEditTracker {
$jobQueueGroup = JobQueueGroup::singleton();
return new UserEditTracker(
@@ -1437,18 +1437,18 @@ return [
);
},
- 'UserFactory' => function ( MediaWikiServices $services ) : UserFactory {
+ 'UserFactory' => static function ( MediaWikiServices $services ) : UserFactory {
return new UserFactory(
$services->getDBLoadBalancer(),
$services->getUserNameUtils()
);
},
- 'UserGroupManager' => function ( MediaWikiServices $services ) : UserGroupManager {
+ 'UserGroupManager' => static function ( MediaWikiServices $services ) : UserGroupManager {
return $services->getUserGroupManagerFactory()->getUserGroupManager();
},
- 'UserGroupManagerFactory' => function ( MediaWikiServices $services ) : UserGroupManagerFactory {
+ 'UserGroupManagerFactory' => static function ( MediaWikiServices $services ) : UserGroupManagerFactory {
return new UserGroupManagerFactory(
new ServiceOptions(
UserGroupManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
@@ -1459,14 +1459,14 @@ return [
$services->getUserEditTracker(),
$services->getGroupPermissionsLookup(),
LoggerFactory::getInstance( 'UserGroupManager' ),
- [ function ( UserIdentity $user ) use ( $services ) {
+ [ static function ( UserIdentity $user ) use ( $services ) {
$services->getPermissionManager()->invalidateUsersRightsCache( $user );
$services->getUserFactory()->newFromUserIdentity( $user )->invalidateCache();
} ]
);
},
- 'UserNamePrefixSearch' => function ( MediaWikiServices $services ) : UserNamePrefixSearch {
+ 'UserNamePrefixSearch' => static function ( MediaWikiServices $services ) : UserNamePrefixSearch {
return new UserNamePrefixSearch(
$services->getDBLoadBalancer(),
$services->getPermissionManager(),
@@ -1474,7 +1474,7 @@ return [
);
},
- 'UserNameUtils' => function ( MediaWikiServices $services ) : UserNameUtils {
+ 'UserNameUtils' => static function ( MediaWikiServices $services ) : UserNameUtils {
$messageFormatterFactory = new MessageFormatterFactory( Message::FORMAT_PLAIN );
return new UserNameUtils(
new ServiceOptions(
@@ -1490,11 +1490,11 @@ return [
);
},
- 'UserOptionsLookup' => function ( MediaWikiServices $services ) : UserOptionsLookup {
+ 'UserOptionsLookup' => static function ( MediaWikiServices $services ) : UserOptionsLookup {
return $services->getUserOptionsManager();
},
- 'UserOptionsManager' => function ( MediaWikiServices $services ) : UserOptionsManager {
+ 'UserOptionsManager' => static function ( MediaWikiServices $services ) : UserOptionsManager {
return new UserOptionsManager(
new ServiceOptions( UserOptionsManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->get( '_DefaultOptionsLookup' ),
@@ -1506,7 +1506,7 @@ return [
},
'VirtualRESTServiceClient' =>
- function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
+ static function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
$config = $services->getMainConfig()->get( 'VirtualRestConfig' );
$vrsClient = new VirtualRESTServiceClient(
@@ -1524,7 +1524,7 @@ return [
},
'WatchedItemQueryService' =>
- function ( MediaWikiServices $services ) : WatchedItemQueryService {
+ static function ( MediaWikiServices $services ) : WatchedItemQueryService {
return new WatchedItemQueryService(
$services->getDBLoadBalancer(),
$services->getCommentStore(),
@@ -1537,7 +1537,7 @@ return [
);
},
- 'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
+ 'WatchedItemStore' => static function ( MediaWikiServices $services ) : WatchedItemStore {
$store = new WatchedItemStore(
new ServiceOptions( WatchedItemStore::CONSTRUCTOR_OPTIONS,
$services->getMainConfig() ),
@@ -1562,7 +1562,7 @@ return [
},
'WatchlistNotificationManager' =>
- function ( MediaWikiServices $services ) : WatchlistNotificationManager {
+ static function ( MediaWikiServices $services ) : WatchlistNotificationManager {
return new WatchlistNotificationManager(
new ServiceOptions(
WatchlistNotificationManager::CONSTRUCTOR_OPTIONS,
@@ -1577,7 +1577,7 @@ return [
);
},
- 'WikiPageFactory' => function ( MediaWikiServices $services ) : WikiPageFactory {
+ 'WikiPageFactory' => static function ( MediaWikiServices $services ) : WikiPageFactory {
return new WikiPageFactory(
$services->getTitleFactory(),
new HookRunner( $services->getHookContainer() ),
@@ -1586,7 +1586,7 @@ return [
},
'WikiRevisionOldRevisionImporterNoUpdates' =>
- function ( MediaWikiServices $services ) : ImportableOldRevisionImporter {
+ static function ( MediaWikiServices $services ) : ImportableOldRevisionImporter {
return new ImportableOldRevisionImporter(
false,
LoggerFactory::getInstance( 'OldRevisionImporter' ),
@@ -1597,7 +1597,7 @@ return [
);
},
- '_DefaultOptionsLookup' => function ( MediaWikiServices $services ) : DefaultOptionsLookup {
+ '_DefaultOptionsLookup' => static function ( MediaWikiServices $services ) : DefaultOptionsLookup {
return new DefaultOptionsLookup(
new ServiceOptions( DefaultOptionsLookup::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getContentLanguage(),
@@ -1605,7 +1605,7 @@ return [
);
},
- '_EditConstraintFactory' => function ( MediaWikiServices $services ) : EditConstraintFactory {
+ '_EditConstraintFactory' => static function ( MediaWikiServices $services ) : EditConstraintFactory {
// This service is internal and currently only exists because a significant number
// of dependencies will be needed by different constraints. It is not part of
// the public interface and has no corresponding method in MediaWikiServices
@@ -1629,7 +1629,7 @@ return [
);
},
- '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
+ '_MediaWikiTitleCodec' => static function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
return new MediaWikiTitleCodec(
$services->getContentLanguage(),
$services->getGenderCache(),
@@ -1639,7 +1639,7 @@ return [
);
},
- '_PageCommandFactory' => function ( MediaWikiServices $services ) : PageCommandFactory {
+ '_PageCommandFactory' => static function ( MediaWikiServices $services ) : PageCommandFactory {
return new PageCommandFactory(
new ServiceOptions( PageCommandFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getDBLoadBalancer(),
@@ -1655,11 +1655,11 @@ return [
);
},
- '_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
+ '_SqlBlobStore' => static function ( MediaWikiServices $services ) : SqlBlobStore {
return $services->getBlobStoreFactory()->newSqlBlobStore();
},
- '_UserBlockCommandFactory' => function ( MediaWikiServices $services ) : UserBlockCommandFactory {
+ '_UserBlockCommandFactory' => static function ( MediaWikiServices $services ) : UserBlockCommandFactory {
return new UserBlockCommandFactory(
new ServiceOptions( UserBlockCommandFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
$services->getHookContainer(),
diff --git a/includes/Setup.php b/includes/Setup.php
index 15aaf9676fe3..1deb16c7c039 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -674,7 +674,7 @@ if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) {
}
// Useful debug output
-( function () {
+( static function () {
global $wgCommandLineMode, $wgRequest;
$logger = LoggerFactory::getInstance( 'wfDebug' );
if ( $wgCommandLineMode ) {
@@ -792,7 +792,7 @@ $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
* @var Parser $wgParser
* @deprecated since 1.32, use MediaWikiServices::getInstance()->getParser() instead
*/
-$wgParser = new DeprecatedGlobal( 'wgParser', function () {
+$wgParser = new DeprecatedGlobal( 'wgParser', static function () {
return MediaWikiServices::getInstance()->getParser();
}, '1.32' );
diff --git a/includes/SiteStats.php b/includes/SiteStats.php
index b7bf57b48242..396ab8b403ca 100644
--- a/includes/SiteStats.php
+++ b/includes/SiteStats.php
@@ -182,7 +182,7 @@ class SiteStats {
return $cache->getWithSetCallback(
$cache->makeKey( 'SiteStats', 'jobscount' ),
$cache::TTL_MINUTE,
- function ( $oldValue, &$ttl, array &$setOpts ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) {
try{
$jobs = array_sum( JobQueueGroup::singleton()->getQueueSizes() );
} catch ( JobQueueError $e ) {
diff --git a/includes/Status.php b/includes/Status.php
index 87e2f2b6cbbd..e5fbc81f50af 100644
--- a/includes/Status.php
+++ b/includes/Status.php
@@ -295,12 +295,12 @@ class Status extends StatusValue {
if ( isset( $error['message'] ) && $error['message'] instanceof Message ) {
$msg = $error['message'];
} elseif ( isset( $error['message'] ) && isset( $error['params'] ) ) {
- $msg = $this->msg( $error['message'], array_map( function ( $param ) {
+ $msg = $this->msg( $error['message'], array_map( static function ( $param ) {
return is_string( $param ) ? wfEscapeWikiText( $param ) : $param;
}, $this->cleanParams( $error['params'] ) ) );
} else {
$msgName = array_shift( $error );
- $msg = $this->msg( $msgName, array_map( function ( $param ) {
+ $msg = $this->msg( $msgName, array_map( static function ( $param ) {
return is_string( $param ) ? wfEscapeWikiText( $param ) : $param;
}, $this->cleanParams( $error ) ) );
}
diff --git a/includes/Storage/DerivedPageDataUpdater.php b/includes/Storage/DerivedPageDataUpdater.php
index 5675e2ecb780..d331dcba7682 100644
--- a/includes/Storage/DerivedPageDataUpdater.php
+++ b/includes/Storage/DerivedPageDataUpdater.php
@@ -1395,7 +1395,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface {
);
// HACK: filter out redundant and incomplete LinksUpdates
- $legacyUpdates = array_filter( $legacyUpdates, function ( $update ) {
+ $legacyUpdates = array_filter( $legacyUpdates, static function ( $update ) {
return !( $update instanceof LinksUpdate );
} );
@@ -1430,7 +1430,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface {
$legacyUpdates = $content->getDeletionUpdates( $wikiPage );
// HACK: filter out redundant and incomplete LinksDeletionUpdate
- $legacyUpdates = array_filter( $legacyUpdates, function ( $update ) {
+ $legacyUpdates = array_filter( $legacyUpdates, static function ( $update ) {
return !( $update instanceof LinksDeletionUpdate );
} );
diff --git a/includes/Storage/NameTableStoreFactory.php b/includes/Storage/NameTableStoreFactory.php
index cac3c2a624d8..c22166e3d154 100644
--- a/includes/Storage/NameTableStoreFactory.php
+++ b/includes/Storage/NameTableStoreFactory.php
@@ -45,7 +45,7 @@ class NameTableStoreFactory {
'idField' => 'ctd_id',
'nameField' => 'ctd_name',
'normalizationCallback' => null,
- 'insertCallback' => function ( $insertFields ) {
+ 'insertCallback' => static function ( $insertFields ) {
$insertFields['ctd_user_defined'] = 0;
$insertFields['ctd_count'] = 0;
return $insertFields;
diff --git a/includes/Storage/PageEditStash.php b/includes/Storage/PageEditStash.php
index 83fb74c16289..a8ae454b2cb1 100644
--- a/includes/Storage/PageEditStash.php
+++ b/includes/Storage/PageEditStash.php
@@ -122,7 +122,7 @@ class PageEditStash {
return self::ERROR_BUSY;
}
/** @noinspection PhpUnusedLocalVariableInspection */
- $unlocker = new ScopedCallback( function () use ( $dbw, $key, $fname ) {
+ $unlocker = new ScopedCallback( static function () use ( $dbw, $key, $fname ) {
$dbw->unlock( $key, $fname );
} );
diff --git a/includes/Storage/PageUpdater.php b/includes/Storage/PageUpdater.php
index 542830c5100f..69de33aa2b0d 100644
--- a/includes/Storage/PageUpdater.php
+++ b/includes/Storage/PageUpdater.php
@@ -804,7 +804,7 @@ class PageUpdater {
}
// Promote user to any groups they meet the criteria for
- DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
$user->addAutopromoteOnceGroups( 'onEdit' );
$user->addAutopromoteOnceGroups( 'onView' ); // b/c
} );
@@ -1135,7 +1135,7 @@ class PageUpdater {
$status->value['revision-record'] = $newRevisionRecord;
// Deprecated via DeprecatablePropertyArray
- $status->value['revision'] = function () use ( $newRevisionRecord ) {
+ $status->value['revision'] = static function () use ( $newRevisionRecord ) {
return new Revision( $newRevisionRecord );
};
} else {
@@ -1300,7 +1300,7 @@ class PageUpdater {
$status->value['revision-record'] = $newRevisionRecord;
// Deprecated via DeprecatablePropertyArray
- $status->value['revision'] = function () use ( $newRevisionRecord ) {
+ $status->value['revision'] = static function () use ( $newRevisionRecord ) {
return new Revision( $newRevisionRecord );
};
diff --git a/includes/Storage/SqlBlobStore.php b/includes/Storage/SqlBlobStore.php
index f5851f05d4fc..d865cfda3218 100644
--- a/includes/Storage/SqlBlobStore.php
+++ b/includes/Storage/SqlBlobStore.php
@@ -317,7 +317,7 @@ class SqlBlobStore implements IDBAccessObject, BlobStore {
list( $blobsByAddress, $errors ) = $this->fetchBlobs( $blobAddresses, $queryFlags );
- $blobsByAddress = array_map( function ( $blob ) {
+ $blobsByAddress = array_map( static function ( $blob ) {
return $blob === false ? null : $blob;
}, $blobsByAddress );
diff --git a/includes/Title.php b/includes/Title.php
index 73c58590d964..6ba152834229 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2934,7 +2934,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
$id = $this->getArticleID( $flags );
if ( $id ) {
$fname = __METHOD__;
- $loadRestrictionsFromDb = function ( IDatabase $dbr ) use ( $fname, $id ) {
+ $loadRestrictionsFromDb = static function ( IDatabase $dbr ) use ( $fname, $id ) {
return iterator_to_array(
$dbr->select(
'page_restrictions',
@@ -2954,7 +2954,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
// Page protections always leave a new null revision
$cache->makeKey( 'page-restrictions', 'v1', $id, $this->getLatestRevID() ),
$cache::TTL_DAY,
- function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) {
+ static function ( $curValue, &$ttl, array &$setOpts ) use ( $loadRestrictionsFromDb ) {
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
@@ -3014,7 +3014,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
DeferredUpdates::addUpdate( new AtomicSectionUpdate(
wfGetDB( DB_MASTER ),
__METHOD__,
- function ( IDatabase $dbw, $fname ) {
+ static function ( IDatabase $dbw, $fname ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
$ids = $dbw->selectFieldValues(
'page_restrictions',
@@ -3032,7 +3032,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
DeferredUpdates::addUpdate( new AtomicSectionUpdate(
wfGetDB( DB_MASTER ),
__METHOD__,
- function ( IDatabase $dbw, $fname ) {
+ static function ( IDatabase $dbw, $fname ) {
$dbw->delete(
'protected_titles',
[ 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ],
@@ -3902,7 +3902,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
$limit,
$options
);
- return array_map( function ( UserIdentity $user ) {
+ return array_map( static function ( UserIdentity $user ) {
return $user->getName();
}, $users );
} catch ( InvalidArgumentException $e ) {
diff --git a/includes/WebResponse.php b/includes/WebResponse.php
index ab878e9d823e..113e0c819ff7 100644
--- a/includes/WebResponse.php
+++ b/includes/WebResponse.php
@@ -143,7 +143,7 @@ class WebResponse {
global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
global $wgUseSameSiteLegacyCookies;
- $options = array_filter( $options, function ( $a ) {
+ $options = array_filter( $options, static function ( $a ) {
return $a !== null;
} ) + [
'prefix' => $wgCookiePrefix,
diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php
index 2867c6f7f847..c83b6a3311a6 100644
--- a/includes/actions/InfoAction.php
+++ b/includes/actions/InfoAction.php
@@ -740,7 +740,7 @@ class InfoAction extends FormlessAction {
return $cache->getWithSetCallback(
self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
WANObjectCache::TTL_WEEK,
- function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname, $services ) {
+ static function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname, $services ) {
$title = $page->getTitle();
$id = $title->getArticleID();
diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php
index 37b98d0e43e5..d0cf9adcc618 100644
--- a/includes/actions/RollbackAction.php
+++ b/includes/actions/RollbackAction.php
@@ -225,7 +225,7 @@ class RollbackAction extends FormAction {
$trxLimits = $this->context->getConfig()->get( 'TrxProfilerLimits' );
$trxProfiler = Profiler::instance()->getTransactionProfiler();
$trxProfiler->redefineExpectations( $trxLimits['POST'], $fname );
- DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits, $fname
+ DeferredUpdates::addCallableUpdate( static function () use ( $trxProfiler, $trxLimits, $fname
) {
$trxProfiler->redefineExpectations( $trxLimits['PostSend-POST'], $fname );
} );
diff --git a/includes/api/ApiAuthManagerHelper.php b/includes/api/ApiAuthManagerHelper.php
index 141378634421..594b070766e4 100644
--- a/includes/api/ApiAuthManagerHelper.php
+++ b/includes/api/ApiAuthManagerHelper.php
@@ -129,7 +129,7 @@ class ApiAuthManagerHelper {
public static function blacklistAuthenticationRequests( array $reqs, array $blacklist ) {
if ( $blacklist ) {
$blacklist = array_flip( $blacklist );
- $reqs = array_filter( $reqs, function ( $req ) use ( $blacklist ) {
+ $reqs = array_filter( $reqs, static function ( $req ) use ( $blacklist ) {
return !isset( $blacklist[get_class( $req )] );
} );
}
@@ -156,7 +156,7 @@ class ApiAuthManagerHelper {
if ( $wantedRequests !== null ) {
$reqs = array_filter(
$reqs,
- function ( AuthenticationRequest $req ) use ( $wantedRequests ) {
+ static function ( AuthenticationRequest $req ) use ( $wantedRequests ) {
return isset( $wantedRequests[$req->getUniqueId()] );
}
);
@@ -168,7 +168,7 @@ class ApiAuthManagerHelper {
foreach ( $reqs as $req ) {
$info = (array)$req->getFieldInfo();
$fields += $info;
- $sensitive += array_filter( $info, function ( $opts ) {
+ $sensitive += array_filter( $info, static function ( $opts ) {
return !empty( $opts['sensitive'] );
} );
}
@@ -335,7 +335,7 @@ class ApiAuthManagerHelper {
$ret = array_intersect_key( $field, $copy );
if ( isset( $field['options'] ) ) {
- $ret['options'] = array_map( function ( $msg ) use ( $module ) {
+ $ret['options'] = array_map( static function ( $msg ) use ( $module ) {
return $msg->setContext( $module )->plain();
}, $field['options'] );
ApiResult::setArrayType( $ret['options'], 'assoc' );
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 41eb0d6aab38..84e64a1710b5 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -1260,7 +1260,7 @@ abstract class ApiBase extends ContextSource {
$min = min( $min, $row->min_id );
$max = max( $max, $row->max_id );
}
- return array_filter( $ids, function ( $id ) use ( $min, $max ) {
+ return array_filter( $ids, static function ( $id ) use ( $min, $max ) {
return ( is_int( $id ) && $id >= 0 || ctype_digit( $id ) )
&& $id >= $min && $id <= $max;
} );
@@ -2058,7 +2058,7 @@ abstract class ApiBase extends ContextSource {
return $value;
}
- $values = array_map( function ( $v ) {
+ $values = array_map( static function ( $v ) {
return '<kbd>' . wfEscapeWikiText( $v ) . '</kbd>';
}, $allowedValues );
$this->dieWithError( [
diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php
index a86cb07946c0..bc3eababb989 100644
--- a/includes/api/ApiBlock.php
+++ b/includes/api/ApiBlock.php
@@ -128,7 +128,7 @@ class ApiBlock extends ApiBase {
$pageRestrictions[] = PageRestriction::newFromTitle( $title );
}
- $namespaceRestrictions = array_map( function ( $id ) {
+ $namespaceRestrictions = array_map( static function ( $id ) {
return new NamespaceRestriction( 0, $id );
}, (array)$params['namespacerestrictions'] );
$restrictions = array_merge( $pageRestrictions, $namespaceRestrictions );
diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php
index 777ec1ca5bae..6f7d5ce769b5 100644
--- a/includes/api/ApiFormatXml.php
+++ b/includes/api/ApiFormatXml.php
@@ -58,7 +58,7 @@ class ApiFormatXml extends ApiFormatBase {
$result->addValue( null, 'xmlns', self::$namespace, ApiResult::NO_SIZE_CHECK );
}
$data = $result->getResultData( null, [
- 'Custom' => function ( &$data, &$metadata ) {
+ 'Custom' => static function ( &$data, &$metadata ) {
if ( isset( $metadata[ApiResult::META_TYPE] ) ) {
// We want to use non-BC for BCassoc to force outputting of _idx.
switch ( $metadata[ApiResult::META_TYPE] ) {
@@ -247,7 +247,7 @@ class ApiFormatXml extends ApiFormatBase {
return '_' . preg_replace_callback(
"/[^$nc]/uS",
- function ( $m ) {
+ static function ( $m ) {
return sprintf( '.%X.', UtfNormal\Utils::utf8ToCodepoint( $m[0] ) );
},
str_replace( '.', '.2E.', $name )
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index e79e4635a6a1..ffc6f96b7d5f 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1344,7 +1344,7 @@ class ApiMain extends ApiBase {
}
if ( $ifNoneMatch && $etag !== null ) {
$test = substr( $etag, 0, 2 ) === 'W/' ? substr( $etag, 2 ) : $etag;
- $match = array_map( function ( $s ) {
+ $match = array_map( static function ( $s ) {
return substr( $s, 0, 2 ) === 'W/' ? substr( $s, 2 ) : $s;
}, $ifNoneMatch );
$return304 = in_array( $test, $match, true );
@@ -1967,7 +1967,7 @@ class ApiMain extends ApiBase {
$rightMsg = $this->msg( $rightMsg['msg'], $rightMsg['params'] )->parse();
$help['permissions'] .= Html::rawElement( 'dd', null, $rightMsg );
- $groups = array_map( function ( $group ) {
+ $groups = array_map( static function ( $group ) {
return $group == '*' ? 'all' : $group;
}, $this->getPermissionManager()->getGroupsWithPermission( $right ) );
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index e4eb4dce1ddc..078096d64bc0 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -60,7 +60,7 @@ class ApiParse extends ApiBase {
) {
$worker = new PoolCounterWorkViaCallback( 'ApiParser', $this->getPoolKey(),
[
- 'doWork' => function () use ( $content, $title, $revId, $popts ) {
+ 'doWork' => static function () use ( $content, $title, $revId, $popts ) {
return $content->getParserOutput( $title, $revId, $popts );
},
'error' => function () {
@@ -79,7 +79,7 @@ class ApiParse extends ApiBase {
) {
$worker = new PoolCounterWorkViaCallback( 'ApiParser', $this->getPoolKey(),
[
- 'doWork' => function () use ( $page, $revId, $popts, $suppressCache ) {
+ 'doWork' => static function () use ( $page, $revId, $popts, $suppressCache ) {
return $page->getParserOutput( $popts, $revId, $suppressCache );
},
'error' => function () {
diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php
index a57f9f4e0b31..ed1a8f3c1ba3 100644
--- a/includes/api/ApiQueryBacklinks.php
+++ b/includes/api/ApiQueryBacklinks.php
@@ -449,7 +449,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
if ( $resultPageSet === null ) {
// Try to add the result data in one go and pray that it fits
$code = $this->bl_code;
- $data = array_map( function ( $arr ) use ( $code ) {
+ $data = array_map( static function ( $arr ) use ( $code ) {
if ( isset( $arr['redirlinks'] ) ) {
$arr['redirlinks'] = array_values( $arr['redirlinks'] );
ApiResult::setIndexedTagName( $arr['redirlinks'], $code );
diff --git a/includes/api/ApiQueryBacklinksprop.php b/includes/api/ApiQueryBacklinksprop.php
index 6ec9425ee57c..29d0d7954ea4 100644
--- a/includes/api/ApiQueryBacklinksprop.php
+++ b/includes/api/ApiQueryBacklinksprop.php
@@ -123,7 +123,7 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
$bl_namespace = $settings['to_namespace'];
$bl_title = "{$p}_to";
- $titles = array_filter( $titles, function ( $t ) use ( $bl_namespace ) {
+ $titles = array_filter( $titles, static function ( $t ) use ( $bl_namespace ) {
return $t->getNamespace() === $bl_namespace;
} );
$map = array_intersect_key( $map, [ $bl_namespace => true ] );
diff --git a/includes/api/ApiQueryContributors.php b/includes/api/ApiQueryContributors.php
index 18a97aa21d61..e1ce170a2c49 100644
--- a/includes/api/ApiQueryContributors.php
+++ b/includes/api/ApiQueryContributors.php
@@ -58,7 +58,7 @@ class ApiQueryContributors extends ApiQueryBase {
$cont = explode( '|', $params['continue'] );
$this->dieContinueUsageIf( count( $cont ) != 2 );
$cont_page = (int)$cont[0];
- $pages = array_filter( $pages, function ( $v ) use ( $cont_page ) {
+ $pages = array_filter( $pages, static function ( $v ) use ( $cont_page ) {
return $v >= $cont_page;
} );
}
diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php
index 9da020f281e6..37e227e099da 100644
--- a/includes/api/ApiQueryFileRepoInfo.php
+++ b/includes/api/ApiQueryFileRepoInfo.php
@@ -54,7 +54,7 @@ class ApiQueryFileRepoInfo extends ApiQueryBase {
$foreignTargets = $conf->get( 'ForeignUploadTargets' );
$repoGroup->forEachForeignRepo(
- function ( FileRepo $repo ) use ( &$repos, $props, $foreignTargets ) {
+ static function ( FileRepo $repo ) use ( &$repos, $props, $foreignTargets ) {
$repoProps = $repo->getInfo();
$repoProps['canUpload'] = in_array( $repoProps['name'], $foreignTargets );
@@ -94,7 +94,7 @@ class ApiQueryFileRepoInfo extends ApiQueryBase {
$props = [];
$repoGroup = $this->getInitialisedRepoGroup();
- $repoGroup->forEachForeignRepo( function ( FileRepo $repo ) use ( &$props ) {
+ $repoGroup->forEachForeignRepo( static function ( FileRepo $repo ) use ( &$props ) {
$props = array_merge( $props, array_keys( $repo->getInfo() ) );
} );
diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php
index 4b47fa5577bf..8468b3c93caf 100644
--- a/includes/api/ApiQueryImageInfo.php
+++ b/includes/api/ApiQueryImageInfo.php
@@ -88,7 +88,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
}
$user = $this->getUser();
- $findTitles = array_map( function ( $title ) use ( $user ) {
+ $findTitles = array_map( static function ( $title ) use ( $user ) {
return [
'title' => $title,
'private' => $user,
@@ -401,11 +401,11 @@ class ApiQueryImageInfo extends ApiQueryBase {
// Handle external callers who don't pass revdelUser
if ( isset( $opts['revdelUser'] ) && $opts['revdelUser'] ) {
$revdelUser = $opts['revdelUser'];
- $canShowField = function ( $field ) use ( $file, $revdelUser ) {
+ $canShowField = static function ( $field ) use ( $file, $revdelUser ) {
return $file->userCan( $field, $revdelUser );
};
} else {
- $canShowField = function ( $field ) use ( $file ) {
+ $canShowField = static function ( $field ) use ( $file ) {
return !$file->isDeleted( $field );
};
}
diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php
index 782a1e079101..a4f7160c5064 100644
--- a/includes/api/ApiQueryInfo.php
+++ b/includes/api/ApiQueryInfo.php
@@ -1016,7 +1016,7 @@ class ApiQueryInfo extends ApiQueryBase {
$timestamps[$row->page_namespace][$row->page_title] = (int)$revTimestamp - $age;
}
$titlesWithThresholds = array_map(
- function ( LinkTarget $target ) use ( $timestamps ) {
+ static function ( LinkTarget $target ) use ( $timestamps ) {
return [
$target, $timestamps[$target->getNamespace()][$target->getDBkey()]
];
@@ -1029,7 +1029,7 @@ class ApiQueryInfo extends ApiQueryBase {
$titlesWithThresholds = array_merge(
$titlesWithThresholds,
array_map(
- function ( LinkTarget $target ) {
+ static function ( LinkTarget $target ) {
return [ $target, null ];
},
$this->missing
diff --git a/includes/api/ApiQueryPrefixSearch.php b/includes/api/ApiQueryPrefixSearch.php
index ae6b8dcb9de1..a88874df0667 100644
--- a/includes/api/ApiQueryPrefixSearch.php
+++ b/includes/api/ApiQueryPrefixSearch.php
@@ -63,7 +63,7 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase {
}
if ( $resultPageSet ) {
- $resultPageSet->setRedirectMergePolicy( function ( array $current, array $new ) {
+ $resultPageSet->setRedirectMergePolicy( static function ( array $current, array $new ) {
if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) {
$current['index'] = $new['index'];
}
diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php
index e35e4a7a8fd8..7b79aab0bed7 100644
--- a/includes/api/ApiQuerySearch.php
+++ b/includes/api/ApiQuerySearch.php
@@ -200,7 +200,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
'query', $this->getModuleName()
], 'p' );
} else {
- $resultPageSet->setRedirectMergePolicy( function ( $current, $new ) {
+ $resultPageSet->setRedirectMergePolicy( static function ( $current, $new ) {
if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) {
$current['index'] = $new['index'];
}
diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php
index ad4cab4a1dc7..227a84935724 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -826,7 +826,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
public function appendExtensionTags( $property ) {
$tags = array_map(
- function ( $item ) {
+ static function ( $item ) {
return "<$item>";
},
MediaWikiServices::getInstance()->getParser()->getTags()
diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php
index f104383ae456..0f949cae16ff 100644
--- a/includes/api/ApiQueryTags.php
+++ b/includes/api/ApiQueryTags.php
@@ -57,7 +57,7 @@ class ApiQueryTags extends ApiQueryBase {
# Fetch defined tags that aren't past the continuation
if ( $params['continue'] !== null ) {
$cont = $params['continue'];
- $tags = array_filter( $tags, function ( $v ) use ( $cont ) {
+ $tags = array_filter( $tags, static function ( $v ) use ( $cont ) {
return $v >= $cont;
} );
}
diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php
index 1b74d117be8b..4b7ec7acb665 100644
--- a/includes/api/ApiQueryUsers.php
+++ b/includes/api/ApiQueryUsers.php
@@ -215,7 +215,7 @@ class ApiQueryUsers extends ApiQueryBase {
}
if ( isset( $this->prop['groupmemberships'] ) ) {
- $data[$key]['groupmemberships'] = array_map( function ( $ugm ) {
+ $data[$key]['groupmemberships'] = array_map( static function ( $ugm ) {
return [
'group' => $ugm->getGroup(),
'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ),
diff --git a/includes/api/ApiRemoveAuthenticationData.php b/includes/api/ApiRemoveAuthenticationData.php
index f5b0ed62bd6a..07144857933b 100644
--- a/includes/api/ApiRemoveAuthenticationData.php
+++ b/includes/api/ApiRemoveAuthenticationData.php
@@ -64,7 +64,7 @@ class ApiRemoveAuthenticationData extends ApiBase {
: [];
$reqs = array_filter(
$manager->getAuthenticationRequests( $this->authAction, $this->getUser() ),
- function ( AuthenticationRequest $req ) use ( $params, $blacklist ) {
+ static function ( AuthenticationRequest $req ) use ( $params, $blacklist ) {
return $req->getUniqueId() === $params['request'] &&
!isset( $blacklist[get_class( $req )] );
}
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index d9f4e0cdbcd5..e526c40623a9 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -72,7 +72,7 @@ class ApiRollback extends ApiBase {
$trxLimits = $this->getConfig()->get( 'TrxProfilerLimits' );
$trxProfiler = Profiler::instance()->getTransactionProfiler();
$trxProfiler->redefineExpectations( $trxLimits['POST'], $fname );
- DeferredUpdates::addCallableUpdate( function () use ( $trxProfiler, $trxLimits, $fname ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $trxProfiler, $trxLimits, $fname ) {
$trxProfiler->redefineExpectations( $trxLimits['PostSend-POST'], $fname );
} );
diff --git a/includes/api/ApiTokens.php b/includes/api/ApiTokens.php
index bc37a4e22b40..6c9ff5deeacd 100644
--- a/includes/api/ApiTokens.php
+++ b/includes/api/ApiTokens.php
@@ -74,7 +74,7 @@ class ApiTokens extends ApiBase {
$request = $this->getRequest();
foreach ( ApiQueryTokens::getTokenTypeSalts() as $name => $salt ) {
if ( !isset( $types[$name] ) ) {
- $types[$name] = function ( User $user ) use ( $salt, $request ) {
+ $types[$name] = static function ( User $user ) use ( $salt, $request ) {
return ApiQueryTokens::getToken( $user, $request->getSession(), $salt )->toString();
};
}
diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php
index cb21431f161b..fe8b9c7f0427 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -83,7 +83,7 @@ class ApiWatch extends ApiBase {
ApiResult::setIndexedTagName( $res, 'w' );
} else {
// dont allow use of old title parameter with new pageset parameters.
- $extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), function ( $x ) {
+ $extraParams = array_keys( array_filter( $pageSet->extractRequestParams(), static function ( $x ) {
return $x !== null && $x !== false;
} ) );
diff --git a/includes/api/Validator/ApiParamValidator.php b/includes/api/Validator/ApiParamValidator.php
index edc972d73dea..873ac4cb5e69 100644
--- a/includes/api/Validator/ApiParamValidator.php
+++ b/includes/api/Validator/ApiParamValidator.php
@@ -310,7 +310,7 @@ class ApiParamValidator {
}
$keys = implode( '|', array_map(
- function ( $key ) {
+ static function ( $key ) {
return preg_quote( $key, '/' );
},
array_keys( $settings[ApiBase::PARAM_TEMPLATE_VARS] )
diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php
index a4f6a8df882b..06a3a0c878b2 100644
--- a/includes/auth/AuthManager.php
+++ b/includes/auth/AuthManager.php
@@ -1790,7 +1790,7 @@ class AuthManager implements LoggerAwareInterface {
// Update user count
\DeferredUpdates::addUpdate( \SiteStatsUpdate::factory( [ 'users' => 1 ] ) );
// Watch user's userpage and talk page
- \DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ \DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
$user->addWatch( $user->getUserPage(), User::IGNORE_USER_RIGHTS );
} );
@@ -2346,7 +2346,7 @@ class AuthManager implements LoggerAwareInterface {
}
unset( $spec );
// Sort according to the 'sort' field, and if they are equal, according to 'sort2'
- usort( $specs, function ( $a, $b ) {
+ usort( $specs, static function ( $a, $b ) {
return $a['sort'] <=> $b['sort']
?: $a['sort2'] <=> $b['sort2'];
} );
diff --git a/includes/auth/AuthenticationRequest.php b/includes/auth/AuthenticationRequest.php
index 34079274e62c..79b409d7db2d 100644
--- a/includes/auth/AuthenticationRequest.php
+++ b/includes/auth/AuthenticationRequest.php
@@ -157,7 +157,7 @@ abstract class AuthenticationRequest {
* @return bool Whether the request data was successfully loaded
*/
public function loadFromSubmission( array $data ) {
- $fields = array_filter( $this->getFieldInfo(), function ( $info ) {
+ $fields = array_filter( $this->getFieldInfo(), static function ( $info ) {
return $info['type'] !== 'null';
} );
if ( !$fields ) {
@@ -272,7 +272,7 @@ abstract class AuthenticationRequest {
* @phan-return T|null
*/
public static function getRequestByClass( array $reqs, $class, $allowSubclasses = false ) {
- $requests = array_filter( $reqs, function ( $req ) use ( $class, $allowSubclasses ) {
+ $requests = array_filter( $reqs, static function ( $req ) use ( $class, $allowSubclasses ) {
if ( $allowSubclasses ) {
return is_a( $req, $class, false );
} else {
diff --git a/includes/auth/ButtonAuthenticationRequest.php b/includes/auth/ButtonAuthenticationRequest.php
index 7fb16c6a915c..81cf3a8c97b5 100644
--- a/includes/auth/ButtonAuthenticationRequest.php
+++ b/includes/auth/ButtonAuthenticationRequest.php
@@ -84,7 +84,7 @@ class ButtonAuthenticationRequest extends AuthenticationRequest {
* exactly one matching request.
*/
public static function getRequestByName( array $reqs, $name ) {
- $requests = array_filter( $reqs, function ( $req ) use ( $name ) {
+ $requests = array_filter( $reqs, static function ( $req ) use ( $name ) {
return $req instanceof ButtonAuthenticationRequest && $req->name === $name;
} );
return count( $requests ) === 1 ? reset( $requests ) : null;
diff --git a/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php b/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php
index 759d03262b67..fa3469d655d5 100644
--- a/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php
+++ b/includes/auth/LocalPasswordPrimaryAuthenticationProvider.php
@@ -140,7 +140,7 @@ class LocalPasswordPrimaryAuthenticationProvider
if ( $this->getPasswordFactory()->needsUpdate( $pwhash ) ) {
$newHash = $this->getPasswordFactory()->newFromPlaintext( $req->password );
$fname = __METHOD__;
- \DeferredUpdates::addCallableUpdate( function () use ( $newHash, $oldRow, $fname ) {
+ \DeferredUpdates::addCallableUpdate( static function () use ( $newHash, $oldRow, $fname ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update(
'user',
diff --git a/includes/block/BlockErrorFormatter.php b/includes/block/BlockErrorFormatter.php
index 6dfccf421009..101f077db0ea 100644
--- a/includes/block/BlockErrorFormatter.php
+++ b/includes/block/BlockErrorFormatter.php
@@ -214,7 +214,7 @@ class BlockErrorFormatter {
// Display the CompositeBlock identifier as a message containing relevant block IDs
if ( $block instanceof CompositeBlock ) {
$ids = $language->commaList( array_map(
- function ( $id ) {
+ static function ( $id ) {
return '#' . $id;
},
array_filter( $info['identifier'], 'is_int' )
diff --git a/includes/block/BlockRestrictionStore.php b/includes/block/BlockRestrictionStore.php
index ab71c0252e10..0a36f7a58eb4 100644
--- a/includes/block/BlockRestrictionStore.php
+++ b/includes/block/BlockRestrictionStore.php
@@ -299,7 +299,7 @@ class BlockRestrictionStore {
* @return bool
*/
public function equals( array $a, array $b ) {
- $filter = function ( $restriction ) {
+ $filter = static function ( $restriction ) {
return $restriction instanceof Restriction;
};
@@ -322,7 +322,7 @@ class BlockRestrictionStore {
return true;
}
- $hasher = function ( $r ) {
+ $hasher = static function ( $r ) {
return $r->getHash();
};
@@ -371,7 +371,7 @@ class BlockRestrictionStore {
* @return array
*/
private function restrictionsToRemove( array $existing, array $new ) {
- return array_filter( $existing, function ( $e ) use ( $new ) {
+ return array_filter( $existing, static function ( $e ) use ( $new ) {
foreach ( $new as $restriction ) {
if ( !$restriction instanceof Restriction ) {
continue;
diff --git a/includes/block/DatabaseBlock.php b/includes/block/DatabaseBlock.php
index 7eb8a51f728f..3e3e6f16c81a 100644
--- a/includes/block/DatabaseBlock.php
+++ b/includes/block/DatabaseBlock.php
@@ -527,7 +527,7 @@ class DatabaseBlock extends AbstractBlock {
$lines = $cache->getWithSetCallback(
$cache->makeKey( 'ip-autoblock', 'whitelist' ),
$cache::TTL_DAY,
- function ( $curValue, &$ttl, array &$setOpts ) {
+ static function ( $curValue, &$ttl, array &$setOpts ) {
$setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
return explode( "\n",
@@ -986,7 +986,7 @@ class DatabaseBlock extends AbstractBlock {
// Sort hard blocks before soft ones and secondarily sort blocks
// that disable account creation before those that don't.
- usort( $blocks, function ( DatabaseBlock $a, DatabaseBlock $b ) {
+ usort( $blocks, static function ( DatabaseBlock $a, DatabaseBlock $b ) {
$aWeight = (int)$a->isHardblock() . (int)$a->appliesToRight( 'createaccount' );
$bWeight = (int)$b->isHardblock() . (int)$b->appliesToRight( 'createaccount' );
return strcmp( $bWeight, $aWeight ); // highest weight first
@@ -1124,7 +1124,7 @@ class DatabaseBlock extends AbstractBlock {
* @return self
*/
public function setRestrictions( array $restrictions ) {
- $this->restrictions = array_filter( $restrictions, function ( $restriction ) {
+ $this->restrictions = array_filter( $restrictions, static function ( $restriction ) {
return $restriction instanceof Restriction;
} );
diff --git a/includes/block/DatabaseBlockStore.php b/includes/block/DatabaseBlockStore.php
index fb601cefa4af..89d3d0ee334b 100644
--- a/includes/block/DatabaseBlockStore.php
+++ b/includes/block/DatabaseBlockStore.php
@@ -123,7 +123,7 @@ class DatabaseBlockStore {
DeferredUpdates::addUpdate( new AutoCommitUpdate(
$dbw,
__METHOD__,
- function ( IDatabase $dbw, $fname ) use ( $blockRestrictionStore ) {
+ static function ( IDatabase $dbw, $fname ) use ( $blockRestrictionStore ) {
$ids = $dbw->selectFieldValues(
'ipblocks',
'ipb_id',
diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php
index 818d2da96e4c..5a6ea030397f 100644
--- a/includes/cache/BacklinkCache.php
+++ b/includes/cache/BacklinkCache.php
@@ -212,7 +212,7 @@ class BacklinkCache {
$res = $this->getDB()->select(
$table,
[ 'page_id' => $fromField ],
- array_filter( $conds, function ( $clause ) { // kind of janky
+ array_filter( $conds, static function ( $clause ) { // kind of janky
return !preg_match( '/(\b|=)page_id(\b|=)/', $clause );
} ),
__METHOD__,
diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php
index 84d2489f2d4e..fb4b5a0dc459 100644
--- a/includes/cache/LinkBatch.php
+++ b/includes/cache/LinkBatch.php
@@ -85,7 +85,7 @@ class LinkBatch {
?GenderCache $genderCache = null,
?ILoadBalancer $loadBalancer = null
) {
- $getServices = function () {
+ $getServices = static function () {
// BC hack. Use a closure so this can be unit-tested.
return MediaWikiServices::getInstance();
};
diff --git a/includes/changes/ChangesListBooleanFilter.php b/includes/changes/ChangesListBooleanFilter.php
index d5a5f3c189c5..5ac76e1c5bd9 100644
--- a/includes/changes/ChangesListBooleanFilter.php
+++ b/includes/changes/ChangesListBooleanFilter.php
@@ -221,7 +221,7 @@ class ChangesListBooleanFilter extends ChangesListFilter {
return !$opts[ $this->getName() ] &&
array_filter(
$this->getSiblings(),
- function ( ChangesListBooleanFilter $sibling ) use ( $opts ) {
+ static function ( ChangesListBooleanFilter $sibling ) use ( $opts ) {
return $opts[ $sibling->getName() ];
}
);
diff --git a/includes/changes/ChangesListFilter.php b/includes/changes/ChangesListFilter.php
index 826d4ef56c6f..d7557a7ae65d 100644
--- a/includes/changes/ChangesListFilter.php
+++ b/includes/changes/ChangesListFilter.php
@@ -415,7 +415,7 @@ abstract class ChangesListFilter {
*/
public function getConflictingGroups() {
return array_map(
- function ( $conflictDesc ) {
+ static function ( $conflictDesc ) {
return $conflictDesc[ 'groupObject' ];
},
$this->conflictingGroups
@@ -429,7 +429,7 @@ abstract class ChangesListFilter {
*/
public function getConflictingFilters() {
return array_map(
- function ( $conflictDesc ) {
+ static function ( $conflictDesc ) {
return $conflictDesc[ 'filterObject' ];
},
$this->conflictingFilters
diff --git a/includes/changes/ChangesListFilterGroup.php b/includes/changes/ChangesListFilterGroup.php
index 72b4340fe1fd..26c41f233502 100644
--- a/includes/changes/ChangesListFilterGroup.php
+++ b/includes/changes/ChangesListFilterGroup.php
@@ -354,7 +354,7 @@ abstract class ChangesListFilterGroup {
);
}
- usort( $this->filters, function ( $a, $b ) {
+ usort( $this->filters, static function ( $a, $b ) {
return $b->getPriority() <=> $a->getPriority();
} );
@@ -402,7 +402,7 @@ abstract class ChangesListFilterGroup {
*/
public function getConflictingGroups() {
return array_map(
- function ( $conflictDesc ) {
+ static function ( $conflictDesc ) {
return $conflictDesc[ 'groupObject' ];
},
$this->conflictingGroups
@@ -416,7 +416,7 @@ abstract class ChangesListFilterGroup {
*/
public function getConflictingFilters() {
return array_map(
- function ( $conflictDesc ) {
+ static function ( $conflictDesc ) {
return $conflictDesc[ 'filterObject' ];
},
$this->conflictingFilters
@@ -432,7 +432,7 @@ abstract class ChangesListFilterGroup {
public function anySelected( FormOptions $opts ) {
return (bool)count( array_filter(
$this->getFilters(),
- function ( ChangesListFilter $filter ) use ( $opts ) {
+ static function ( ChangesListFilter $filter ) use ( $opts ) {
return $filter->isSelected( $opts );
}
) );
diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php
index a384d4da093b..ad83f96c7f0c 100644
--- a/includes/changes/EnhancedChangesList.php
+++ b/includes/changes/EnhancedChangesList.php
@@ -715,7 +715,7 @@ class EnhancedChangesList extends ChangesList {
}
$attribs = $data['attribs'];
unset( $data['attribs'] );
- $attribs = array_filter( $attribs, function ( $key ) {
+ $attribs = array_filter( $attribs, static function ( $key ) {
return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
}, ARRAY_FILTER_USE_KEY );
diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php
index 339596641a68..1dc8918b4dfc 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -699,7 +699,7 @@ class RecentChange implements Taggable {
];
DeferredUpdates::addCallableUpdate(
- function () use ( $rc, $tags, $editResult ) {
+ static function () use ( $rc, $tags, $editResult ) {
$rc->addTags( $tags );
$rc->setEditResult( $editResult );
$rc->save();
@@ -773,7 +773,7 @@ class RecentChange implements Taggable {
];
DeferredUpdates::addCallableUpdate(
- function () use ( $rc, $tags ) {
+ static function () use ( $rc, $tags ) {
$rc->addTags( $tags );
$rc->save();
},
diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php
index 6b377d1f44cb..595f29c8b4db 100644
--- a/includes/changetags/ChangeTags.php
+++ b/includes/changetags/ChangeTags.php
@@ -440,7 +440,7 @@ class ChangeTags {
}
$fname = __METHOD__;
// T207881: update the counts at the end of the transaction
- $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tagsToAdd, $fname ) {
+ $dbw->onTransactionPreCommitOrIdle( static function () use ( $dbw, $tagsToAdd, $fname ) {
$dbw->update(
'change_tag_def',
[ 'ctd_count = ctd_count + 1' ],
@@ -485,7 +485,7 @@ class ChangeTags {
$dbw->delete( 'change_tag', $conds, __METHOD__ );
if ( $dbw->affectedRows() ) {
// T207881: update the counts at the end of the transaction
- $dbw->onTransactionPreCommitOrIdle( function () use ( $dbw, $tag, $fname ) {
+ $dbw->onTransactionPreCommitOrIdle( static function () use ( $dbw, $tag, $fname ) {
$dbw->update(
'change_tag_def',
[ 'ctd_count = ctd_count - 1' ],
@@ -1512,7 +1512,7 @@ class ChangeTags {
return $cache->getWithSetCallback(
$cache->makeKey( 'active-tags' ),
WANObjectCache::TTL_MINUTE * 5,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags, $hookRunner ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags, $hookRunner ) {
$setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
// Ask extensions which tags they consider active
@@ -1554,7 +1554,7 @@ class ChangeTags {
return $cache->getWithSetCallback(
$cache->makeKey( 'valid-tags-db' ),
WANObjectCache::TTL_MINUTE * 5,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
@@ -1597,7 +1597,7 @@ class ChangeTags {
return $cache->getWithSetCallback(
$cache->makeKey( 'valid-tags-hook' ),
WANObjectCache::TTL_MINUTE * 5,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags, $hookRunner ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $tags, $hookRunner ) {
$setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
$hookRunner->onListDefinedTags( $tags );
@@ -1640,7 +1640,7 @@ class ChangeTags {
return $cache->getWithSetCallback(
$cache->makeKey( 'tags-usage-statistics' ),
WANObjectCache::TTL_MINUTE * 5,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) {
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'change_tag_def',
diff --git a/includes/collation/NumericUppercaseCollation.php b/includes/collation/NumericUppercaseCollation.php
index 126bb8c826dd..18d1df8204a4 100644
--- a/includes/collation/NumericUppercaseCollation.php
+++ b/includes/collation/NumericUppercaseCollation.php
@@ -58,7 +58,7 @@ class NumericUppercaseCollation extends UppercaseCollation {
// correct position (where digits would normally sort), then the length will be compared putting
// shorter numbers before longer ones; if identical, then the characters will be compared, which
// generates the correct results for numbers of equal length.
- $sortkey = preg_replace_callback( '/\d+/', function ( $matches ) {
+ $sortkey = preg_replace_callback( '/\d+/', static function ( $matches ) {
// Strip any leading zeros
$number = ltrim( $matches[0], '0' );
$len = strlen( $number );
diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php
index 9ea7360b421f..0d2262fb8a7c 100644
--- a/includes/context/RequestContext.php
+++ b/includes/context/RequestContext.php
@@ -566,7 +566,7 @@ class RequestContext implements IContextSource, MutableContext {
$user = User::newFromName( $params['ip'], false );
}
- $importSessionFunc = function ( User $user, array $params ) {
+ $importSessionFunc = static function ( User $user, array $params ) {
global $wgRequest, $wgUser;
$context = RequestContext::getMain();
@@ -619,7 +619,7 @@ class RequestContext implements IContextSource, MutableContext {
// Set callback to save and close the new session and reload the old one
return new ScopedCallback(
- function () use ( $importSessionFunc, $oUser, $oParams, $oRequest ) {
+ static function () use ( $importSessionFunc, $oUser, $oParams, $oRequest ) {
global $wgRequest;
$importSessionFunc( $oUser, $oParams );
// Restore the exact previous Request object (instead of leaving FauxRequest)
diff --git a/includes/db/CloneDatabase.php b/includes/db/CloneDatabase.php
index 9cb4eb30845c..727f8609b044 100644
--- a/includes/db/CloneDatabase.php
+++ b/includes/db/CloneDatabase.php
@@ -139,7 +139,7 @@ class CloneDatabase {
$wgDBname => $lbFactory->getLocalDomainID()
];
$lbFactory->setDomainAliases( $aliases );
- $lbFactory->forEachLB( function ( ILoadBalancer $lb ) use ( $aliases ) {
+ $lbFactory->forEachLB( static function ( ILoadBalancer $lb ) use ( $aliases ) {
$lb->setDomainAliases( $aliases );
} );
diff --git a/includes/db/MWLBFactory.php b/includes/db/MWLBFactory.php
index 44007cdaf4e6..2557120a72f2 100644
--- a/includes/db/MWLBFactory.php
+++ b/includes/db/MWLBFactory.php
@@ -89,7 +89,7 @@ abstract class MWLBFactory {
$options->get( 'DBmwschema' ),
$options->get( 'DBprefix' )
),
- 'profiler' => function ( $section ) {
+ 'profiler' => static function ( $section ) {
return Profiler::instance()->scopedProfileIn( $section );
},
'trxProfiler' => Profiler::instance()->getTransactionProfiler(),
diff --git a/includes/deferred/CdnCacheUpdate.php b/includes/deferred/CdnCacheUpdate.php
index c88db2bb2cd8..9385c7ff4f1d 100644
--- a/includes/deferred/CdnCacheUpdate.php
+++ b/includes/deferred/CdnCacheUpdate.php
@@ -127,7 +127,7 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
$relayerGroup->getRelayer( 'cdn-url-purges' )->notifyMulti(
'cdn-url-purges',
array_map(
- function ( $url ) use ( $ts ) {
+ static function ( $url ) use ( $ts ) {
return [
'url' => $url,
'timestamp' => $ts,
diff --git a/includes/deferred/DeferredUpdates.php b/includes/deferred/DeferredUpdates.php
index ad9bcbdd96b6..63a69563735b 100644
--- a/includes/deferred/DeferredUpdates.php
+++ b/includes/deferred/DeferredUpdates.php
@@ -300,7 +300,7 @@ class DeferredUpdates {
self::getScopeStack()->current()->consumeMatchingUpdates(
self::ALL,
EnqueueableDataUpdate::class,
- function ( EnqueueableDataUpdate $update ) {
+ static function ( EnqueueableDataUpdate $update ) {
$spec = $update->getAsJobSpecification();
JobQueueGroup::singleton( $spec['domain'] )->push( $spec['job'] );
}
@@ -525,8 +525,8 @@ class DeferredUpdates {
}
$connsBusy = false;
- $lbFactory->forEachLB( function ( LoadBalancer $lb ) use ( &$connsBusy ) {
- $lb->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( &$connsBusy ) {
+ $lbFactory->forEachLB( static function ( LoadBalancer $lb ) use ( &$connsBusy ) {
+ $lb->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( &$connsBusy ) {
if ( $conn->writesOrCallbacksPending() || $conn->explicitTrxActive() ) {
$connsBusy = true;
}
diff --git a/includes/deferred/LinksDeletionUpdate.php b/includes/deferred/LinksDeletionUpdate.php
index 6a2f79238b91..7091ba89e7d3 100644
--- a/includes/deferred/LinksDeletionUpdate.php
+++ b/includes/deferred/LinksDeletionUpdate.php
@@ -71,7 +71,7 @@ class LinksDeletionUpdate extends LinksUpdate implements EnqueueableDataUpdate {
// spurious row in the category table.
if ( $title->getNamespace() === NS_CATEGORY ) {
// T166757: do the update after the main job DB commit
- DeferredUpdates::addCallableUpdate( function () use ( $title ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $title ) {
$cat = Category::newFromName( $title->getDBkey() );
$cat->refreshCountsIfSmall();
} );
diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php
index c85e7e644536..1525c7e4cc8c 100644
--- a/includes/deferred/SiteStatsUpdate.php
+++ b/includes/deferred/SiteStatsUpdate.php
@@ -100,7 +100,7 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate {
( new AutoCommitUpdate(
$services->getDBLoadBalancer()->getConnectionRef( DB_MASTER ),
__METHOD__,
- function ( IDatabase $dbw, $fname ) use ( $deltaByType ) {
+ static function ( IDatabase $dbw, $fname ) use ( $deltaByType ) {
$set = [];
foreach ( self::COUNTERS as $field => $type ) {
$delta = (int)$deltaByType[$type];
diff --git a/includes/diff/TextSlotDiffRenderer.php b/includes/diff/TextSlotDiffRenderer.php
index 354d7ac8dc57..55ed9e9f35d1 100644
--- a/includes/diff/TextSlotDiffRenderer.php
+++ b/includes/diff/TextSlotDiffRenderer.php
@@ -166,7 +166,7 @@ class TextSlotDiffRenderer extends SlotDiffRenderer {
* @param Status $status
* @throws FatalError
*/
- $error = function ( $status ) {
+ $error = static function ( $status ) {
throw new FatalError( $status->getWikiText() );
};
diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php
index 775733256b39..572bdb285589 100644
--- a/includes/exception/MWExceptionHandler.php
+++ b/includes/exception/MWExceptionHandler.php
@@ -158,7 +158,7 @@ class MWExceptionHandler {
// Make sure we don't claim success on exit for CLI scripts (T177414)
if ( wfIsCLI() ) {
register_shutdown_function(
- function () {
+ static function () {
exit( 255 );
}
);
@@ -431,9 +431,9 @@ TXT;
* @return array Stacktrace with arugment values converted to data types
*/
public static function redactTrace( array $trace ) {
- return array_map( function ( $frame ) {
+ return array_map( static function ( $frame ) {
if ( isset( $frame['args'] ) ) {
- $frame['args'] = array_map( function ( $arg ) {
+ $frame['args'] = array_map( static function ( $arg ) {
return is_object( $arg ) ? get_class( $arg ) : gettype( $arg );
}, $frame['args'] );
}
diff --git a/includes/export/XmlDumpWriter.php b/includes/export/XmlDumpWriter.php
index 300e79770542..4349fb1ae637 100644
--- a/includes/export/XmlDumpWriter.php
+++ b/includes/export/XmlDumpWriter.php
@@ -248,7 +248,7 @@ class XmlDumpWriter {
if ( $row->page_is_redirect ) {
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $this->currentTitle );
$redirect = $this->invokeLenient(
- function () use ( $page ) {
+ static function () use ( $page ) {
return $page->getRedirectTarget();
},
'Failed to get redirect target of page ' . $page->getId()
@@ -399,7 +399,7 @@ class XmlDumpWriter {
$out .= " <sha1/>\n";
} else {
$sha1 = $this->invokeLenient(
- function () use ( $rev ) {
+ static function () use ( $rev ) {
return $rev->getSha1();
},
'failed to determine sha1 for revision ' . $rev->getId()
@@ -413,7 +413,7 @@ class XmlDumpWriter {
if ( $contentMode === self::WRITE_CONTENT ) {
/** @var Content $content */
$content = $this->invokeLenient(
- function () use ( $rev ) {
+ static function () use ( $rev ) {
return $rev->getContent( SlotRecord::MAIN, RevisionRecord::RAW );
},
'Failed to load main slot content of revision ' . $rev->getId()
@@ -470,7 +470,7 @@ class XmlDumpWriter {
$textAttributes = [
'bytes' => $this->invokeLenient(
- function () use ( $slot ) {
+ static function () use ( $slot ) {
return $slot->getSize();
},
'failed to determine size for slot ' . $slot->getRole() . ' of revision '
@@ -480,7 +480,7 @@ class XmlDumpWriter {
if ( $isV11 ) {
$textAttributes['sha1'] = $this->invokeLenient(
- function () use ( $slot ) {
+ static function () use ( $slot ) {
return $slot->getSha1();
},
'failed to determine sha1 for slot ' . $slot->getRole() . ' of revision '
@@ -490,7 +490,7 @@ class XmlDumpWriter {
if ( $contentMode === self::WRITE_CONTENT ) {
$content = $this->invokeLenient(
- function () use ( $slot ) {
+ static function () use ( $slot ) {
return $slot->getContent();
},
'failed to load content for slot ' . $slot->getRole() . ' of revision '
diff --git a/includes/filebackend/FileBackendGroup.php b/includes/filebackend/FileBackendGroup.php
index a4d6ef8f41c9..9eefe9336b91 100644
--- a/includes/filebackend/FileBackendGroup.php
+++ b/includes/filebackend/FileBackendGroup.php
@@ -243,7 +243,7 @@ class FileBackendGroup {
'wanCache' => $this->wanCache,
'srvCache' => $this->srvCache,
'logger' => LoggerFactory::getInstance( 'FileOperation' ),
- 'profiler' => function ( $section ) {
+ 'profiler' => static function ( $section ) {
return Profiler::instance()->scopedProfileIn( $section );
}
],
diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php
index 128a1d1c8047..0a7937d497be 100644
--- a/includes/filerepo/ForeignDBRepo.php
+++ b/includes/filerepo/ForeignDBRepo.php
@@ -107,7 +107,7 @@ class ForeignDBRepo extends LocalRepo {
'tablePrefix' => $this->tablePrefix
];
- return function ( $index ) use ( $type, $params ) {
+ return static function ( $index ) use ( $type, $params ) {
return Database::factory( $type, $params );
};
}
diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php
index c725471921d4..4cd7a980be04 100644
--- a/includes/filerepo/LocalRepo.php
+++ b/includes/filerepo/LocalRepo.php
@@ -266,7 +266,7 @@ class LocalRepo extends FileRepo {
}
}
- $fileMatchesSearch = function ( File $file, array $search ) {
+ $fileMatchesSearch = static function ( File $file, array $search ) {
// Note: file name comparison done elsewhere (to handle redirects)
// Fallback to RequestContext::getMain should be replaced with a better
@@ -495,7 +495,7 @@ class LocalRepo extends FileRepo {
* @return Closure
*/
protected function getDBFactory() {
- return function ( $index ) {
+ return static function ( $index ) {
return wfGetDB( $index );
};
}
diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php
index 83e47fe5aef6..956e8518fb26 100644
--- a/includes/filerepo/RepoGroup.php
+++ b/includes/filerepo/RepoGroup.php
@@ -78,7 +78,7 @@ class RepoGroup {
$services = MediaWikiServices::getInstance();
$services->disableService( 'RepoGroup' );
$services->redefineService( 'RepoGroup',
- function () use ( $instance ) {
+ static function () use ( $instance ) {
return $instance;
}
);
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index 12bb223dfa51..7d330c916d72 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -2161,7 +2161,7 @@ abstract class File implements IDBAccessObject {
return $cache->getWithSetCallback(
$key,
$this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
wfDebug( "Fetching shared description from $renderUrl" );
$res = MediaWikiServices::getInstance()->getHttpRequestFactory()->
get( $renderUrl, [], $fname );
diff --git a/includes/filerepo/file/ForeignDBFile.php b/includes/filerepo/file/ForeignDBFile.php
index 411db81faa3e..b276ce153c91 100644
--- a/includes/filerepo/file/ForeignDBFile.php
+++ b/includes/filerepo/file/ForeignDBFile.php
@@ -129,7 +129,7 @@ class ForeignDBFile extends LocalFile {
$touched
),
$this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
wfDebug( "Fetching shared description from $renderUrl" );
$res = MediaWikiServices::getInstance()->getHttpRequestFactory()->
get( $renderUrl, [], $fname );
diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php
index ada612cafea3..b1f63f1c2616 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -382,7 +382,7 @@ class LocalFile extends File {
}
$this->repo->getMasterDB()->onTransactionPreCommitOrIdle(
- function () use ( $key ) {
+ static function () use ( $key ) {
MediaWikiServices::getInstance()->getMainWANObjectCache()->delete( $key );
},
__METHOD__
@@ -1987,7 +1987,7 @@ class LocalFile extends File {
new AutoCommitUpdate(
$this->getRepo()->getMasterDB(),
__METHOD__,
- function () use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
+ static function () use ( $oldTitleFile, $newTitleFile, $archiveNames ) {
$oldTitleFile->purgeEverything();
foreach ( $archiveNames as $archiveName ) {
/** @var OldLocalFile $oldTitleFile */
diff --git a/includes/htmlform/fields/HTMLNamespacesMultiselectField.php b/includes/htmlform/fields/HTMLNamespacesMultiselectField.php
index 7ea821e166e6..ef00e64f8998 100644
--- a/includes/htmlform/fields/HTMLNamespacesMultiselectField.php
+++ b/includes/htmlform/fields/HTMLNamespacesMultiselectField.php
@@ -21,7 +21,7 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
$namespaces = explode( "\n", $value );
// Remove empty lines
- $namespaces = array_values( array_filter( $namespaces, function ( $namespace ) {
+ $namespaces = array_values( array_filter( $namespaces, static function ( $namespace ) {
return trim( $namespace ) !== '';
} ) );
// This function is expected to return a string
diff --git a/includes/htmlform/fields/HTMLTitlesMultiselectField.php b/includes/htmlform/fields/HTMLTitlesMultiselectField.php
index c06b62364ea2..7b4c261a3a8e 100644
--- a/includes/htmlform/fields/HTMLTitlesMultiselectField.php
+++ b/includes/htmlform/fields/HTMLTitlesMultiselectField.php
@@ -39,7 +39,7 @@ class HTMLTitlesMultiselectField extends HTMLTitleTextField {
$titlesArray = explode( "\n", $value );
// Remove empty lines
- $titlesArray = array_values( array_filter( $titlesArray, function ( $title ) {
+ $titlesArray = array_values( array_filter( $titlesArray, static function ( $title ) {
return trim( $title ) !== '';
} ) );
// This function is expected to return a string
diff --git a/includes/htmlform/fields/HTMLUsersMultiselectField.php b/includes/htmlform/fields/HTMLUsersMultiselectField.php
index 6c1cc8476dac..5f4615d93e31 100644
--- a/includes/htmlform/fields/HTMLUsersMultiselectField.php
+++ b/includes/htmlform/fields/HTMLUsersMultiselectField.php
@@ -21,7 +21,7 @@ class HTMLUsersMultiselectField extends HTMLUserTextField {
$usersArray = explode( "\n", $value );
// Remove empty lines
- $usersArray = array_values( array_filter( $usersArray, function ( $username ) {
+ $usersArray = array_values( array_filter( $usersArray, static function ( $username ) {
return trim( $username ) !== '';
} ) );
// This function is expected to return a string
diff --git a/includes/http/GuzzleHttpRequest.php b/includes/http/GuzzleHttpRequest.php
index ad7249f283e7..74edf8e8617f 100644
--- a/includes/http/GuzzleHttpRequest.php
+++ b/includes/http/GuzzleHttpRequest.php
@@ -168,7 +168,7 @@ class GuzzleHttpRequest extends MWHttpRequest {
$mwCookieJar = $this->getCookieJar();
$stack->push( Middleware::mapRequest(
- function ( RequestInterface $request ) use ( $mwCookieJar ) {
+ static function ( RequestInterface $request ) use ( $mwCookieJar ) {
$uri = $request->getUri();
$cookieHeader = $mwCookieJar->serializeToHttpRequest(
$uri->getPath() ?: '/',
diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php
index 6a13bef797a5..acd00d06072b 100644
--- a/includes/installer/DatabaseInstaller.php
+++ b/includes/installer/DatabaseInstaller.php
@@ -402,7 +402,7 @@ abstract class DatabaseInstaller {
$connection = $status->value;
$this->parent->resetMediaWikiServices( null, [
- 'DBLoadBalancerFactory' => function () use ( $connection ) {
+ 'DBLoadBalancerFactory' => static function () use ( $connection ) {
return LBFactorySingle::newFromConnection( $connection );
}
] );
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index c4efbcf70f93..2374b6487d3b 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -398,7 +398,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'] = static function () use ( $installerConfig ) {
return $installerConfig;
};
@@ -459,12 +459,12 @@ abstract class Installer {
$serviceOverrides += [
// Disable interwiki lookup, to avoid database access during parses
- 'InterwikiLookup' => function () {
+ 'InterwikiLookup' => static function () {
return new NullInterwikiLookup();
},
// Disable user options database fetching, only rely on default options.
- 'UserOptionsLookup' => function ( MediaWikiServices $services ) {
+ 'UserOptionsLookup' => static function ( MediaWikiServices $services ) {
return $services->get( '_DefaultOptionsLookup' );
}
];
@@ -1762,7 +1762,7 @@ abstract class Installer {
*/
public function restoreServices() {
$this->resetMediaWikiServices( null, [
- 'UserOptionsLookup' => function ( MediaWikiServices $services ) {
+ 'UserOptionsLookup' => static function ( MediaWikiServices $services ) {
return $services->get( 'UserOptionsManager' );
}
] );
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 546d67fd0f36..95a12ce4764c 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -680,7 +680,7 @@ class JobQueueDB extends JobQueue {
__METHOD__
);
$ids = array_map(
- function ( $o ) {
+ static function ( $o ) {
return $o->job_id;
}, iterator_to_array( $res )
);
@@ -716,7 +716,7 @@ class JobQueueDB extends JobQueue {
// the IDs first means that the UPDATE can be done by primary key (less deadlocks).
$res = $dbw->select( 'job', 'job_id', $conds, __METHOD__ );
$ids = array_map(
- function ( $o ) {
+ static function ( $o ) {
return $o->job_id;
}, iterator_to_array( $res )
);
@@ -828,7 +828,7 @@ class JobQueueDB extends JobQueue {
$autoTrx = $db->getFlag( DBO_TRX ); // get current setting
$db->clearFlag( DBO_TRX ); // make each query its own transaction
- return new ScopedCallback( function () use ( $db, $autoTrx ) {
+ return new ScopedCallback( static function () use ( $db, $autoTrx ) {
if ( $autoTrx ) {
$db->setFlag( DBO_TRX ); // restore old setting
}
diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php
index d188e29be165..34a1c2215ee2 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -454,7 +454,7 @@ class JobQueueGroup {
$value = $cache->getWithSetCallback(
$cache->makeGlobalKey( 'jobqueue', 'configvalue', $this->domain, $name ),
$cache::TTL_DAY + mt_rand( 0, $cache::TTL_DAY ),
- function () use ( $wiki, $name ) {
+ static function () use ( $wiki, $name ) {
global $wgConf;
// @TODO: use the full domain ID here
return [ 'v' => $wgConf->getConfig( $wiki, $name ) ];
diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php
index cd7063d6c069..c7b95363123b 100644
--- a/includes/jobqueue/JobQueueRedis.php
+++ b/includes/jobqueue/JobQueueRedis.php
@@ -587,7 +587,7 @@ LUA;
function ( $uid ) use ( $conn ) {
return $this->getJobFromUidInternal( $uid, $conn );
},
- [ 'accept' => function ( $job ) {
+ [ 'accept' => static function ( $job ) {
return is_object( $job );
} ]
);
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
index 3094d00cf768..9c9d3d8da5f4 100644
--- a/includes/jobqueue/JobRunner.php
+++ b/includes/jobqueue/JobRunner.php
@@ -673,7 +673,7 @@ class JobRunner implements LoggerAwareInterface {
// This will trigger a rollback in the main loop
throw new DBError( $dbwSerial, "Timed out waiting on commit queue." );
}
- $unlocker = new ScopedCallback( function () use ( $dbwSerial, $fnameTrxOwner ) {
+ $unlocker = new ScopedCallback( static function () use ( $dbwSerial, $fnameTrxOwner ) {
$dbwSerial->unlock( 'jobrunner-serial-commit', $fnameTrxOwner );
} );
diff --git a/includes/jobqueue/jobs/AssembleUploadChunksJob.php b/includes/jobqueue/jobs/AssembleUploadChunksJob.php
index 8e72959b1960..519419dcb37d 100644
--- a/includes/jobqueue/jobs/AssembleUploadChunksJob.php
+++ b/includes/jobqueue/jobs/AssembleUploadChunksJob.php
@@ -35,7 +35,7 @@ class AssembleUploadChunksJob extends Job {
public function run() {
$scope = RequestContext::importScopedSession( $this->params['session'] );
- $this->addTeardownCallback( function () use ( &$scope ) {
+ $this->addTeardownCallback( static function () use ( &$scope ) {
ScopedCallback::consume( $scope ); // T126450
} );
diff --git a/includes/jobqueue/jobs/PublishStashedFileJob.php b/includes/jobqueue/jobs/PublishStashedFileJob.php
index ae07e884bf2a..6919bdd0ae6f 100644
--- a/includes/jobqueue/jobs/PublishStashedFileJob.php
+++ b/includes/jobqueue/jobs/PublishStashedFileJob.php
@@ -37,7 +37,7 @@ class PublishStashedFileJob extends Job {
public function run() {
$scope = RequestContext::importScopedSession( $this->params['session'] );
- $this->addTeardownCallback( function () use ( &$scope ) {
+ $this->addTeardownCallback( static function () use ( &$scope ) {
ScopedCallback::consume( $scope ); // T126450
} );
diff --git a/includes/jobqueue/utils/PurgeJobUtils.php b/includes/jobqueue/utils/PurgeJobUtils.php
index d1784f02c625..d6de48fc4208 100644
--- a/includes/jobqueue/utils/PurgeJobUtils.php
+++ b/includes/jobqueue/utils/PurgeJobUtils.php
@@ -41,7 +41,7 @@ class PurgeJobUtils {
DeferredUpdates::addUpdate( new AutoCommitUpdate(
$dbw,
__METHOD__,
- function () use ( $dbw, $namespace, $dbkeys, $fname ) {
+ static function () use ( $dbw, $namespace, $dbkeys, $fname ) {
$services = MediaWikiServices::getInstance();
$lbFactory = $services->getDBLoadBalancerFactory();
// Determine which pages need to be updated.
diff --git a/includes/language/converters/EnConverter.php b/includes/language/converters/EnConverter.php
index 7f7825c0ed91..ed8d5ae1faf0 100644
--- a/includes/language/converters/EnConverter.php
+++ b/includes/language/converters/EnConverter.php
@@ -78,13 +78,13 @@ class EnConverter extends LanguageConverter {
// Only process words composed of standard English alphabet, leave the rest unchanged.
// This skips some English words like 'naïve' or 'résumé', but we can live with that.
// Ignore single letters and words which aren't lowercase or uppercase-first.
- return preg_replace_callback( '/[A-Za-z][a-z\']+/', function ( $matches ) {
+ return preg_replace_callback( '/[A-Za-z][a-z\']+/', static function ( $matches ) {
$word = $matches[0];
if ( preg_match( '/^[aeiou]/i', $word ) ) {
return $word . 'way';
}
- return preg_replace_callback( '/^(s?qu|[^aeiou][^aeiouy]*)(.*)$/i', function ( $m ) {
+ return preg_replace_callback( '/^(s?qu|[^aeiou][^aeiouy]*)(.*)$/i', static function ( $m ) {
$ucfirst = strtoupper( $m[1][0] ) === $m[1][0];
if ( $ucfirst ) {
return ucfirst( $m[2] ) . lcfirst( $m[1] ) . 'ay';
diff --git a/includes/libs/ArrayUtils.php b/includes/libs/ArrayUtils.php
index 5c1fbe1d2db0..292e343683bb 100644
--- a/includes/libs/ArrayUtils.php
+++ b/includes/libs/ArrayUtils.php
@@ -51,7 +51,7 @@ class ArrayUtils {
foreach ( $array as $elt ) {
$hashes[$elt] = md5( $elt . $separator . $key );
}
- uasort( $array, function ( $a, $b ) use ( $hashes ) {
+ uasort( $array, static function ( $a, $b ) use ( $hashes ) {
return strcmp( $hashes[$a], $hashes[$b] );
} );
}
diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php
index 94f3516ee87f..49f428599464 100644
--- a/includes/libs/CSSMin.php
+++ b/includes/libs/CSSMin.php
@@ -188,7 +188,7 @@ class CSSMin {
*/
public static function serializeStringValue( $value ) {
$value = strtr( $value, [ "\0" => "\u{FFFD}", '\\' => '\\\\', '"' => '\\"' ] );
- $value = preg_replace_callback( '/[\x01-\x1f\x7f]/', function ( $match ) {
+ $value = preg_replace_callback( '/[\x01-\x1f\x7f]/', static function ( $match ) {
return '\\' . base_convert( ord( $match[0] ), 10, 16 ) . ' ';
}, $value );
return '"' . $value . '"';
@@ -264,7 +264,7 @@ class CSSMin {
$source = preg_replace_callback(
$pattern,
- function ( $match ) use ( &$comments ) {
+ static function ( $match ) use ( &$comments ) {
$comments[] = $match[ 0 ];
return self::PLACEHOLDER . ( count( $comments ) - 1 ) . 'x';
},
@@ -339,7 +339,7 @@ class CSSMin {
// Re-insert comments
$pattern = '/' . self::PLACEHOLDER . '(\d+)x/';
- $source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) {
+ $source = preg_replace_callback( $pattern, static function ( $match ) use ( &$comments ) {
return $comments[ $match[1] ];
}, $source );
diff --git a/includes/libs/HashRing.php b/includes/libs/HashRing.php
index 75f91a4bcec4..a59e67dad564 100644
--- a/includes/libs/HashRing.php
+++ b/includes/libs/HashRing.php
@@ -271,7 +271,7 @@ class HashRing implements Serializable {
$this->weightByLocation,
array_filter(
$this->ejectExpiryByLocation,
- function ( $expiry ) use ( $now ) {
+ static function ( $expiry ) use ( $now ) {
return ( $expiry > $now );
}
)
@@ -319,7 +319,7 @@ class HashRing implements Serializable {
}
}
// Sort the locations into clockwise order based on the hash ring position
- usort( $ring, function ( $a, $b ) {
+ usort( $ring, static function ( $a, $b ) {
if ( $a[self::KEY_POS] === $b[self::KEY_POS] ) {
throw new UnexpectedValueException( 'Duplicate node positions.' );
}
@@ -402,7 +402,7 @@ class HashRing implements Serializable {
// Live ring needs to be regerenated...
$this->ejectExpiryByLocation = array_filter(
$this->ejectExpiryByLocation,
- function ( $expiry ) use ( $now ) {
+ static function ( $expiry ) use ( $now ) {
return ( $expiry > $now );
}
);
diff --git a/includes/libs/ParamValidator/ParamValidator.php b/includes/libs/ParamValidator/ParamValidator.php
index 976c694609fd..adfb9f6edf72 100644
--- a/includes/libs/ParamValidator/ParamValidator.php
+++ b/includes/libs/ParamValidator/ParamValidator.php
@@ -655,7 +655,7 @@ class ParamValidator {
'values' => $invalidValues,
] )
->plaintextParams( $name, $value )
- ->commaListParams( array_map( function ( $v ) {
+ ->commaListParams( array_map( static function ( $v ) {
return new ScalarParam( ParamType::PLAINTEXT, $v );
}, $invalidValues ) )
->numParams( count( $invalidValues ) ),
@@ -725,7 +725,7 @@ class ParamValidator {
}
// Filter out nulls (strictly)
- return array_filter( $info, function ( $v ) {
+ return array_filter( $info, static function ( $v ) {
return $v !== null;
} );
}
diff --git a/includes/libs/ParamValidator/TypeDef/EnumDef.php b/includes/libs/ParamValidator/TypeDef/EnumDef.php
index 85ebe87442aa..53216ab76290 100644
--- a/includes/libs/ParamValidator/TypeDef/EnumDef.php
+++ b/includes/libs/ParamValidator/TypeDef/EnumDef.php
@@ -76,7 +76,7 @@ class EnumDef extends TypeDef {
$isMulti = isset( $options['values-list'] );
$this->failure(
$this->failureMessage( 'badvalue', [], $isMulti ? 'enummulti' : 'enumnotmulti' )
- ->textListParams( array_map( function ( $v ) {
+ ->textListParams( array_map( static function ( $v ) {
return new ScalarParam( ParamType::PLAINTEXT, $v );
}, $values ) )
->numParams( count( $values ) ),
diff --git a/includes/libs/ParamValidator/TypeDef/ExpiryDef.php b/includes/libs/ParamValidator/TypeDef/ExpiryDef.php
index 438d5f9d7e62..5ebe9b7ad17e 100644
--- a/includes/libs/ParamValidator/TypeDef/ExpiryDef.php
+++ b/includes/libs/ParamValidator/TypeDef/ExpiryDef.php
@@ -70,7 +70,7 @@ class ExpiryDef extends TypeDef {
->textListParams(
// Should be quoted or monospace for presentation purposes,
// but textListParams() doesn't do this.
- array_map( function ( $val ) {
+ array_map( static function ( $val ) {
return "\"$val\"";
}, self::INFINITY_VALS )
);
diff --git a/includes/libs/StatusValue.php b/includes/libs/StatusValue.php
index 922829c1d238..17d22ce5bcbd 100644
--- a/includes/libs/StatusValue.php
+++ b/includes/libs/StatusValue.php
@@ -187,7 +187,7 @@ class StatusValue {
*/
private function addError( array $newError ) {
if ( $newError[ 'message' ] instanceof MessageSpecifier ) {
- $isEqual = function ( $existingError ) use ( $newError ) {
+ $isEqual = static function ( $existingError ) use ( $newError ) {
if ( $existingError['message'] instanceof MessageSpecifier ) {
// compare attributes of both MessageSpecifiers
return $newError['message'] == $existingError['message'];
@@ -197,7 +197,7 @@ class StatusValue {
}
};
} else {
- $isEqual = function ( $existingError ) use ( $newError ) {
+ $isEqual = static function ( $existingError ) use ( $newError ) {
if ( $existingError['message'] instanceof MessageSpecifier ) {
return $newError['message'] === $existingError['message']->getKey() &&
$newError['params'] === $existingError['message']->getParams();
diff --git a/includes/libs/StringUtils.php b/includes/libs/StringUtils.php
index 65b552b35bef..f5e9e731433c 100644
--- a/includes/libs/StringUtils.php
+++ b/includes/libs/StringUtils.php
@@ -250,7 +250,7 @@ class StringUtils {
) {
return self::delimiterReplaceCallback(
$startDelim, $endDelim,
- function ( array $matches ) use ( $replace ) {
+ static function ( array $matches ) use ( $replace ) {
return strtr( $replace, [ '$0' => $matches[0], '$1' => $matches[1] ] );
},
$subject, $flags
@@ -274,7 +274,7 @@ class StringUtils {
// Replace instances of the separator inside HTML-like tags with the placeholder
$cleaned = self::delimiterReplaceCallback(
'<', '>',
- function ( array $matches ) use ( $search, $placeholder ) {
+ static function ( array $matches ) use ( $search, $placeholder ) {
return str_replace( $search, $placeholder, $matches[0] );
},
$text
diff --git a/includes/libs/Timing.php b/includes/libs/Timing.php
index 5ed7aebc6a7a..2149d33395d1 100644
--- a/includes/libs/Timing.php
+++ b/includes/libs/Timing.php
@@ -153,7 +153,7 @@ class Timing implements LoggerAwareInterface {
* Sort entries in chronological order with respect to startTime.
*/
private function sortEntries() {
- uasort( $this->entries, function ( $a, $b ) {
+ uasort( $this->entries, static function ( $a, $b ) {
return $a['startTime'] <=> $b['startTime'];
} );
}
diff --git a/includes/libs/XhprofData.php b/includes/libs/XhprofData.php
index 9ec27e394db1..dee766ed23c9 100644
--- a/includes/libs/XhprofData.php
+++ b/includes/libs/XhprofData.php
@@ -367,7 +367,7 @@ class XhprofData {
* @return Closure
*/
public static function makeSortFunction( $key, $sub ) {
- return function ( $a, $b ) use ( $key, $sub ) {
+ return static function ( $a, $b ) use ( $key, $sub ) {
if ( isset( $a[$key] ) && isset( $b[$key] ) ) {
// Descending sort: larger values will be first in result.
// Values for 'main()' will not have sub keys
diff --git a/includes/libs/filebackend/FileBackendMultiWrite.php b/includes/libs/filebackend/FileBackendMultiWrite.php
index e0ead23480a8..d3591ba2ea1d 100644
--- a/includes/libs/filebackend/FileBackendMultiWrite.php
+++ b/includes/libs/filebackend/FileBackendMultiWrite.php
@@ -561,7 +561,7 @@ class FileBackendMultiWrite extends FileBackend {
$realOps = $this->substOpBatchPaths( $ops, $backend );
if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) {
DeferredUpdates::addCallableUpdate(
- function () use ( $backend, $realOps ) {
+ static function () use ( $backend, $realOps ) {
$backend->doQuickOperations( $realOps );
}
);
@@ -615,7 +615,7 @@ class FileBackendMultiWrite extends FileBackend {
$realParams = $this->substOpPaths( $params, $backend );
if ( $this->asyncWrites ) {
DeferredUpdates::addCallableUpdate(
- function () use ( $backend, $method, $realParams ) {
+ static function () use ( $backend, $method, $realParams ) {
$backend->$method( $realParams );
}
);
diff --git a/includes/libs/filebackend/HTTPFileStreamer.php b/includes/libs/filebackend/HTTPFileStreamer.php
index 9c06f5322548..ee1e3dfb01fc 100644
--- a/includes/libs/filebackend/HTTPFileStreamer.php
+++ b/includes/libs/filebackend/HTTPFileStreamer.php
@@ -95,10 +95,10 @@ class HTTPFileStreamer {
}
$headerFunc = ( $flags & self::STREAM_HEADLESS )
- ? function ( $header ) {
+ ? static function ( $header ) {
// no-op
}
- : function ( $header ) {
+ : static function ( $header ) {
is_int( $header ) ? HttpStatus::header( $header ) : header( $header );
};
diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php
index f7a9dca077c3..04e8fc601ad0 100644
--- a/includes/libs/filebackend/SwiftFileBackend.php
+++ b/includes/libs/filebackend/SwiftFileBackend.php
@@ -938,7 +938,7 @@ class SwiftFileBackend extends FileBackendStore {
}
} else {
// Recursive: list all dirs under $dir and its subdirs
- $getParentDir = function ( $path ) {
+ $getParentDir = static function ( $path ) {
return ( strpos( $path, '/' ) !== false ) ? dirname( $path ) : false;
};
diff --git a/includes/libs/http/HttpAcceptParser.php b/includes/libs/http/HttpAcceptParser.php
index 26611b6edd00..625237c6d39e 100644
--- a/includes/libs/http/HttpAcceptParser.php
+++ b/includes/libs/http/HttpAcceptParser.php
@@ -63,7 +63,7 @@ class HttpAcceptParser {
}
// Sort list. First by q values, then by order
- usort( $ret, function ( $a, $b ) {
+ usort( $ret, static function ( $a, $b ) {
if ( $b['q'] > $a['q'] ) {
return 1;
} elseif ( $b['q'] === $a['q'] ) {
@@ -100,7 +100,7 @@ class HttpAcceptParser {
$accepts = $this->parseAccept( $rawHeader );
// Create a list like "en" => 0.8
- return array_reduce( $accepts, function ( $prev, $next ) {
+ return array_reduce( $accepts, static function ( $prev, $next ) {
$type = "{$next['type']}/{$next['subtype']}";
$prev[$type] = $next['q'];
return $prev;
diff --git a/includes/libs/http/MultiHttpClient.php b/includes/libs/http/MultiHttpClient.php
index f3e9be7660a9..750b1dd435de 100644
--- a/includes/libs/http/MultiHttpClient.php
+++ b/includes/libs/http/MultiHttpClient.php
@@ -350,7 +350,7 @@ class MultiHttpClient implements LoggerAwareInterface {
curl_setopt( $ch, CURLOPT_INFILESIZE, 0 );
}
curl_setopt( $ch, CURLOPT_READFUNCTION,
- function ( $ch, $fd, $length ) {
+ static function ( $ch, $fd, $length ) {
return (string)fread( $fd, $length );
}
);
@@ -378,7 +378,7 @@ class MultiHttpClient implements LoggerAwareInterface {
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_HEADERFUNCTION,
- function ( $ch, $header ) use ( &$req ) {
+ static function ( $ch, $header ) use ( &$req ) {
if ( !empty( $req['flags']['relayResponseHeaders'] ) && trim( $header ) !== '' ) {
header( $header );
}
@@ -410,7 +410,7 @@ class MultiHttpClient implements LoggerAwareInterface {
// This works with both file and php://temp handles (unlike CURLOPT_FILE)
$hasOutputStream = isset( $req['stream'] );
curl_setopt( $ch, CURLOPT_WRITEFUNCTION,
- function ( $ch, $data ) use ( &$req, $hasOutputStream ) {
+ static function ( $ch, $data ) use ( &$req, $hasOutputStream ) {
if ( $hasOutputStream ) {
return fwrite( $req['stream'], $data );
} else {
@@ -496,7 +496,7 @@ class MultiHttpClient implements LoggerAwareInterface {
$sv = $httpRequest->execute()->getStatusValue();
$respHeaders = array_map(
- function ( $v ) {
+ static function ( $v ) {
return implode( ', ', $v );
},
$httpRequest->getResponseHeaders() );
diff --git a/includes/libs/lockmanager/MemcLockManager.php b/includes/libs/lockmanager/MemcLockManager.php
index d31fcede661a..6dbde075570d 100644
--- a/includes/libs/lockmanager/MemcLockManager.php
+++ b/includes/libs/lockmanager/MemcLockManager.php
@@ -309,7 +309,7 @@ class MemcLockManager extends QuorumLockManager {
// This reduces memcached spam, especially in the rare case where a server acquires
// some lock keys and dies without releasing them. Lock keys expire after a few minutes.
$loop = new WaitConditionLoop(
- function () use ( $memc, $keys, &$lockedKeys ) {
+ static function () use ( $memc, $keys, &$lockedKeys ) {
foreach ( array_diff( $keys, $lockedKeys ) as $key ) {
if ( $memc->add( "$key:mutex", 1, 180 ) ) { // lock record
$lockedKeys[] = $key;
diff --git a/includes/libs/lockmanager/PostgreSqlLockManager.php b/includes/libs/lockmanager/PostgreSqlLockManager.php
index fd3ffa5cbcd6..5f63334726ca 100644
--- a/includes/libs/lockmanager/PostgreSqlLockManager.php
+++ b/includes/libs/lockmanager/PostgreSqlLockManager.php
@@ -24,7 +24,7 @@ class PostgreSqlLockManager extends DBLockManager {
$db = $this->getConnection( $lockSrv ); // checked in isServerUp()
$bigints = array_unique( array_map(
- function ( $key ) {
+ static function ( $key ) {
return Wikimedia\base_convert( substr( $key, 0, 15 ), 16, 10 );
},
array_map( [ $this, 'sha1Base16Absolute' ], $paths )
diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php b/includes/libs/objectcache/MemcachedBagOStuff.php
index 068ea3b5a935..4d238d404fc3 100644
--- a/includes/libs/objectcache/MemcachedBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedBagOStuff.php
@@ -68,7 +68,7 @@ abstract class MemcachedBagOStuff extends MediumSpecificBagOStuff {
// Make sure %, #, and non-ASCII chars are escaped
$component = preg_replace_callback(
'/[^\x21-\x22\x24\x26-\x39\x3b-\x7e]+/',
- function ( $m ) {
+ static function ( $m ) {
return rawurlencode( $m[0] );
},
$component
diff --git a/includes/libs/objectcache/MultiWriteBagOStuff.php b/includes/libs/objectcache/MultiWriteBagOStuff.php
index f4b44dd1c2a8..9a9f8c3a1001 100644
--- a/includes/libs/objectcache/MultiWriteBagOStuff.php
+++ b/includes/libs/objectcache/MultiWriteBagOStuff.php
@@ -454,7 +454,7 @@ class MultiWriteBagOStuff extends BagOStuff {
} else {
// Secondary write in async mode: do not block this HTTP request
( $this->asyncHandler )(
- function () use ( $cache, $method, $arg0Sig, $resSig, $args ) {
+ static function () use ( $cache, $method, $arg0Sig, $resSig, $args ) {
$cache->proxyCall( $method, $arg0Sig, $resSig, $args );
}
);
diff --git a/includes/libs/objectcache/WinCacheBagOStuff.php b/includes/libs/objectcache/WinCacheBagOStuff.php
index e5c417ac49c8..18e6fb441dc1 100644
--- a/includes/libs/objectcache/WinCacheBagOStuff.php
+++ b/includes/libs/objectcache/WinCacheBagOStuff.php
@@ -110,7 +110,7 @@ class WinCacheBagOStuff extends MediumSpecificBagOStuff {
$charsLeft = 125 - strlen( $keyspace ) - count( $components );
$components = array_map(
- function ( $component ) use ( &$charsLeft ) {
+ static function ( $component ) use ( &$charsLeft ) {
// 33 = 32 characters for the MD5 + 1 for the '#' prefix.
if ( $charsLeft > 33 && strlen( $component ) > $charsLeft ) {
$component = '#' . md5( $component );
diff --git a/includes/libs/objectcache/wancache/WANObjectCache.php b/includes/libs/objectcache/wancache/WANObjectCache.php
index 386aa79dd6c7..4762193f3391 100644
--- a/includes/libs/objectcache/wancache/WANObjectCache.php
+++ b/includes/libs/objectcache/wancache/WANObjectCache.php
@@ -773,7 +773,7 @@ class WANObjectCache implements
} else {
$ok = $this->cache->merge(
$this->makeSisterKey( $key, self::TYPE_VALUE ),
- function ( $cache, $key, $cWrapped ) use ( $wrapped ) {
+ static function ( $cache, $key, $cWrapped ) use ( $wrapped ) {
// A string value means that it is a tombstone; do nothing in that case
return ( is_string( $cWrapped ) ) ? false : $wrapped;
},
@@ -1867,7 +1867,7 @@ class WANObjectCache implements
$wrapped = $this->wrap( $value, $ttl, $version, $this->getCurrentTime(), $walltime );
$this->cache->merge(
$this->makeSisterKey( $key, self::TYPE_INTERIM ),
- function () use ( $wrapped ) {
+ static function () use ( $wrapped ) {
return $wrapped;
},
$ttl,
@@ -1961,7 +1961,7 @@ class WANObjectCache implements
// to distinguish different items. To reuse the code in getWithSetCallback(), wrap the
// callback with a proxy callback that has the standard getWithSetCallback() signature.
// This is defined only once per batch to avoid closure creation overhead.
- $proxyCb = function ( $oldValue, &$ttl, &$setOpts, $oldAsOf, $params ) use ( $callback ) {
+ $proxyCb = static function ( $oldValue, &$ttl, &$setOpts, $oldAsOf, $params ) use ( $callback ) {
return $callback( $params['id'], $oldValue, $ttl, $setOpts, $oldAsOf );
};
@@ -2080,7 +2080,7 @@ class WANObjectCache implements
// to distinguish different items. To reuse the code in getWithSetCallback(), wrap the
// callback with a proxy callback that has the standard getWithSetCallback() signature.
// This is defined only once per batch to avoid closure creation overhead.
- $proxyCb = function ( $oldValue, &$ttl, &$setOpts, $oldAsOf, $params )
+ $proxyCb = static function ( $oldValue, &$ttl, &$setOpts, $oldAsOf, $params )
use ( $callback, $newValsById, $newTTLsById, $newSetOpts )
{
$id = $params['id'];
diff --git a/includes/libs/objectcache/wancache/WANObjectCacheReaper.php b/includes/libs/objectcache/wancache/WANObjectCacheReaper.php
index ff421e94f350..39a8d159ed17 100644
--- a/includes/libs/objectcache/wancache/WANObjectCacheReaper.php
+++ b/includes/libs/objectcache/wancache/WANObjectCacheReaper.php
@@ -153,7 +153,7 @@ class WANObjectCacheReaper implements LoggerAwareInterface {
if ( $lastOkEvent ) {
$ok = $this->store->merge(
$posKey,
- function ( $bag, $key, $curValue ) use ( $lastOkEvent ) {
+ static function ( $bag, $key, $curValue ) use ( $lastOkEvent ) {
if ( !$curValue ) {
// Use new position
} else {
diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php
index b006ec1c9ba8..2127ae2b890f 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -422,10 +422,10 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
'connLogger' => $params['connLogger'] ?? new NullLogger(),
'queryLogger' => $params['queryLogger'] ?? new NullLogger(),
'replLogger' => $params['replLogger'] ?? new NullLogger(),
- 'errorLogger' => $params['errorLogger'] ?? function ( Throwable $e ) {
+ 'errorLogger' => $params['errorLogger'] ?? static function ( Throwable $e ) {
trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
},
- 'deprecationLogger' => $params['deprecationLogger'] ?? function ( $msg ) {
+ 'deprecationLogger' => $params['deprecationLogger'] ?? static function ( $msg ) {
trigger_error( $msg, E_USER_DEPRECATED );
}
];
@@ -754,7 +754,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
* @return string
*/
private function flatAtomicSectionList() {
- return array_reduce( $this->trxAtomicLevels, function ( $accum, $v ) {
+ return array_reduce( $this->trxAtomicLevels, static function ( $accum, $v ) {
return $accum === null ? $v[0] : "$accum, " . $v[0];
} );
}
@@ -4046,13 +4046,13 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
// Cancel the "on commit" callbacks owned by this savepoint
$this->trxPostCommitOrIdleCallbacks = array_filter(
$this->trxPostCommitOrIdleCallbacks,
- function ( $entry ) use ( $sectionIds ) {
+ static function ( $entry ) use ( $sectionIds ) {
return !in_array( $entry[2], $sectionIds, true );
}
);
$this->trxPreCommitOrIdleCallbacks = array_filter(
$this->trxPreCommitOrIdleCallbacks,
- function ( $entry ) use ( $sectionIds ) {
+ static function ( $entry ) use ( $sectionIds ) {
return !in_array( $entry[2], $sectionIds, true );
}
);
diff --git a/includes/libs/rdbms/lbfactory/LBFactory.php b/includes/libs/rdbms/lbfactory/LBFactory.php
index 42fb6f1e9c55..ec91cdae8426 100644
--- a/includes/libs/rdbms/lbfactory/LBFactory.php
+++ b/includes/libs/rdbms/lbfactory/LBFactory.php
@@ -141,10 +141,10 @@ abstract class LBFactory implements ILBFactory {
foreach ( self::$loggerFields as $key ) {
$this->$key = $conf[$key] ?? new NullLogger();
}
- $this->errorLogger = $conf['errorLogger'] ?? function ( Throwable $e ) {
+ $this->errorLogger = $conf['errorLogger'] ?? static function ( Throwable $e ) {
trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
};
- $this->deprecationLogger = $conf['deprecationLogger'] ?? function ( $msg ) {
+ $this->deprecationLogger = $conf['deprecationLogger'] ?? static function ( $msg ) {
trigger_error( $msg, E_USER_DEPRECATED );
};
@@ -245,7 +245,7 @@ abstract class LBFactory implements ILBFactory {
*/
protected function forEachLBCallMethod( $methodName, array $args = [] ) {
$this->forEachLB(
- function ( ILoadBalancer $loadBalancer, $methodName, array $args ) {
+ static function ( ILoadBalancer $loadBalancer, $methodName, array $args ) {
$loadBalancer->$methodName( ...$args );
},
[ $methodName, $args ]
@@ -371,7 +371,7 @@ abstract class LBFactory implements ILBFactory {
*/
private function logIfMultiDbTransaction() {
$callersByDB = [];
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( &$callersByDB ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( &$callersByDB ) {
$masterName = $lb->getServerName( $lb->getWriterIndex() );
$callers = $lb->pendingMasterChangeCallers();
if ( $callers ) {
@@ -391,7 +391,7 @@ abstract class LBFactory implements ILBFactory {
public function hasMasterChanges() {
$ret = false;
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( &$ret ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( &$ret ) {
$ret = $ret || $lb->hasMasterChanges();
} );
@@ -400,7 +400,7 @@ abstract class LBFactory implements ILBFactory {
public function laggedReplicaUsed() {
$ret = false;
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( &$ret ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( &$ret ) {
$ret = $ret || $lb->laggedReplicaUsed();
} );
@@ -409,7 +409,7 @@ abstract class LBFactory implements ILBFactory {
public function hasOrMadeRecentMasterChanges( $age = null ) {
$ret = false;
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( $age, &$ret ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( $age, &$ret ) {
$ret = $ret || $lb->hasOrMadeRecentMasterChanges( $age );
} );
return $ret;
@@ -437,7 +437,7 @@ abstract class LBFactory implements ILBFactory {
} elseif ( $opts['domain'] !== false ) {
$lbs[] = $this->getMainLB( $opts['domain'] );
} else {
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( &$lbs ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( &$lbs ) {
$lbs[] = $lb;
} );
if ( !$lbs ) {
@@ -597,7 +597,7 @@ abstract class LBFactory implements ILBFactory {
ChronologyProtector $cp, $workCallback, $mode, &$cpIndex = null
) {
// Record all the master positions needed
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( $cp ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( $cp ) {
$cp->storeSessionReplicationPosition( $lb );
} );
// Write them to the persistent stash. Try to do something useful by running $work
@@ -611,7 +611,7 @@ abstract class LBFactory implements ILBFactory {
// replica DBs to catch up before responding. Even if there are several DCs, this increases
// the chance that the user will see their own changes immediately afterwards. As long
// as the sticky DC cookie applies (same domain), this is not even an issue.
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( $unsavedPositions ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( $unsavedPositions ) {
$masterName = $lb->getServerName( $lb->getWriterIndex() );
if ( isset( $unsavedPositions[$masterName] ) ) {
$lb->waitForAll( $unsavedPositions[$masterName] );
@@ -697,7 +697,7 @@ abstract class LBFactory implements ILBFactory {
$prefix
);
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( $prefix ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( $prefix ) {
$lb->setLocalDomainPrefix( $prefix );
} );
}
@@ -725,7 +725,7 @@ abstract class LBFactory implements ILBFactory {
public function appendShutdownCPIndexAsQuery( $url, $index ) {
$usedCluster = 0;
- $this->forEachLB( function ( ILoadBalancer $lb ) use ( &$usedCluster ) {
+ $this->forEachLB( static function ( ILoadBalancer $lb ) use ( &$usedCluster ) {
$usedCluster |= $lb->hasStreamingReplicaServers();
} );
diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
index 715d55ad6532..2aba785364b2 100644
--- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php
+++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php
@@ -228,10 +228,10 @@ class LoadBalancer implements ILoadBalancer {
$this->profiler = $params['profiler'] ?? null;
$this->trxProfiler = $params['trxProfiler'] ?? new TransactionProfiler();
- $this->errorLogger = $params['errorLogger'] ?? function ( Throwable $e ) {
+ $this->errorLogger = $params['errorLogger'] ?? static function ( Throwable $e ) {
trigger_error( get_class( $e ) . ': ' . $e->getMessage(), E_USER_WARNING );
};
- $this->deprecationLogger = $params['deprecationLogger'] ?? function ( $msg ) {
+ $this->deprecationLogger = $params['deprecationLogger'] ?? static function ( $msg ) {
trigger_error( $msg, E_USER_DEPRECATED );
};
foreach ( [ 'replLogger', 'connLogger', 'queryLogger', 'perfLogger' ] as $key ) {
@@ -1694,7 +1694,7 @@ class LoadBalancer implements ILoadBalancer {
$total = 0;
do {
$count = 0; // callbacks execution attempts
- $this->forEachOpenMasterConnection( function ( Database $conn ) use ( &$count ) {
+ $this->forEachOpenMasterConnection( static function ( Database $conn ) use ( &$count ) {
// Run any pre-commit callbacks while leaving the post-commit ones suppressed.
// Any error should cause all (peer) transactions to be rolled back together.
$count += $conn->runOnTransactionPreCommitCallbacks();
@@ -1702,7 +1702,7 @@ class LoadBalancer implements ILoadBalancer {
$total += $count;
} while ( $count > 0 );
// Defer post-commit callbacks until after COMMIT/ROLLBACK happens on all handles
- $this->forEachOpenMasterConnection( function ( Database $conn ) {
+ $this->forEachOpenMasterConnection( static function ( Database $conn ) {
$conn->setTrxEndCallbackSuppression( true );
} );
$this->trxRoundStage = self::ROUND_FINALIZED;
@@ -1721,7 +1721,7 @@ class LoadBalancer implements ILoadBalancer {
$limit = $options['maxWriteDuration'] ?? 0;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $limit ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( $limit ) {
// If atomic sections or explicit transactions are still open, some caller must have
// caught an exception but failed to properly rollback any changes. Detect that and
// throw an error (causing rollback).
@@ -1838,7 +1838,7 @@ class LoadBalancer implements ILoadBalancer {
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
// Now that the COMMIT/ROLLBACK step is over, enable post-commit callback runs
- $this->forEachOpenMasterConnection( function ( Database $conn ) {
+ $this->forEachOpenMasterConnection( static function ( Database $conn ) {
$conn->setTrxEndCallbackSuppression( false );
} );
@@ -1849,7 +1849,7 @@ class LoadBalancer implements ILoadBalancer {
// Run any pending callbacks for each connection...
$count = 0; // callback execution attempts
$this->forEachOpenMasterConnection(
- function ( Database $conn ) use ( $type, &$e, &$count ) {
+ static function ( Database $conn ) use ( $type, &$e, &$count ) {
if ( $conn->trxLevel() ) {
return; // retry in the next iteration, after commit() is called
}
@@ -1912,7 +1912,7 @@ class LoadBalancer implements ILoadBalancer {
$e = null;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
- $this->forEachOpenMasterConnection( function ( Database $conn ) use ( $type, &$e ) {
+ $this->forEachOpenMasterConnection( static function ( Database $conn ) use ( $type, &$e ) {
try {
$conn->runTransactionListenerCallbacks( $type );
} catch ( Throwable $ex ) {
@@ -1934,7 +1934,7 @@ class LoadBalancer implements ILoadBalancer {
$restore = ( $this->trxRoundId !== false );
$this->trxRoundId = false;
$this->trxRoundStage = self::ROUND_ERROR; // "failed" until proven otherwise
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $fname ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( $fname ) {
$conn->rollback( $fname, $conn::FLUSHING_ALL_PEERS );
} );
if ( $restore ) {
@@ -1956,7 +1956,7 @@ class LoadBalancer implements ILoadBalancer {
if ( !in_array( $this->trxRoundStage, $stages, true ) ) {
$stageList = implode(
'/',
- array_map( function ( $v ) {
+ array_map( static function ( $v ) {
return "'$v'";
}, $stages )
);
@@ -2032,14 +2032,14 @@ class LoadBalancer implements ILoadBalancer {
public function flushReplicaSnapshots( $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
- $this->forEachOpenReplicaConnection( function ( IDatabase $conn ) use ( $fname ) {
+ $this->forEachOpenReplicaConnection( static function ( IDatabase $conn ) use ( $fname ) {
$conn->flushSnapshot( $fname );
} );
}
public function flushMasterSnapshots( $fname = __METHOD__, $owner = null ) {
$this->assertOwnership( $fname, $owner );
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $fname ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( $fname ) {
$conn->flushSnapshot( $fname );
} );
}
@@ -2058,7 +2058,7 @@ class LoadBalancer implements ILoadBalancer {
public function hasMasterChanges() {
$pending = false;
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( &$pending ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( &$pending ) {
$pending = $pending || $conn->writesOrCallbacksPending();
} );
@@ -2067,7 +2067,7 @@ class LoadBalancer implements ILoadBalancer {
public function lastMasterChangeTimestamp() {
$lastTime = false;
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( &$lastTime ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( &$lastTime ) {
$lastTime = max( $lastTime, $conn->lastDoneWrites() );
} );
@@ -2083,7 +2083,7 @@ class LoadBalancer implements ILoadBalancer {
public function pendingMasterChangeCallers() {
$fnames = [];
- $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( &$fnames ) {
+ $this->forEachOpenMasterConnection( static function ( IDatabase $conn ) use ( &$fnames ) {
$fnames = array_merge( $fnames, $conn->pendingWriteCallers() );
} );
@@ -2153,7 +2153,7 @@ class LoadBalancer implements ILoadBalancer {
$readOnly = $this->srvCache->getWithSetCallback(
$key,
BagOStuff::TTL_PROC_SHORT,
- function () use ( $conn ) {
+ static function () use ( $conn ) {
try {
return (int)$conn->serverIsReadOnly();
} catch ( DBError $e ) {
@@ -2213,7 +2213,7 @@ class LoadBalancer implements ILoadBalancer {
public function pingAll() {
$success = true;
- $this->forEachOpenConnection( function ( IDatabase $conn ) use ( &$success ) {
+ $this->forEachOpenConnection( static function ( IDatabase $conn ) use ( &$success ) {
if ( !$conn->ping() ) {
$success = false;
}
@@ -2390,7 +2390,7 @@ class LoadBalancer implements ILoadBalancer {
unset( $this->trxRecurringCallbacks[$name] );
}
$this->forEachOpenMasterConnection(
- function ( IDatabase $conn ) use ( $name, $callback ) {
+ static function ( IDatabase $conn ) use ( $name, $callback ) {
$conn->setTransactionListener( $name, $callback );
}
);
@@ -2411,7 +2411,7 @@ class LoadBalancer implements ILoadBalancer {
public function setLocalDomainPrefix( $prefix ) {
// Find connections to explicit foreign domains still marked as in-use...
$domainsInUse = [];
- $this->forEachOpenConnection( function ( IDatabase $conn ) use ( &$domainsInUse ) {
+ $this->forEachOpenConnection( static function ( IDatabase $conn ) use ( &$domainsInUse ) {
// Once reuseConnection() is called on a handle, its reference count goes from 1 to 0.
// Until then, it is still in use by the caller (explicitly or via DBConnRef scope).
if ( $conn->getLBInfo( self::$INFO_FOREIGN_REF_COUNT ) > 0 ) {
@@ -2433,7 +2433,7 @@ class LoadBalancer implements ILoadBalancer {
) );
// Update the prefix for all local connections...
- $this->forEachOpenConnection( function ( IDatabase $conn ) use ( $prefix ) {
+ $this->forEachOpenConnection( static function ( IDatabase $conn ) use ( $prefix ) {
if ( !$conn->getLBInfo( self::$INFO_FORIEGN ) ) {
$conn->tablePrefix( $prefix );
}
diff --git a/includes/libs/stats/SamplingStatsdClient.php b/includes/libs/stats/SamplingStatsdClient.php
index 1b92fac6469a..c02d8e3d55fa 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, static function ( $item ) use ( $samplingRates ) {
/** @var StatsdData $item */
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 88ba9815eae3..983dc72e01ba 100644
--- a/includes/libs/virtualrest/VirtualRESTServiceClient.php
+++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php
@@ -102,7 +102,7 @@ class VirtualRESTServiceClient {
* @return array (prefix,VirtualRESTService) or (null,null) if none found
*/
public function getMountAndService( $path ) {
- $cmpFunc = function ( $a, $b ) {
+ $cmpFunc = static function ( $a, $b ) {
$al = substr_count( $a, '/' );
$bl = substr_count( $b, '/' );
return $bl <=> $al; // largest prefix first
@@ -203,7 +203,7 @@ class VirtualRESTServiceClient {
}
// Function to get IDs that won't collide with keys in $armoredIndexMap
- $idFunc = function () use ( &$curUniqueId ) {
+ $idFunc = static function () use ( &$curUniqueId ) {
return $curUniqueId++;
};
diff --git a/includes/logging/RightsLogFormatter.php b/includes/logging/RightsLogFormatter.php
index 90c1017d2f30..d2a17cca62b9 100644
--- a/includes/logging/RightsLogFormatter.php
+++ b/includes/logging/RightsLogFormatter.php
@@ -179,7 +179,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( static function ( $index ) use ( $params, $oldmetadata ) {
$result = [ 'group' => $params['4:array:oldgroups'][$index] ];
if ( isset( $oldmetadata[$index] ) ) {
$result += $oldmetadata[$index];
@@ -196,7 +196,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( static function ( $index ) use ( $params, $newmetadata ) {
$result = [ 'group' => $params['5:array:newgroups'][$index] ];
if ( isset( $newmetadata[$index] ) ) {
$result += $newmetadata[$index];
diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php
index 8a2e247d3c63..19f9ad21d9fa 100644
--- a/includes/mail/UserMailer.php
+++ b/includes/mail/UserMailer.php
@@ -522,7 +522,7 @@ class UserMailer {
}
$out = "=?$charset?Q?";
$out .= preg_replace_callback( "/([$replace])/",
- function ( $matches ) {
+ static function ( $matches ) {
return sprintf( "=%02X", ord( $matches[1] ) );
},
$string
diff --git a/includes/media/DjVuHandler.php b/includes/media/DjVuHandler.php
index b3f164a2d7b9..7ef44c7c4add 100644
--- a/includes/media/DjVuHandler.php
+++ b/includes/media/DjVuHandler.php
@@ -182,7 +182,7 @@ class DjVuHandler extends ImageHandler {
if ( $image->getSize() >= 1e7 ) { // 10MB
$work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $image->getName() ),
[
- 'doWork' => function () use ( $image ) {
+ 'doWork' => static function () use ( $image ) {
return $image->getLocalRefPath();
}
]
diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php
index 17aeda19c7f4..846aa0147f3f 100644
--- a/includes/media/SvgHandler.php
+++ b/includes/media/SvgHandler.php
@@ -280,7 +280,7 @@ class SvgHandler extends ImageHandler {
}
$ok = symlink( $srcPath, $lnPath );
/** @noinspection PhpUnusedLocalVariableInspection */
- $cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) {
+ $cleaner = new ScopedCallback( static function () use ( $tmpDir, $lnPath ) {
Wikimedia\suppressWarnings();
unlink( $lnPath );
rmdir( $tmpDir );
diff --git a/includes/media/TransformationalImageHandler.php b/includes/media/TransformationalImageHandler.php
index 4f1dea5a2d67..311c5eb639d8 100644
--- a/includes/media/TransformationalImageHandler.php
+++ b/includes/media/TransformationalImageHandler.php
@@ -523,7 +523,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
return $cache->getWithSetCallback(
$cache->makeGlobalKey( 'imagemagick-version' ),
$cache::TTL_HOUR,
- function () use ( $method ) {
+ static function () use ( $method ) {
global $wgImageMagickConvertCommand;
$cmd = Shell::escape( $wgImageMagickConvertCommand ) . ' -version';
diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php
index 32ece3183539..dda235a0ddd1 100644
--- a/includes/objectcache/ObjectCache.php
+++ b/includes/objectcache/ObjectCache.php
@@ -181,7 +181,7 @@ class ObjectCache {
}
} elseif ( !isset( $params['localKeyLB'] ) ) {
$params['localKeyLB'] = [
- 'factory' => function () {
+ 'factory' => static function () {
return MediaWikiServices::getInstance()->getDBLoadBalancer();
}
];
diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php
index f979583a843e..9b9da8ae13b9 100644
--- a/includes/objectcache/SqlBagOStuff.php
+++ b/includes/objectcache/SqlBagOStuff.php
@@ -1170,7 +1170,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
}
$loop = new WaitConditionLoop(
- function () use ( $lb, $masterPos ) {
+ static function () use ( $lb, $masterPos ) {
return $lb->waitForAll( $masterPos, 1 );
},
$this->syncTimeout,
@@ -1197,7 +1197,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
$trxProfiler = Profiler::instance()->getTransactionProfiler();
$oldSilenced = $trxProfiler->setSilenced( true );
- return new ScopedCallback( function () use ( $trxProfiler, $oldSilenced ) {
+ return new ScopedCallback( static function () use ( $trxProfiler, $oldSilenced ) {
$trxProfiler->setSilenced( $oldSilenced );
} );
}
diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php
index f5915523c6bc..5a158d5957dd 100644
--- a/includes/page/PageArchive.php
+++ b/includes/page/PageArchive.php
@@ -109,7 +109,7 @@ class PageArchive {
}
$dbr = wfGetDB( DB_REPLICA );
- $condTitles = array_unique( array_map( function ( Title $t ) {
+ $condTitles = array_unique( array_map( static function ( Title $t ) {
return $t->getDBkey();
}, $results ) );
$conds = [
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 042e776ea8c8..7cbbe990e6b9 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -2945,7 +2945,7 @@ class WikiPage implements Page, IDBAccessObject {
$logid = $logEntry->insert();
$dbw->onTransactionPreCommitOrIdle(
- function () use ( $logEntry, $logid ) {
+ static function () use ( $logEntry, $logid ) {
// T58776: avoid deadlocks (especially from FileDeleteForm)
$logEntry->publish( $logid );
},
@@ -3295,7 +3295,7 @@ class WikiPage implements Page, IDBAccessObject {
}
$currentEditorForPublic = $current->getUser( RevisionRecord::FOR_PUBLIC );
- $legacyCurrentCallback = function () use ( $current ) {
+ $legacyCurrentCallback = static function () use ( $current ) {
// Only created when needed
return new Revision( $current );
};
@@ -3527,7 +3527,7 @@ class WikiPage implements Page, IDBAccessObject {
$this->getHookRunner()->onRollbackComplete( $this, $guser, $target, $current );
- $legacyTargetCallback = function () use ( $target ) {
+ $legacyTargetCallback = static function () use ( $target ) {
// Only create the Revision object if needed
return new Revision( $target );
};
@@ -3697,7 +3697,7 @@ class WikiPage implements Page, IDBAccessObject {
// Purge ?action=info cache
$revid = $revRecord ? $revRecord->getId() : null;
- DeferredUpdates::addCallableUpdate( function () use ( $title, $revid ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $title, $revid ) {
InfoAction::invalidateCache( $title, $revid );
} );
@@ -3719,7 +3719,7 @@ class WikiPage implements Page, IDBAccessObject {
return; // @todo: perhaps this wiki is only used as a *source* for content?
}
- DeferredUpdates::addCallableUpdate( function () use ( $title ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $title ) {
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cache->resetCheckKey(
// Do not include the namespace since there can be multiple aliases to it
@@ -3880,7 +3880,7 @@ class WikiPage implements Page, IDBAccessObject {
$cat = Category::newFromName( $catName );
$this->getHookRunner()->onCategoryAfterPageRemoved( $cat, $this, $id );
// Refresh counts on categories that should be empty now (after commit, T166757)
- DeferredUpdates::addCallableUpdate( function () use ( $cat ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $cat ) {
$cat->refreshCountsIfEmpty();
} );
}
@@ -3968,7 +3968,7 @@ class WikiPage implements Page, IDBAccessObject {
$slotContent = [ SlotRecord::MAIN => $rev ];
} else {
- $slotContent = array_map( function ( SlotRecord $slot ) {
+ $slotContent = array_map( static function ( SlotRecord $slot ) {
return $slot->getContent();
}, $rev->getSlots()->getSlots() );
}
@@ -3993,7 +3993,7 @@ class WikiPage implements Page, IDBAccessObject {
$legacyUpdates = $content->getDeletionUpdates( $this );
// HACK: filter out redundant and incomplete LinksDeletionUpdate
- $legacyUpdates = array_filter( $legacyUpdates, function ( $update ) {
+ $legacyUpdates = array_filter( $legacyUpdates, static function ( $update ) {
return !( $update instanceof LinksDeletionUpdate );
} );
diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php
index eacbf60c9b8c..8b2d28c682e1 100644
--- a/includes/pager/IndexPager.php
+++ b/includes/pager/IndexPager.php
@@ -373,7 +373,7 @@ abstract class IndexPager extends ContextSource implements Pager {
$this->mPastTheEndRow = null;
if ( $numRows ) {
- $indexColumns = array_map( function ( $v ) {
+ $indexColumns = array_map( static function ( $v ) {
// Remove any table prefix from index field
$parts = explode( '.', $v );
return end( $parts );
diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php
index c5cae849939e..f5d6a774ee1a 100644
--- a/includes/parser/CoreParserFunctions.php
+++ b/includes/parser/CoreParserFunctions.php
@@ -315,7 +315,7 @@ class CoreParserFunctions {
// take arguments which are not actually formatted numbers,
// which then trigger deprecation warnings in Language::formatNum*.
// Instead emit a tracking category instead to allow linting.
- return function ( $number ) use ( $parser, $callback ) {
+ return static function ( $number ) use ( $parser, $callback ) {
$validNumberRe = '(-(?=[\d\.]))?(\d+|(?=\.\d))(\.\d*)?([Ee][-+]?\d+)?';
if (
!is_numeric( $number ) &&
@@ -326,7 +326,7 @@ class CoreParserFunctions {
$parser->addTrackingCategory( 'nonnumeric-formatnum' );
// Don't split on NAN/INF in the legacy case since they are
// likely to be found embedded inside non-numeric text.
- return preg_replace_callback( "/{$validNumberRe}/", function ( $m ) use ( $callback ) {
+ return preg_replace_callback( "/{$validNumberRe}/", static function ( $m ) use ( $callback ) {
return call_user_func( $callback, $m[0] );
}, $number );
}
@@ -445,7 +445,7 @@ class CoreParserFunctions {
// disallow some styles that could be used to bypass $wgRestrictDisplayTitle
if ( $wgRestrictDisplayTitle ) {
- $htmlTagsCallback = function ( &$params ) {
+ $htmlTagsCallback = static function ( &$params ) {
$decoded = Sanitizer::decodeTagAttributes( $params );
if ( isset( $decoded['style'] ) ) {
diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php
index 58cb19d9e08e..61205ff5c949 100644
--- a/includes/parser/LinkHolderArray.php
+++ b/includes/parser/LinkHolderArray.php
@@ -302,7 +302,7 @@ class LinkHolderArray {
# Do the thing
$text = preg_replace_callback(
'/(<!--LINK\'" .*?-->)/',
- function ( array $matches ) use ( $replacePairs ) {
+ static function ( array $matches ) use ( $replacePairs ) {
return $replacePairs[$matches[1]];
},
$text
@@ -333,7 +333,7 @@ class LinkHolderArray {
$text = preg_replace_callback(
'/<!--IWLINK\'" (.*?)-->/',
- function ( array $matches ) use ( $replacePairs ) {
+ static function ( array $matches ) use ( $replacePairs ) {
return $replacePairs[$matches[1]];
},
$text
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index b46645088811..d11e8434275a 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -785,7 +785,7 @@ class Parser {
// Add on template profiling data in human/machine readable way
$dataByFunc = $this->mProfiler->getFunctionStats();
- uasort( $dataByFunc, function ( $a, $b ) {
+ uasort( $dataByFunc, static function ( $a, $b ) {
return $b['real'] <=> $a['real']; // descending order
} );
$profileReport = [];
@@ -2246,7 +2246,7 @@ class Parser {
# Make sure unsafe characters are encoded
$url = preg_replace_callback( '/[\x00-\x20"<>\[\\\\\]^`{|}\x7F-\xFF]/',
- function ( $m ) {
+ static function ( $m ) {
return rawurlencode( $m[0] );
},
$url
@@ -2290,7 +2290,7 @@ class Parser {
}
private static function normalizeUrlComponent( $component, $unsafe ) {
- $callback = function ( $matches ) use ( $unsafe ) {
+ $callback = static function ( $matches ) use ( $unsafe ) {
$char = urldecode( $matches[0] );
$ord = ord( $char );
if ( $ord > 32 && $ord < 127 && strpos( $unsafe, $char ) === false ) {
@@ -3694,7 +3694,7 @@ class Parser {
$title = $content->getRedirectTarget();
}
- $legacyRevision = function () use ( $revRecord ) {
+ $legacyRevision = static function () use ( $revRecord ) {
return $revRecord ? new Revision( $revRecord ) : null;
};
$retValues = [
@@ -3789,7 +3789,7 @@ class Parser {
sha1( $url )
),
$this->svcOptions->get( 'TranscludeCacheExpiry' ),
- function ( $oldValue, &$ttl ) use ( $url, $fname, $cache ) {
+ static function ( $oldValue, &$ttl ) use ( $url, $fname, $cache ) {
$req = MWHttpRequest::factory( $url, [], $fname );
$status = $req->execute(); // Status object
diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php
index 409959734dcd..c854deaa9891 100644
--- a/includes/parser/ParserOptions.php
+++ b/includes/parser/ParserOptions.php
@@ -816,7 +816,7 @@ class ParserOptions {
if ( $revRecordCb !== [ Parser::class, 'statelessFetchRevisionRecord' ] ) {
// currentRevisionRecordCallback is set and not the default,
// convert it
- $revCb = function ( Title $title, $parser = false ) use ( $revRecordCb ) {
+ $revCb = static function ( Title $title, $parser = false ) use ( $revRecordCb ) {
$revRecord = call_user_func(
$revRecordCb,
$title,
@@ -848,7 +848,7 @@ class ParserOptions {
$revCb = $this->getOption( 'currentRevisionCallback' );
if ( $revCb !== [ Parser::class, 'statelessFetchRevision' ] ) {
// currentRevisionCallback is set and not the default, convert it
- $revRecordCb = function ( Title $title, $parser = null ) use ( $revCb ) {
+ $revRecordCb = static function ( Title $title, $parser = null ) use ( $revCb ) {
$rev = call_user_func( $revCb, $title, $parser ?? false );
if ( $rev ) {
return $rev->getRevisionRecord();
@@ -1490,7 +1490,7 @@ class ParserOptions {
*/
public function setupFakeRevision( $title, $content, $user ) {
$oldCallback = $this->setCurrentRevisionRecordCallback(
- function (
+ static function (
$titleToCheck, $parser = null ) use ( $title, $content, $user, &$oldCallback
) {
if ( $titleToCheck->equals( $title ) ) {
@@ -1509,7 +1509,7 @@ class ParserOptions {
global $wgHooks;
$wgHooks['TitleExists'][] =
- function ( $titleToCheck, &$exists ) use ( $title ) {
+ static function ( $titleToCheck, &$exists ) use ( $title ) {
if ( $titleToCheck->equals( $title ) ) {
$exists = true;
}
@@ -1518,7 +1518,7 @@ class ParserOptions {
$key = key( $wgHooks['TitleExists'] );
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
$linkCache->clearBadLink( $title->getPrefixedDBkey() );
- return new ScopedCallback( function () use ( $title, $key, $linkCache ) {
+ return new ScopedCallback( static function () use ( $title, $key, $linkCache ) {
global $wgHooks;
unset( $wgHooks['TitleExists'][$key] );
$linkCache->clearLink( $title );
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index 6c3c2484bd74..df7f8908ecb1 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -416,7 +416,7 @@ class ParserOutput extends CacheTime {
$seen = [];
$text = preg_replace_callback(
'#<style\s+([^>]*data-mw-deduplicate\s*=[^>]*)>.*?</style>#s',
- function ( $m ) use ( &$seen ) {
+ static function ( $m ) use ( &$seen ) {
$attr = Sanitizer::decodeTagAttributes( $m[1] );
if ( !isset( $attr['data-mw-deduplicate'] ) ) {
return $m[0];
@@ -444,7 +444,7 @@ class ParserOutput extends CacheTime {
// Hydrate slot section header placeholders generated by RevisionRenderer.
$text = preg_replace_callback(
'#<mw:slotheader>(.*?)</mw:slotheader>#',
- function ( $m ) {
+ static function ( $m ) {
$role = htmlspecialchars_decode( $m[1] );
// TODO: map to message, using the interface language. Set lang="xyz" accordingly.
$headerText = $role;
@@ -1427,7 +1427,7 @@ class ParserOutput extends CacheTime {
public function __sleep() {
return array_filter( array_keys( get_object_vars( $this ) ),
- function ( $field ) {
+ static function ( $field ) {
if ( $field === 'mParseStartTime' ) {
return false;
} elseif ( strpos( $field, "\0" ) !== false ) {
diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php
index 87948dbc9e5d..e9f9ee2a4af0 100644
--- a/includes/parser/Sanitizer.php
+++ b/includes/parser/Sanitizer.php
@@ -790,7 +790,7 @@ class Sanitizer {
# Stupid hack
$encValue = preg_replace_callback(
'/((?i)' . wfUrlProtocols() . ')/',
- function ( $matches ) {
+ static function ( $matches ) {
return str_replace( ':', '&#58;', $matches[1] );
},
$encValue );
@@ -1170,7 +1170,7 @@ class Sanitizer {
return "&$name";
} elseif ( isset( HTMLData::$namedEntityTranslations[$name] ) ) {
// Beware: some entities expand to more than 1 codepoint
- return preg_replace_callback( '/./Ssu', function ( $m ) {
+ return preg_replace_callback( '/./Ssu', static function ( $m ) {
return '&#' . UtfNormal\Utils::utf8ToCodepoint( $m[0] ) . ';';
}, HTMLData::$namedEntityTranslations[$name] );
} else {
@@ -1338,7 +1338,7 @@ class Sanitizer {
// For lookup efficiency flip each attributes array so the keys are
// the valid attributes.
- $merge = function ( $a, $b, $c = [] ) {
+ $merge = static function ( $a, $b, $c = [] ) {
return array_merge( $a, array_flip( $b ), array_flip( $c ) );
};
$common = $merge( [], [
diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php
index 272e40fd116b..9abf467ab8bc 100644
--- a/includes/preferences/DefaultPreferencesFactory.php
+++ b/includes/preferences/DefaultPreferencesFactory.php
@@ -1428,7 +1428,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
// Sort by the internal name, so that the ordering is the same for each display language,
// especially if some skin names are translated to use a different alphabet and some are not.
- uksort( $validSkinNames, function ( $a, $b ) use ( $defaultSkin ) {
+ uksort( $validSkinNames, static function ( $a, $b ) use ( $defaultSkin ) {
// Display the default first in the list by comparing it as lesser than any other.
if ( strcasecmp( $a, $defaultSkin ) === 0 ) {
return -1;
diff --git a/includes/preferences/MultiTitleFilter.php b/includes/preferences/MultiTitleFilter.php
index af93c361eeb8..561f8b2bef40 100644
--- a/includes/preferences/MultiTitleFilter.php
+++ b/includes/preferences/MultiTitleFilter.php
@@ -46,7 +46,7 @@ class MultiTitleFilter implements Filter {
if ( !$titles ) {
return '';
}
- return implode( "\n", array_map( function ( Title $title ) {
+ return implode( "\n", array_map( static function ( Title $title ) {
return $title->getPrefixedText();
}, $titles ) );
}
diff --git a/includes/preferences/SignatureValidator.php b/includes/preferences/SignatureValidator.php
index 71344d9c06fb..2d174f216ac2 100644
--- a/includes/preferences/SignatureValidator.php
+++ b/includes/preferences/SignatureValidator.php
@@ -289,7 +289,7 @@ class SignatureValidator {
[ 'type' => $type, 'params' => $params ] = $lintError;
if ( $type === 'bogus-image-options' && isset( $params['items'] ) ) {
- $list = array_map( function ( $in ) {
+ $list = array_map( static function ( $in ) {
return Html::element( 'code', [], $in );
}, $params['items'] );
return implode(
diff --git a/includes/profiler/ProfilerSectionOnly.php b/includes/profiler/ProfilerSectionOnly.php
index 504859d225bb..5a1f874d7402 100644
--- a/includes/profiler/ProfilerSectionOnly.php
+++ b/includes/profiler/ProfilerSectionOnly.php
@@ -72,7 +72,7 @@ class ProfilerSectionOnly extends Profiler {
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
- usort( $data, function ( $a, $b ) {
+ usort( $data, static function ( $a, $b ) {
return $b['real'] <=> $a['real']; // descending
} );
diff --git a/includes/profiler/ProfilerXhprof.php b/includes/profiler/ProfilerXhprof.php
index 41fcc1f699b3..e02512f38daf 100644
--- a/includes/profiler/ProfilerXhprof.php
+++ b/includes/profiler/ProfilerXhprof.php
@@ -198,7 +198,7 @@ class ProfilerXhprof extends Profiler {
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
- usort( $data, function ( $a, $b ) {
+ usort( $data, static function ( $a, $b ) {
return $b['real'] <=> $a['real']; // descending
} );
diff --git a/includes/profiler/output/ProfilerOutputText.php b/includes/profiler/output/ProfilerOutputText.php
index 6fc3cd6cc89c..8cefc37513c6 100644
--- a/includes/profiler/output/ProfilerOutputText.php
+++ b/includes/profiler/output/ProfilerOutputText.php
@@ -48,16 +48,16 @@ class ProfilerOutputText extends ProfilerOutput {
// Filter out really tiny entries
$min = $this->thresholdMs;
- $stats = array_filter( $stats, function ( $a ) use ( $min ) {
+ $stats = array_filter( $stats, static function ( $a ) use ( $min ) {
return $a['real'] > $min;
} );
// Sort descending by time elapsed
- usort( $stats, function ( $a, $b ) {
+ usort( $stats, static function ( $a, $b ) {
return $b['real'] <=> $a['real'];
} );
array_walk( $stats,
- function ( $item ) use ( &$out ) {
+ static function ( $item ) use ( &$out ) {
$out .= sprintf( "%6.2f%% %3.3f %6d - %s\n",
$item['%real'], $item['real'], $item['calls'], $item['name'] );
}
diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php
index 8e5c43e35668..1ad816d2c3f2 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -333,7 +333,7 @@ class ExtensionProcessor implements Processor {
// picking the non-null if one is, or combines
// the two. Note that it is not possible for
// both inputs to be null.
- $pick = function ( $a, $b ) {
+ $pick = static function ( $a, $b ) {
if ( $a === null ) {
return $b;
} elseif ( $b === null ) {
@@ -699,7 +699,7 @@ class ExtensionProcessor implements Processor {
foreach ( $info['config'] as $key => $data ) {
$value = $data['value'];
if ( isset( $data['path'] ) && $data['path'] ) {
- $callback = function ( $value ) use ( $dir ) {
+ $callback = static function ( $value ) use ( $dir ) {
return "$dir/$value";
};
if ( is_array( $value ) ) {
diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php
index 439fe232d8ed..d9a71487ad1f 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -946,7 +946,7 @@ class ResourceLoader implements LoggerAwareInterface {
}
protected function measureResponseTime( Timing $timing ) {
- DeferredUpdates::addCallableUpdate( function () use ( $timing ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $timing ) {
$measure = $timing->measure( 'responseTime', 'requestStart', 'requestShutdown' );
if ( $measure !== false ) {
$stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php
index 24e55ff9fa66..a9c67c7046a5 100644
--- a/includes/resourceloader/ResourceLoaderFileModule.php
+++ b/includes/resourceloader/ResourceLoaderFileModule.php
@@ -638,7 +638,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
// 'getFileHashes' method tracks their content already.
// It is important that the keys of the $packageFiles['files'] array
// are preserved, as they do affect the module output.
- $packageFiles['files'] = array_map( function ( $fileInfo ) {
+ $packageFiles['files'] = array_map( static function ( $fileInfo ) {
return $fileInfo['definitionSummary'] ?? ( $fileInfo['content'] ?? null );
}, $packageFiles['files'] );
}
diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php
index 9fc3bdadf035..3d3539ced663 100644
--- a/includes/resourceloader/ResourceLoaderModule.php
+++ b/includes/resourceloader/ResourceLoaderModule.php
@@ -546,7 +546,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
*/
public static function getRelativePaths( array $filePaths ) {
global $IP;
- return array_map( function ( $path ) use ( $IP ) {
+ return array_map( static function ( $path ) use ( $IP ) {
return RelPath::getRelativePath( $path, $IP );
}, $filePaths );
}
@@ -560,7 +560,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
*/
public static function expandRelativePaths( array $filePaths ) {
global $IP;
- return array_map( function ( $path ) use ( $IP ) {
+ return array_map( static function ( $path ) use ( $IP ) {
return RelPath::joinPath( $IP, $path );
}, $filePaths );
}
@@ -974,7 +974,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
$fileName
),
$cache::TTL_WEEK,
- function () use ( $contents, $fileName ) {
+ static function () use ( $contents, $fileName ) {
$parser = new JSParser();
try {
// Ignore compiler warnings (T77169)
diff --git a/includes/resourceloader/ResourceLoaderOOUIImageModule.php b/includes/resourceloader/ResourceLoaderOOUIImageModule.php
index 9f04242d2e12..0c5c03c10ada 100644
--- a/includes/resourceloader/ResourceLoaderOOUIImageModule.php
+++ b/includes/resourceloader/ResourceLoaderOOUIImageModule.php
@@ -130,7 +130,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule {
// Expand the paths to images (since they are relative to the JSON file that defines them, not
// our base directory)
- $fixPath = function ( &$path ) use ( $dataPath ) {
+ $fixPath = static function ( &$path ) use ( $dataPath ) {
if ( $dataPath instanceof ResourceLoaderFilePath ) {
$path = new ResourceLoaderFilePath(
dirname( $dataPath->getPath() ) . '/' . $path,
@@ -142,7 +142,7 @@ class ResourceLoaderOOUIImageModule extends ResourceLoaderImageModule {
}
};
// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
- array_walk( $data['images'], function ( &$value ) use ( $fixPath ) {
+ array_walk( $data['images'], static function ( &$value ) use ( $fixPath ) {
if ( is_string( $value['file'] ) ) {
$fixPath( $value['file'] );
} elseif ( is_array( $value['file'] ) ) {
diff --git a/includes/resourceloader/ResourceLoaderSkinModule.php b/includes/resourceloader/ResourceLoaderSkinModule.php
index 94fbaba8b391..d1616dd13f64 100644
--- a/includes/resourceloader/ResourceLoaderSkinModule.php
+++ b/includes/resourceloader/ResourceLoaderSkinModule.php
@@ -217,7 +217,7 @@ class ResourceLoaderSkinModule extends ResourceLoaderLessVarFileModule {
}
$this->features = array_filter(
array_keys( $enabledFeatures ),
- function ( $key ) use ( $enabledFeatures ) {
+ static function ( $key ) use ( $enabledFeatures ) {
return $enabledFeatures[ $key ];
}
);
@@ -352,7 +352,7 @@ class ResourceLoaderSkinModule extends ResourceLoaderLessVarFileModule {
}
// Because PHP can't have floats as array keys
- uksort( $logosPerDppx, function ( $a, $b ) {
+ uksort( $logosPerDppx, static function ( $a, $b ) {
$a = floatval( $a );
$b = floatval( $b );
// Sort from smallest to largest (e.g. 1x, 1.5x, 2x)
diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php
index 6b9b16268d6d..0ad9cd6428f9 100644
--- a/includes/resourceloader/ResourceLoaderWikiModule.php
+++ b/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -498,7 +498,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
$allInfo = $cache->getWithSetCallback(
$cache->makeGlobalKey( 'resourceloader-titleinfo', $db->getDomainID(), $hash ),
$cache::TTL_HOUR,
- function ( $curVal, &$ttl, array &$setOpts ) use ( $func, $pageNames, $db, $fname ) {
+ static function ( $curVal, &$ttl, array &$setOpts ) use ( $func, $pageNames, $db, $fname ) {
$setOpts += Database::getCacheSetOptions( $db );
return call_user_func( $func, $db, $pageNames, $fname );
diff --git a/includes/search/FauxSearchResultSet.php b/includes/search/FauxSearchResultSet.php
index 20db0c45582a..c5585567b776 100644
--- a/includes/search/FauxSearchResultSet.php
+++ b/includes/search/FauxSearchResultSet.php
@@ -21,7 +21,7 @@ class FauxSearchResultSet extends SearchResultSet {
$totalHits = max( count( $results ), $totalHits );
$hasMoreResults = count( $results ) < $totalHits;
parent::__construct( false, $hasMoreResults );
- $this->results = array_map( function ( $result ) {
+ $this->results = array_map( static function ( $result ) {
if ( $result instanceof SearchResult ) {
return $result;
} elseif ( $result instanceof Title ) {
diff --git a/includes/search/PrefixSearch.php b/includes/search/PrefixSearch.php
index a28348bc1339..6a3a512ddbcd 100644
--- a/includes/search/PrefixSearch.php
+++ b/includes/search/PrefixSearch.php
@@ -167,7 +167,7 @@ abstract class PrefixSearch {
$special = $spFactory->getPage( $specialTitle->getText() );
if ( $special ) {
$subpages = $special->prefixSearchSubpages( $subpageSearch, $limit, $offset );
- return array_map( function ( $sub ) use ( $specialTitle ) {
+ return array_map( static function ( $sub ) use ( $specialTitle ) {
return $specialTitle->getSubpage( $sub );
}, $subpages );
} else {
diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php
index 26b527a1b901..64f4b8a380ee 100644
--- a/includes/search/SearchEngine.php
+++ b/includes/search/SearchEngine.php
@@ -309,7 +309,7 @@ abstract class SearchEngine {
if ( $namespaces ) {
// Filter namespaces to only keep valid ones
$validNs = MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces();
- $namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) {
+ $namespaces = array_filter( $namespaces, static function ( $ns ) use( $validNs ) {
return $ns < 0 || isset( $validNs[$ns] );
} );
} else {
@@ -642,7 +642,7 @@ abstract class SearchEngine {
* @return Title[]
*/
public function extractTitles( SearchSuggestionSet $completionResults ) {
- return $completionResults->map( function ( SearchSuggestion $sugg ) {
+ return $completionResults->map( static function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle();
} );
}
@@ -662,13 +662,13 @@ abstract class SearchEngine {
$search = trim( $search );
// preload the titles with LinkBatch
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
- $lb = $linkBatchFactory->newLinkBatch( $suggestions->map( function ( SearchSuggestion $sugg ) {
+ $lb = $linkBatchFactory->newLinkBatch( $suggestions->map( static function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle();
} ) );
$lb->setCaller( __METHOD__ );
$lb->execute();
- $diff = $suggestions->filter( function ( SearchSuggestion $sugg ) {
+ $diff = $suggestions->filter( static function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle()->isKnown();
} );
if ( $diff > 0 ) {
@@ -676,7 +676,7 @@ abstract class SearchEngine {
->updateCount( 'search.completion.missing', $diff );
}
- $results = $suggestions->map( function ( SearchSuggestion $sugg ) {
+ $results = $suggestions->map( static function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle()->getPrefixedText();
} );
diff --git a/includes/search/SearchResultSet.php b/includes/search/SearchResultSet.php
index af8e1c966903..fe5537f16aec 100644
--- a/includes/search/SearchResultSet.php
+++ b/includes/search/SearchResultSet.php
@@ -229,7 +229,7 @@ class SearchResultSet extends BaseSearchResultSet {
$this->titles = [];
} else {
$this->titles = array_map(
- function ( SearchResult $result ) {
+ static function ( SearchResult $result ) {
return $result->getTitle();
},
$this->extractResults() );
diff --git a/includes/search/SearchResultTrait.php b/includes/search/SearchResultTrait.php
index 9a0df2560a4d..b4279d5db254 100644
--- a/includes/search/SearchResultTrait.php
+++ b/includes/search/SearchResultTrait.php
@@ -36,7 +36,7 @@ trait SearchResultTrait {
$this->extensionData = $extensionData;
} elseif ( is_array( $extensionData ) ) {
wfDeprecated( __METHOD__ . ' with array argument', '1.32' );
- $this->extensionData = function () use ( $extensionData ) {
+ $this->extensionData = static function () use ( $extensionData ) {
return $extensionData;
};
} else {
diff --git a/includes/search/SearchSuggestionSet.php b/includes/search/SearchSuggestionSet.php
index ebaa133d4de7..9c3a3849f38b 100644
--- a/includes/search/SearchSuggestionSet.php
+++ b/includes/search/SearchSuggestionSet.php
@@ -208,7 +208,7 @@ class SearchSuggestionSet {
*/
public static function fromTitles( array $titles, $hasMoreResults = false ) {
$score = count( $titles );
- $suggestions = array_map( function ( $title ) use ( &$score ) {
+ $suggestions = array_map( static function ( $title ) use ( &$score ) {
return SearchSuggestion::fromTitle( $score--, $title );
}, $titles );
return new SearchSuggestionSet( $suggestions, $hasMoreResults );
@@ -225,7 +225,7 @@ class SearchSuggestionSet {
*/
public static function fromStrings( array $titles, $hasMoreResults = false ) {
$score = count( $titles );
- $suggestions = array_map( function ( $title ) use ( &$score ) {
+ $suggestions = array_map( static function ( $title ) use ( &$score ) {
return SearchSuggestion::fromText( $score--, $title );
}, $titles );
return new SearchSuggestionSet( $suggestions, $hasMoreResults );
diff --git a/includes/search/StringPrefixSearch.php b/includes/search/StringPrefixSearch.php
index 433500bf9bda..fddbb67c3d79 100644
--- a/includes/search/StringPrefixSearch.php
+++ b/includes/search/StringPrefixSearch.php
@@ -32,7 +32,7 @@ class StringPrefixSearch extends PrefixSearch {
* @return string[]
*/
protected function titles( array $titles ) {
- return array_map( function ( Title $t ) {
+ return array_map( static function ( Title $t ) {
return $t->getPrefixedText();
}, $titles );
}
diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php
index 7cf6f6dd683b..2335cf715662 100644
--- a/includes/session/SessionBackend.php
+++ b/includes/session/SessionBackend.php
@@ -691,7 +691,7 @@ final class SessionBackend {
if ( !wfReadOnly() ) {
// Promise that the token set here will be valid; save it at end of request
$user = $this->user;
- \DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ \DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
$user->saveSettings();
} );
}
diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php
index bc1ad479f43c..0f469d329f11 100644
--- a/includes/session/SessionManager.php
+++ b/includes/session/SessionManager.php
@@ -560,7 +560,7 @@ final class SessionManager implements SessionManagerInterface {
return $this->loadSessionInfoFromStore( $info, $request );
};
} else {
- $failHandler = function () {
+ $failHandler = static function () {
return false;
};
}
diff --git a/includes/site/MediaWikiPageNameNormalizer.php b/includes/site/MediaWikiPageNameNormalizer.php
index a81ddca92488..54ad44d214d0 100644
--- a/includes/site/MediaWikiPageNameNormalizer.php
+++ b/includes/site/MediaWikiPageNameNormalizer.php
@@ -178,7 +178,7 @@ class MediaWikiPageNameNormalizer {
// Filter the substructure down to what we actually are using.
$collectedHits = array_filter(
array_values( $externalData['query'][$listId] ),
- function ( $a ) use ( $fieldId, $pageTitle ) {
+ static function ( $a ) use ( $fieldId, $pageTitle ) {
return $a[$fieldId] === $pageTitle;
}
);
diff --git a/includes/skins/SkinFallback.php b/includes/skins/SkinFallback.php
index 6b8d1f6fdbab..7494e51ee10f 100644
--- a/includes/skins/SkinFallback.php
+++ b/includes/skins/SkinFallback.php
@@ -29,12 +29,12 @@ class SkinFallback extends SkinMustache {
$styleDirectory = $config->get( 'StyleDirectory' );
// Get all subdirectories which might contains skins
$possibleSkins = scandir( $styleDirectory );
- $possibleSkins = array_filter( $possibleSkins, function ( $maybeDir ) use ( $styleDirectory ) {
+ $possibleSkins = array_filter( $possibleSkins, static function ( $maybeDir ) use ( $styleDirectory ) {
return $maybeDir !== '.' && $maybeDir !== '..' && is_dir( "$styleDirectory/$maybeDir" );
} );
// Filter out skins that aren't installed
- $possibleSkins = array_filter( $possibleSkins, function ( $skinDir ) use ( $styleDirectory ) {
+ $possibleSkins = array_filter( $possibleSkins, static function ( $skinDir ) use ( $styleDirectory ) {
return is_file( "$styleDirectory/$skinDir/skin.json" )
|| is_file( "$styleDirectory/$skinDir/$skinDir.php" );
} );
diff --git a/includes/specialpage/AuthManagerSpecialPage.php b/includes/specialpage/AuthManagerSpecialPage.php
index fca9c1f1999b..023673b76d40 100644
--- a/includes/specialpage/AuthManagerSpecialPage.php
+++ b/includes/specialpage/AuthManagerSpecialPage.php
@@ -714,7 +714,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
] );
if ( isset( $singleFieldInfo['options'] ) ) {
- $descriptor['options'] = array_flip( array_map( function ( $message ) {
+ $descriptor['options'] = array_flip( array_map( static function ( $message ) {
/** @var Message $message */
return $message->parse();
}, $singleFieldInfo['options'] ) );
diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php
index 5e16a5b81e24..a8f16b0d7ab2 100644
--- a/includes/specialpage/ChangesListSpecialPage.php
+++ b/includes/specialpage/ChangesListSpecialPage.php
@@ -128,7 +128,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhideliu
'showHideSuffix' => 'showhideliu',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$actorMigration = ActorMigration::newMigration();
@@ -146,7 +146,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhideanons
'showHideSuffix' => 'showhideanons',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$actorMigration = ActorMigration::newMigration();
@@ -171,7 +171,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
'cssClassSuffix' => 'user-unregistered',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return !$rc->getAttribute( 'rc_user' );
}
],
@@ -180,7 +180,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-user-experience-level-registered-label',
'description' => 'rcfilters-filter-user-experience-level-registered-description',
'cssClassSuffix' => 'user-registered',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_user' );
}
],
@@ -189,7 +189,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
'cssClassSuffix' => 'user-newcomer',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'newcomer';
@@ -200,7 +200,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-user-experience-level-learner-label',
'description' => 'rcfilters-filter-user-experience-level-learner-description',
'cssClassSuffix' => 'user-learner',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'learner';
@@ -211,7 +211,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-user-experience-level-experienced-label',
'description' => 'rcfilters-filter-user-experience-level-experienced-description',
'cssClassSuffix' => 'user-experienced',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'experienced';
@@ -235,7 +235,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhidemine
'showHideSuffix' => 'showhidemine',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() );
@@ -244,7 +244,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$conds[] = 'NOT(' . $actorQuery['conds'] . ')';
},
'cssClassSuffix' => 'self',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $ctx->getUser()->equals( $rc->getPerformer() );
},
],
@@ -253,7 +253,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-editsbyother-label',
'description' => 'rcfilters-filter-editsbyother-description',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$actorQuery = ActorMigration::newMigration()
@@ -263,7 +263,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$conds[] = $actorQuery['conds'];
},
'cssClassSuffix' => 'others',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return !$ctx->getUser()->equals( $rc->getPerformer() );
},
]
@@ -283,13 +283,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhidebots
'showHideSuffix' => 'showhidebots',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds['rc_bot'] = 0;
},
'cssClassSuffix' => 'bot',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_bot' );
},
],
@@ -298,13 +298,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-humans-label',
'description' => 'rcfilters-filter-humans-description',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds['rc_bot'] = 1;
},
'cssClassSuffix' => 'human',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return !$rc->getAttribute( 'rc_bot' );
},
]
@@ -327,13 +327,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhideminor
'showHideSuffix' => 'showhideminor',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_minor = 0';
},
'cssClassSuffix' => 'minor',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_minor' );
}
],
@@ -342,13 +342,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-major-label',
'description' => 'rcfilters-filter-major-description',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_minor = 1';
},
'cssClassSuffix' => 'major',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return !$rc->getAttribute( 'rc_minor' );
}
]
@@ -366,7 +366,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-lastrevision-label',
'description' => 'rcfilters-filter-lastrevision-description',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
$conds[] = $dbr->makeList(
[
@@ -377,7 +377,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
);
},
'cssClassSuffix' => 'last',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
}
],
@@ -386,7 +386,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-previousrevision-label',
'description' => 'rcfilters-filter-previousrevision-description',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
$conds[] = $dbr->makeList(
[
@@ -397,7 +397,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
);
},
'cssClassSuffix' => 'previous',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
}
]
@@ -417,13 +417,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'description' => 'rcfilters-filter-pageedits-description',
'default' => false,
'priority' => -2,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
},
'cssClassSuffix' => 'src-mw-edit',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
},
],
@@ -433,13 +433,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'description' => 'rcfilters-filter-newpages-description',
'default' => false,
'priority' => -3,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
},
'cssClassSuffix' => 'src-mw-new',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
},
],
@@ -452,13 +452,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'description' => 'rcfilters-filter-logactions-description',
'default' => false,
'priority' => -5,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
},
'cssClassSuffix' => 'src-mw-log',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
}
],
@@ -479,7 +479,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
// wlshowhidepatr
'showHideSuffix' => 'showhidepatr',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
@@ -489,7 +489,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
[
'name' => 'hideunpatrolled',
'default' => false,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
@@ -513,7 +513,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
'cssClassSuffix' => 'reviewstatus-unpatrolled',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
},
],
@@ -522,7 +522,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-reviewstatus-manual-label',
'description' => 'rcfilters-filter-reviewstatus-manual-description',
'cssClassSuffix' => 'reviewstatus-manual',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
},
],
@@ -531,13 +531,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'label' => 'rcfilters-filter-reviewstatus-auto-label',
'description' => 'rcfilters-filter-reviewstatus-auto-description',
'cssClassSuffix' => 'reviewstatus-auto',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
},
],
],
'default' => ChangesListStringOptionsFilterGroup::NONE,
- 'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
+ 'queryCallable' => static function ( $specialPageClassName, $ctx, $dbr,
&$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
) {
if ( $selected === [] ) {
@@ -549,7 +549,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'auto' => RecentChange::PRC_AUTOPATROLLED,
];
// e.g. rc_patrolled IN (0, 2)
- $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
+ $conds['rc_patrolled'] = array_map( static function ( $s ) use ( $rcPatrolledValues ) {
return $rcPatrolledValues[ $s ];
}, $selected );
}
@@ -565,13 +565,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'showHideSuffix' => 'showhidecategorization',
'default' => false,
'priority' => -4,
- 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
+ 'queryCallable' => static function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
&$query_options, &$join_conds
) {
$conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
},
'cssClassSuffix' => 'src-mw-categorize',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
},
];
@@ -918,7 +918,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
return $cache->getWithSetCallback(
$cache->makeKey( 'ChangesListSpecialPage-changeTagListSummary', $context->getLanguage() ),
WANObjectCache::TTL_DAY,
- function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
+ static function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
$explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
$softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
@@ -988,7 +988,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
}
// Instead of sorting by hit count (disabled for now), sort by display name
- usort( $tags, function ( $a, $b ) {
+ usort( $tags, static function ( $a, $b ) {
return strcasecmp( $a['label'], $b['label'] );
} );
return $tags;
@@ -1293,7 +1293,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'messageKeys' => [],
];
- usort( $this->filterGroups, function ( $a, $b ) {
+ usort( $this->filterGroups, static function ( $a, $b ) {
return $b->getPriority() <=> $a->getPriority();
} );
@@ -1405,7 +1405,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$allInGroupEnabled = array_reduce(
$filters,
- function ( $carry, $filter ) use ( $opts ) {
+ static function ( $carry, $filter ) use ( $opts ) {
return $carry && $opts[ $filter->getName() ];
},
/* initialValue */ count( $filters ) > 0
@@ -1544,7 +1544,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
$namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
$namespaces = array_filter(
$namespaces,
- function ( $ns ) use ( $namespaceInfo ) {
+ static function ( $ns ) use ( $namespaceInfo ) {
return $namespaceInfo->exists( $ns );
}
);
@@ -1555,12 +1555,12 @@ abstract class ChangesListSpecialPage extends SpecialPage {
if ( $opts[ 'associated' ] ) {
$associatedNamespaces = array_map(
- function ( $ns ) use ( $namespaceInfo ){
+ static function ( $ns ) use ( $namespaceInfo ){
return $namespaceInfo->getAssociated( $ns );
},
array_filter(
$namespaces,
- function ( $ns ) use ( $namespaceInfo ) {
+ static function ( $ns ) use ( $namespaceInfo ) {
return $namespaceInfo->hasTalkNamespace( $ns );
}
)
diff --git a/includes/specialpage/DisabledSpecialPage.php b/includes/specialpage/DisabledSpecialPage.php
index ebcd8e58cc69..07af1c112980 100644
--- a/includes/specialpage/DisabledSpecialPage.php
+++ b/includes/specialpage/DisabledSpecialPage.php
@@ -44,7 +44,7 @@ class DisabledSpecialPage extends UnlistedSpecialPage {
* @return Closure
*/
public static function getCallback( $name, $errorMessage = null ) {
- return function () use ( $name, $errorMessage ) {
+ return static function () use ( $name, $errorMessage ) {
return new DisabledSpecialPage( $name, $errorMessage );
};
}
diff --git a/includes/specialpage/FormSpecialPage.php b/includes/specialpage/FormSpecialPage.php
index e5edf3b4a461..e948da3ebaf5 100644
--- a/includes/specialpage/FormSpecialPage.php
+++ b/includes/specialpage/FormSpecialPage.php
@@ -108,7 +108,7 @@ abstract class FormSpecialPage extends SpecialPage {
// But don't treat it as a "real" submission just in case of some
// crazy kind of CSRF.
- $onSubmit = function () {
+ $onSubmit = static function () {
return false;
};
}
diff --git a/includes/specialpage/SpecialPage.php b/includes/specialpage/SpecialPage.php
index 97cab91bc04e..599d4336f178 100644
--- a/includes/specialpage/SpecialPage.php
+++ b/includes/specialpage/SpecialPage.php
@@ -587,7 +587,7 @@ class SpecialPage implements MessageLocalizer {
$searchEngine->setLimitOffset( $limit, $offset );
$searchEngine->setNamespaces( [] );
$result = $searchEngine->defaultPrefixSearch( $search );
- return array_map( function ( Title $t ) {
+ return array_map( static function ( Title $t ) {
return $t->getPrefixedText();
}, $result );
}
diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php
index 87a221b1dd43..a3ceea8f67f9 100644
--- a/includes/specials/SpecialBlock.php
+++ b/includes/specials/SpecialBlock.php
@@ -838,7 +838,7 @@ class SpecialBlock extends FormSpecialPage {
}
}
if ( isset( $data['NamespaceRestrictions'] ) && $data['NamespaceRestrictions'] !== '' ) {
- $namespaceRestrictions = array_map( function ( $id ) {
+ $namespaceRestrictions = array_map( static function ( $id ) {
return new NamespaceRestriction( 0, $id );
}, explode( "\n", $data['NamespaceRestrictions'] ) );
}
diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php
index 3cceb0dce7c0..29f1bcecb4e5 100644
--- a/includes/specials/SpecialBotPasswords.php
+++ b/includes/specials/SpecialBotPasswords.php
@@ -147,7 +147,7 @@ class SpecialBotPasswords extends FormSpecialPage {
$showGrants
),
'default' => array_map(
- function ( $g ) {
+ static function ( $g ) {
return "grant-$g";
},
$this->botPassword->getGrants()
@@ -155,14 +155,14 @@ class SpecialBotPasswords extends FormSpecialPage {
'tooltips' => array_combine(
array_map( [ MWGrants::class, 'getGrantsLink' ], $showGrants ),
array_map(
- function ( $rights ) use ( $lang ) {
+ static function ( $rights ) use ( $lang ) {
return $lang->semicolonList( array_map( [ User::class, 'getRightDescription' ], $rights ) );
},
array_intersect_key( MWGrants::getRightsByGrant(), array_flip( $showGrants ) )
)
),
'force-options-on' => array_map(
- function ( $g ) {
+ static function ( $g ) {
return "grant-$g";
},
MWGrants::getHiddenGrants()
@@ -220,7 +220,7 @@ class SpecialBotPasswords extends FormSpecialPage {
'required' => true,
'size' => BotPassword::APPID_MAXLENGTH,
'maxlength' => BotPassword::APPID_MAXLENGTH,
- 'validation-callback' => function ( $v ) {
+ 'validation-callback' => static function ( $v ) {
$v = trim( $v );
return $v !== '' && strlen( $v ) <= BotPassword::APPID_MAXLENGTH;
},
diff --git a/includes/specials/SpecialFileDuplicateSearch.php b/includes/specials/SpecialFileDuplicateSearch.php
index 1fac2834ce37..69dec6800368 100644
--- a/includes/specials/SpecialFileDuplicateSearch.php
+++ b/includes/specials/SpecialFileDuplicateSearch.php
@@ -286,7 +286,7 @@ class SpecialFileDuplicateSearch extends QueryPage {
$searchEngine->setNamespaces( [ NS_FILE ] );
$result = $searchEngine->defaultPrefixSearch( $search );
- return array_map( function ( Title $t ) {
+ return array_map( static function ( Title $t ) {
// Remove namespace in search suggestion
return $t->getText();
}, $result );
diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php
index 3601e785d512..b894ec28fd96 100644
--- a/includes/specials/SpecialMovepage.php
+++ b/includes/specials/SpecialMovepage.php
@@ -181,7 +181,7 @@ class MovePageForm extends UnlistedSpecialPage {
$permErrors = $this->permManager->getPermissionErrors( 'move', $user, $this->oldTitle );
if ( count( $permErrors ) ) {
// Auto-block user's IP if the account was "hard" blocked
- DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
$user->spreadAnyEditBlock();
} );
throw new PermissionsError( 'move', $permErrors );
diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php
index e325e12ea6e2..5b5d501cce91 100644
--- a/includes/specials/SpecialNewpages.php
+++ b/includes/specials/SpecialNewpages.php
@@ -379,7 +379,7 @@ class SpecialNewpages extends IncludableSpecialPage {
// The form should be visible on each request (inclusive requests with submitted forms), so
// return always false here.
->setSubmitCallback(
- function () {
+ static function () {
return false;
}
)
diff --git a/includes/specials/SpecialRecentChanges.php b/includes/specials/SpecialRecentChanges.php
index 448b592a8838..79fce18f6c91 100644
--- a/includes/specials/SpecialRecentChanges.php
+++ b/includes/specials/SpecialRecentChanges.php
@@ -92,7 +92,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
'label' => 'rcfilters-filter-watchlist-watched-label',
'description' => 'rcfilters-filter-watchlist-watched-description',
'cssClassSuffix' => 'watched',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' );
}
],
@@ -101,7 +101,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
'label' => 'rcfilters-filter-watchlist-watchednew-label',
'description' => 'rcfilters-filter-watchlist-watchednew-description',
'cssClassSuffix' => 'watchednew',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' ) &&
$rc->getAttribute( 'rc_timestamp' ) &&
$rc->getAttribute( 'wl_notificationtimestamp' ) &&
@@ -113,7 +113,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
'label' => 'rcfilters-filter-watchlist-notwatched-label',
'description' => 'rcfilters-filter-watchlist-notwatched-description',
'cssClassSuffix' => 'notwatched',
- 'isRowApplicableCallable' => function ( $ctx, $rc ) {
+ 'isRowApplicableCallable' => static function ( $ctx, $rc ) {
return $rc->getAttribute( 'wl_user' ) === null;
},
]
@@ -437,7 +437,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
* @return array
*/
protected function getFeedQuery() {
- $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
+ $query = array_filter( $this->getOptions()->getAllValues(), static function ( $value ) {
// API handles empty parameters in a different way
return $value !== '';
} );
diff --git a/includes/specials/SpecialResetTokens.php b/includes/specials/SpecialResetTokens.php
index 3f1d80d6245c..792f3888e562 100644
--- a/includes/specials/SpecialResetTokens.php
+++ b/includes/specials/SpecialResetTokens.php
@@ -52,7 +52,7 @@ class SpecialResetTokens extends FormSpecialPage {
$this->getHookRunner()->onSpecialResetTokensTokens( $tokens );
$hiddenPrefs = $this->getConfig()->get( 'HiddenPrefs' );
- $tokens = array_filter( $tokens, function ( $tok ) use ( $hiddenPrefs ) {
+ $tokens = array_filter( $tokens, static function ( $tok ) use ( $hiddenPrefs ) {
return !in_array( $tok['preference'], $hiddenPrefs );
} );
diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php
index 663e35aee8f1..c2418917b040 100644
--- a/includes/specials/SpecialSearch.php
+++ b/includes/specials/SpecialSearch.php
@@ -752,7 +752,7 @@ class SpecialSearch extends SpecialPage {
$this->userOptionsManager->setOption( $user, 'searchNs' . $n, true );
}
- DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
$user->saveSettings();
} );
diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php
index d4fd764203aa..540eed08f781 100644
--- a/includes/specials/SpecialUserrights.php
+++ b/includes/specials/SpecialUserrights.php
@@ -400,7 +400,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 ) {
+ static function ( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) {
if ( isset( $groupExpiries[$group] ) &&
!in_array( $group, $removable ) &&
isset( $ugms[$group] ) &&
diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php
index fcf071df5d81..fd38cfd61472 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -592,7 +592,7 @@ class SpecialVersion extends SpecialPage {
// in their proper section
continue;
}
- $authors = array_map( function ( $arr ) {
+ $authors = array_map( static function ( $arr ) {
// If a homepage is set, link to it
if ( isset( $arr['homepage'] ) ) {
return "[{$arr['homepage']} {$arr['name']}]";
@@ -653,7 +653,7 @@ class SpecialVersion extends SpecialPage {
)
);
- array_walk( $tags, function ( &$value ) {
+ array_walk( $tags, static function ( &$value ) {
// Bidirectional isolation improves readability in RTL wikis
$value = Html::element(
'bdi',
diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php
index e99560af97d5..5659020bc8e2 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -252,7 +252,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
],
],
'default' => ChangesListStringOptionsFilterGroup::NONE,
- 'queryCallable' => function (
+ 'queryCallable' => static function (
$specialPageClassName,
$context,
IDatabase $dbr,
diff --git a/includes/specials/SpecialWhatLinksHere.php b/includes/specials/SpecialWhatLinksHere.php
index cc19b4025c2c..c9234530d1e0 100644
--- a/includes/specials/SpecialWhatLinksHere.php
+++ b/includes/specials/SpecialWhatLinksHere.php
@@ -210,7 +210,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
$conds['pagelinks']['rd_from'] = null;
}
- $queryFunc = function ( IDatabase $dbr, $table, $fromCol ) use (
+ $queryFunc = static function ( IDatabase $dbr, $table, $fromCol ) use (
$conds, $target, $limit
) {
// Read an extra row as an at-end check
diff --git a/includes/specials/pagers/BlockListPager.php b/includes/specials/pagers/BlockListPager.php
index 45b83afa0dbf..77941a2b07c1 100644
--- a/includes/specials/pagers/BlockListPager.php
+++ b/includes/specials/pagers/BlockListPager.php
@@ -283,7 +283,7 @@ class BlockListPager extends TablePager {
$formatted = Html::rawElement(
'ul',
[],
- implode( '', array_map( function ( $prop ) {
+ implode( '', array_map( static function ( $prop ) {
return Html::rawElement(
'li',
[],
diff --git a/includes/tidy/RemexDriver.php b/includes/tidy/RemexDriver.php
index 803369a654af..75031adbe947 100644
--- a/includes/tidy/RemexDriver.php
+++ b/includes/tidy/RemexDriver.php
@@ -30,7 +30,7 @@ class RemexDriver extends TidyDriverBase {
}
public function tidy( $text ) {
- $traceCallback = function ( $msg ) {
+ $traceCallback = static function ( $msg ) {
wfDebug( "RemexHtml: $msg" );
};
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 0bf3c8ee05d2..e2096dd3d308 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -750,7 +750,7 @@ abstract class UploadBase {
* @return mixed[]
*/
public static function makeWarningsSerializable( $warnings ) {
- array_walk_recursive( $warnings, function ( &$param, $key ) {
+ array_walk_recursive( $warnings, static function ( &$param, $key ) {
if ( $param instanceof File ) {
$param = [
'fileName' => $param->getName(),
diff --git a/includes/user/CentralIdLookup.php b/includes/user/CentralIdLookup.php
index 58dcd5526bcf..154b5ccb6b52 100644
--- a/includes/user/CentralIdLookup.php
+++ b/includes/user/CentralIdLookup.php
@@ -204,7 +204,7 @@ abstract class CentralIdLookup implements IDBAccessObject {
$idToName = array_fill_keys( $ids, false );
$names = $this->lookupCentralIds( $idToName, $audience, $flags );
$names = array_unique( $names );
- $names = array_filter( $names, function ( $name ) {
+ $names = array_filter( $names, static function ( $name ) {
return $name !== false && $name !== '';
} );
@@ -242,7 +242,7 @@ abstract class CentralIdLookup implements IDBAccessObject {
$nameToId = array_fill_keys( $names, false );
$ids = $this->lookupUserNames( $nameToId, $audience, $flags );
$ids = array_unique( $ids );
- $ids = array_filter( $ids, function ( $id ) {
+ $ids = array_filter( $ids, static function ( $id ) {
return $id !== false;
} );
diff --git a/includes/user/User.php b/includes/user/User.php
index 1e0fb2acab50..4bfe9261c2c8 100644
--- a/includes/user/User.php
+++ b/includes/user/User.php
@@ -2332,7 +2332,7 @@ class User implements Authority, IDBAccessObject, UserIdentity {
$cache->delete( $key, 1 ); // low tombstone/"hold-off" TTL
} else {
$lb->getConnectionRef( DB_MASTER )->onTransactionPreCommitOrIdle(
- function () use ( $cache, $key ) {
+ static function () use ( $cache, $key ) {
$cache->delete( $key );
},
__METHOD__
diff --git a/includes/user/UserRightsProxy.php b/includes/user/UserRightsProxy.php
index 4218b5f0158d..9ce61235a80a 100644
--- a/includes/user/UserRightsProxy.php
+++ b/includes/user/UserRightsProxy.php
@@ -296,7 +296,7 @@ class UserRightsProxy {
$domainId = $this->db->getDomainID();
$userId = $this->id;
$this->db->onTransactionPreCommitOrIdle(
- function () use ( $domainId, $userId ) {
+ static function () use ( $domainId, $userId ) {
User::purge( $domainId, $userId );
},
__METHOD__
diff --git a/includes/user/WatchlistNotificationManager.php b/includes/user/WatchlistNotificationManager.php
index 46f9d633ecfa..a574949f0fb9 100644
--- a/includes/user/WatchlistNotificationManager.php
+++ b/includes/user/WatchlistNotificationManager.php
@@ -192,7 +192,7 @@ class WatchlistNotificationManager {
// Try to update the DB post-send and only if needed...
$talkPageNotificationManager = $this->talkPageNotificationManager;
$revisionLookup = $this->revisionLookup;
- DeferredUpdates::addCallableUpdate( function () use (
+ DeferredUpdates::addCallableUpdate( static function () use (
$user,
$oldid,
$talkPageNotificationManager,
diff --git a/includes/utils/BatchRowUpdate.php b/includes/utils/BatchRowUpdate.php
index 198996e91816..7243e1dbd2fe 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 ( $text ) {
+ $this->output = static function ( $text ) {
}; // nop
}
diff --git a/includes/watcheditem/WatchedItemQueryService.php b/includes/watcheditem/WatchedItemQueryService.php
index 96fc5b2be3ea..f390ace8b4ad 100644
--- a/includes/watcheditem/WatchedItemQueryService.php
+++ b/includes/watcheditem/WatchedItemQueryService.php
@@ -377,7 +377,7 @@ class WatchedItemQueryService {
$allFields = get_object_vars( $row );
$rcKeys = array_filter(
array_keys( $allFields ),
- function ( $key ) {
+ static function ( $key ) {
return substr( $key, 0, 3 ) === 'rc_';
}
);
diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php
index 75b9617a57f1..4221f98de4ef 100644
--- a/includes/watcheditem/WatchedItemStore.php
+++ b/includes/watcheditem/WatchedItemStore.php
@@ -1144,7 +1144,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
$expiry = $dbw->timestamp( $expiry );
- $weRows = array_map( function ( $wlId ) use ( $expiry, $dbw ) {
+ $weRows = array_map( static function ( $wlId ) use ( $expiry, $dbw ) {
return [
'we_item' => $wlId,
'we_expiry' => $expiry
@@ -1282,7 +1282,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
// Calls DeferredUpdates::addCallableUpdate in normal operation
call_user_func(
$this->deferredUpdatesAddCallableUpdateCallback,
- function () use ( $job ) {
+ static function () use ( $job ) {
$job->run();
}
);