build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0

The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
This commit is contained in:
Umherirrender 2017-06-26 18:35:31 +02:00
parent 3f849d695f
commit be42e09aa8
77 changed files with 216 additions and 222 deletions

View file

@ -377,7 +377,7 @@ class MediaWikiServices extends ServiceContainer {
parent::__construct();
// Register the given Config object as the bootstrap config service.
$this->defineService( 'BootstrapConfig', function() use ( $config ) {
$this->defineService( 'BootstrapConfig', function () use ( $config ) {
return $config;
} );
}

View file

@ -55,7 +55,7 @@ class PageProps {
}
$previousValue = self::$instance;
self::$instance = $store;
return new ScopedCallback( function() use ( $previousValue ) {
return new ScopedCallback( function () use ( $previousValue ) {
self::$instance = $previousValue;
} );
}

View file

@ -43,7 +43,7 @@ use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
return [
'DBLoadBalancerFactory' => function( MediaWikiServices $services ) {
'DBLoadBalancerFactory' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
$lbConf = MWLBFactory::applyDefaultConfig(
@ -56,12 +56,12 @@ return [
return new $class( $lbConf );
},
'DBLoadBalancer' => function( MediaWikiServices $services ) {
'DBLoadBalancer' => function ( MediaWikiServices $services ) {
// just return the default LB from the DBLoadBalancerFactory service
return $services->getDBLoadBalancerFactory()->getMainLB();
},
'SiteStore' => function( MediaWikiServices $services ) {
'SiteStore' => function ( MediaWikiServices $services ) {
$rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
// TODO: replace wfGetCache with a CacheFactory service.
@ -71,7 +71,7 @@ return [
return new CachingSiteStore( $rawSiteStore, $cache );
},
'SiteLookup' => function( MediaWikiServices $services ) {
'SiteLookup' => function ( MediaWikiServices $services ) {
$cacheFile = $services->getMainConfig()->get( 'SitesCacheFile' );
if ( $cacheFile !== false ) {
@ -82,7 +82,7 @@ return [
}
},
'ConfigFactory' => function( MediaWikiServices $services ) {
'ConfigFactory' => function ( MediaWikiServices $services ) {
// Use the bootstrap config to initialize the ConfigFactory.
$registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
$factory = new ConfigFactory();
@ -93,12 +93,12 @@ return [
return $factory;
},
'MainConfig' => function( MediaWikiServices $services ) {
'MainConfig' => function ( MediaWikiServices $services ) {
// Use the 'main' config from the ConfigFactory service.
return $services->getConfigFactory()->makeConfig( 'main' );
},
'InterwikiLookup' => function( MediaWikiServices $services ) {
'InterwikiLookup' => function ( MediaWikiServices $services ) {
global $wgContLang; // TODO: manage $wgContLang as a service
$config = $services->getMainConfig();
return new ClassicInterwikiLookup(
@ -111,26 +111,26 @@ return [
);
},
'StatsdDataFactory' => function( MediaWikiServices $services ) {
'StatsdDataFactory' => function ( MediaWikiServices $services ) {
return new BufferingStatsdDataFactory(
rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
);
},
'EventRelayerGroup' => function( MediaWikiServices $services ) {
'EventRelayerGroup' => function ( MediaWikiServices $services ) {
return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
},
'SearchEngineFactory' => function( MediaWikiServices $services ) {
'SearchEngineFactory' => function ( MediaWikiServices $services ) {
return new SearchEngineFactory( $services->getSearchEngineConfig() );
},
'SearchEngineConfig' => function( MediaWikiServices $services ) {
'SearchEngineConfig' => function ( MediaWikiServices $services ) {
global $wgContLang;
return new SearchEngineConfig( $services->getMainConfig(), $wgContLang );
},
'SkinFactory' => function( MediaWikiServices $services ) {
'SkinFactory' => function ( MediaWikiServices $services ) {
$factory = new SkinFactory();
$names = $services->getMainConfig()->get( 'ValidSkinNames' );
@ -153,7 +153,7 @@ return [
return $factory;
},
'WatchedItemStore' => function( MediaWikiServices $services ) {
'WatchedItemStore' => function ( MediaWikiServices $services ) {
$store = new WatchedItemStore(
$services->getDBLoadBalancer(),
new HashBagOStuff( [ 'maxKeys' => 100 ] ),
@ -163,11 +163,11 @@ return [
return $store;
},
'WatchedItemQueryService' => function( MediaWikiServices $services ) {
'WatchedItemQueryService' => function ( MediaWikiServices $services ) {
return new WatchedItemQueryService( $services->getDBLoadBalancer() );
},
'CryptRand' => function( MediaWikiServices $services ) {
'CryptRand' => function ( MediaWikiServices $services ) {
$secretKey = $services->getMainConfig()->get( 'SecretKey' );
return new CryptRand(
[
@ -178,7 +178,7 @@ return [
// for a little more variance
'wfWikiID',
// If we have a secret key set then throw it into the state as well
function() use ( $secretKey ) {
function () use ( $secretKey ) {
return $secretKey ?: '';
}
],
@ -192,7 +192,7 @@ return [
);
},
'CryptHKDF' => function( MediaWikiServices $services ) {
'CryptHKDF' => function ( MediaWikiServices $services ) {
$config = $services->getMainConfig();
$secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
@ -215,13 +215,13 @@ return [
);
},
'MediaHandlerFactory' => function( MediaWikiServices $services ) {
'MediaHandlerFactory' => function ( MediaWikiServices $services ) {
return new MediaHandlerFactory(
$services->getMainConfig()->get( 'MediaHandlers' )
);
},
'MimeAnalyzer' => function( MediaWikiServices $services ) {
'MimeAnalyzer' => function ( MediaWikiServices $services ) {
$logger = LoggerFactory::getInstance( 'Mime' );
$mainConfig = $services->getMainConfig();
$params = [
@ -274,7 +274,7 @@ return [
return new MimeMagic( $params );
},
'ProxyLookup' => function( MediaWikiServices $services ) {
'ProxyLookup' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
return new ProxyLookup(
$mainConfig->get( 'SquidServers' ),
@ -282,26 +282,26 @@ return [
);
},
'Parser' => function( MediaWikiServices $services ) {
'Parser' => function ( MediaWikiServices $services ) {
$conf = $services->getMainConfig()->get( 'ParserConf' );
return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] );
},
'LinkCache' => function( MediaWikiServices $services ) {
'LinkCache' => function ( MediaWikiServices $services ) {
return new LinkCache(
$services->getTitleFormatter(),
$services->getMainWANObjectCache()
);
},
'LinkRendererFactory' => function( MediaWikiServices $services ) {
'LinkRendererFactory' => function ( MediaWikiServices $services ) {
return new LinkRendererFactory(
$services->getTitleFormatter(),
$services->getLinkCache()
);
},
'LinkRenderer' => function( MediaWikiServices $services ) {
'LinkRenderer' => function ( MediaWikiServices $services ) {
global $wgUser;
if ( defined( 'MW_NO_SESSION' ) ) {
@ -311,11 +311,11 @@ return [
}
},
'GenderCache' => function( MediaWikiServices $services ) {
'GenderCache' => function ( MediaWikiServices $services ) {
return new GenderCache();
},
'_MediaWikiTitleCodec' => function( MediaWikiServices $services ) {
'_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) {
global $wgContLang;
return new MediaWikiTitleCodec(
@ -325,15 +325,15 @@ return [
);
},
'TitleFormatter' => function( MediaWikiServices $services ) {
'TitleFormatter' => function ( MediaWikiServices $services ) {
return $services->getService( '_MediaWikiTitleCodec' );
},
'TitleParser' => function( MediaWikiServices $services ) {
'TitleParser' => function ( MediaWikiServices $services ) {
return $services->getService( '_MediaWikiTitleCodec' );
},
'MainObjectStash' => function( MediaWikiServices $services ) {
'MainObjectStash' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
$id = $mainConfig->get( 'MainStash' );
@ -345,7 +345,7 @@ return [
return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
},
'MainWANObjectCache' => function( MediaWikiServices $services ) {
'MainWANObjectCache' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
$id = $mainConfig->get( 'MainWANCache' );
@ -365,7 +365,7 @@ return [
return \ObjectCache::newWANCacheFromParams( $params );
},
'LocalServerObjectCache' => function( MediaWikiServices $services ) {
'LocalServerObjectCache' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
if ( function_exists( 'apc_fetch' ) ) {
@ -388,7 +388,7 @@ return [
return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
},
'VirtualRESTServiceClient' => function( MediaWikiServices $services ) {
'VirtualRESTServiceClient' => function ( MediaWikiServices $services ) {
$config = $services->getMainConfig()->get( 'VirtualRestConfig' );
$vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
@ -406,11 +406,11 @@ return [
return $vrsClient;
},
'ConfiguredReadOnlyMode' => function( MediaWikiServices $services ) {
'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) {
return new ConfiguredReadOnlyMode( $services->getMainConfig() );
},
'ReadOnlyMode' => function( MediaWikiServices $services ) {
'ReadOnlyMode' => function ( MediaWikiServices $services ) {
return new ReadOnlyMode(
$services->getConfiguredReadOnlyMode(),
$services->getDBLoadBalancer()

View file

@ -313,7 +313,7 @@ class WatchedItemQueryService {
$allFields = get_object_vars( $row );
$rcKeys = array_filter(
array_keys( $allFields ),
function( $key ) {
function ( $key ) {
return substr( $key, 0, 3 ) === 'rc_';
}
);

View file

@ -104,7 +104,7 @@ class WatchedItemStore implements StatsdAwareInterface {
}
$previousValue = $this->deferredUpdatesAddCallableUpdateCallback;
$this->deferredUpdatesAddCallableUpdateCallback = $callback;
return new ScopedCallback( function() use ( $previousValue ) {
return new ScopedCallback( function () use ( $previousValue ) {
$this->deferredUpdatesAddCallableUpdateCallback = $previousValue;
} );
}
@ -127,7 +127,7 @@ class WatchedItemStore implements StatsdAwareInterface {
}
$previousValue = $this->revisionGetTimestampFromIdCallback;
$this->revisionGetTimestampFromIdCallback = $callback;
return new ScopedCallback( function() use ( $previousValue ) {
return new ScopedCallback( function () use ( $previousValue ) {
$this->revisionGetTimestampFromIdCallback = $previousValue;
} );
}
@ -821,7 +821,7 @@ class WatchedItemStore implements StatsdAwareInterface {
// Calls DeferredUpdates::addCallableUpdate in normal operation
call_user_func(
$this->deferredUpdatesAddCallableUpdateCallback,
function() use ( $job ) {
function () use ( $job ) {
$job->run();
}
);

View file

@ -826,4 +826,3 @@ class Xml {
return $s;
}
}

View file

@ -766,7 +766,7 @@ class ApiQueryInfo extends ApiQueryBase {
if ( $this->fld_watched ) {
foreach ( $timestamps as $namespaceId => $dbKeys ) {
$this->watched[$namespaceId] = array_map(
function( $x ) {
function ( $x ) {
return $x !== false;
},
$dbKeys
@ -847,7 +847,7 @@ class ApiQueryInfo extends ApiQueryBase {
$timestamps[$row->page_namespace][$row->page_title] = $revTimestamp - $age;
}
$titlesWithThresholds = array_map(
function( LinkTarget $target ) use ( $timestamps ) {
function ( LinkTarget $target ) use ( $timestamps ) {
return [
$target, $timestamps[$target->getNamespace()][$target->getDBkey()]
];
@ -860,7 +860,7 @@ class ApiQueryInfo extends ApiQueryBase {
$titlesWithThresholds = array_merge(
$titlesWithThresholds,
array_map(
function( LinkTarget $target ) {
function ( LinkTarget $target ) {
return [ $target, null ];
},
$this->missing

View file

@ -54,7 +54,7 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase {
$titles = $searchEngine->extractTitles( $searchEngine->completionSearchWithVariants( $search ) );
if ( $resultPageSet ) {
$resultPageSet->setRedirectMergePolicy( function( array $current, array $new ) {
$resultPageSet->setRedirectMergePolicy( function ( array $current, array $new ) {
if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) {
$current['index'] = $new['index'];
}

View file

@ -214,7 +214,7 @@ class ApiQueryUsers extends ApiQueryBase {
}
if ( isset( $this->prop['groupmemberships'] ) ) {
$data[$key]['groupmemberships'] = array_map( function( $ugm ) {
$data[$key]['groupmemberships'] = array_map( function ( $ugm ) {
return [
'group' => $ugm->getGroup(),
'expiry' => ApiResult::formatExpiry( $ugm->getExpiry() ),

View file

@ -685,7 +685,7 @@ class EnhancedChangesList extends ChangesList {
}
$attribs = $data['attribs'];
unset( $data['attribs'] );
$attribs = wfArrayFilterByKey( $attribs, function( $key ) {
$attribs = wfArrayFilterByKey( $attribs, function ( $key ) {
return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
} );

View file

@ -847,7 +847,7 @@ class DifferenceEngine extends ContextSource {
* @return bool|string
*/
public function generateTextDiffBody( $otext, $ntext ) {
$diff = function() use ( $otext, $ntext ) {
$diff = function () use ( $otext, $ntext ) {
$time = microtime( true );
$result = $this->textDiff( $otext, $ntext );
@ -867,7 +867,7 @@ class DifferenceEngine extends ContextSource {
* @param Status $status
* @throws FatalError
*/
$error = function( $status ) {
$error = function ( $status ) {
throw new FatalError( $status->getWikiText() );
};

View file

@ -73,7 +73,7 @@ class ForeignDBViaLBRepo extends LocalRepo {
* @return Closure
*/
protected function getDBFactory() {
return function( $index ) {
return function ( $index ) {
return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki );
};
}

View file

@ -483,7 +483,7 @@ class LocalRepo extends FileRepo {
* @return Closure
*/
protected function getDBFactory() {
return function( $index ) {
return function ( $index ) {
return wfGetDB( $index );
};
}

View file

@ -593,7 +593,7 @@ class LocalFile extends File {
if ( $upgrade ) {
$this->upgrading = true;
// Defer updates unless in auto-commit CLI mode
DeferredUpdates::addCallableUpdate( function() {
DeferredUpdates::addCallableUpdate( function () {
$this->upgrading = false; // avoid duplicate updates
try {
$this->upgradeRow();

View file

@ -26,7 +26,7 @@ trait HTMLFormElement {
// And it's not needed anymore after infusing, so we don't put it in JS config at all.
$this->setAttributes( [ 'data-mw-modules' => implode( ',', $this->modules ) ] );
}
$this->registerConfigCallback( function( &$config ) {
$this->registerConfigCallback( function ( &$config ) {
if ( $this->hideIf !== null ) {
$config['hideIf'] = $this->hideIf;
}

View file

@ -23,7 +23,7 @@ class HTMLUsersMultiselectField extends HTMLUserTextField {
$usersArray = explode( "\n", $request->getText( $this->mName ) );
// Remove empty lines
$usersArray = array_values( array_filter( $usersArray, function( $username ) {
$usersArray = array_values( array_filter( $usersArray, function ( $username ) {
return trim( $username ) !== '';
} ) );
return $usersArray;

View file

@ -336,7 +336,7 @@ abstract class DatabaseInstaller {
$services = \MediaWiki\MediaWikiServices::getInstance();
$connection = $status->value;
$services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
$services->redefineService( 'DBLoadBalancerFactory', function () use ( $connection ) {
return LBFactorySingle::newFromConnection( $connection );
} );
}

View file

@ -384,7 +384,7 @@ abstract class Installer {
// make sure we use the installer config as the main config
$configRegistry = $baseConfig->get( 'ConfigRegistry' );
$configRegistry['main'] = function() use ( $installerConfig ) {
$configRegistry['main'] = function () use ( $installerConfig ) {
return $installerConfig;
};

View file

@ -356,7 +356,7 @@ class CSSMin {
// Re-insert comments
$pattern = '/' . CSSMin::PLACEHOLDER . '(\d+)x/';
$source = preg_replace_callback( $pattern, function( $match ) use ( &$comments ) {
$source = preg_replace_callback( $pattern, function ( $match ) use ( &$comments ) {
return $comments[ $match[1] ];
}, $source );

View file

@ -179,7 +179,7 @@ class HashRing {
if ( $this->liveRing === null || $this->ejectionNextExpiry <= $now ) {
$this->ejectionExpiries = array_filter(
$this->ejectionExpiries,
function( $expiry ) use ( $now ) {
function ( $expiry ) use ( $now ) {
return ( $expiry > $now );
}
);

View file

@ -196,7 +196,7 @@ class FileBackendMultiWrite extends FileBackend {
if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) {
// Bind $scopeLock to the callback to preserve locks
DeferredUpdates::addCallableUpdate(
function() use ( $backend, $realOps, $opts, $scopeLock, $relevantPaths ) {
function () use ( $backend, $realOps, $opts, $scopeLock, $relevantPaths ) {
wfDebugLog( 'FileOperationReplication',
"'{$backend->getName()}' async replication; paths: " .
FormatJson::encode( $relevantPaths ) );
@ -508,7 +508,7 @@ class FileBackendMultiWrite extends FileBackend {
$realOps = $this->substOpBatchPaths( $ops, $backend );
if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) {
DeferredUpdates::addCallableUpdate(
function() use ( $backend, $realOps ) {
function () use ( $backend, $realOps ) {
$backend->doQuickOperations( $realOps );
}
);
@ -562,7 +562,7 @@ class FileBackendMultiWrite extends FileBackend {
$realParams = $this->substOpPaths( $params, $backend );
if ( $this->asyncWrites ) {
DeferredUpdates::addCallableUpdate(
function() use ( $backend, $method, $realParams ) {
function () use ( $backend, $method, $realParams ) {
$backend->$method( $realParams );
}
);

View file

@ -475,7 +475,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
$lSince = microtime( true ); // lock timestamp
return new ScopedCallback( function() use ( $key, $lSince, $expiry ) {
return new ScopedCallback( function () use ( $key, $lSince, $expiry ) {
$latency = .050; // latency skew (err towards keeping lock present)
$age = ( microtime( true ) - $lSince + $latency );
if ( ( $age + $latency ) >= $expiry ) {

View file

@ -1046,4 +1046,3 @@ class DatabaseSqlite extends Database {
}
class_alias( DatabaseSqlite::class, 'DatabaseSqlite' );

View file

@ -63,4 +63,3 @@ class FakeResultWrapper extends ResultWrapper {
}
class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );

View file

@ -28,4 +28,3 @@ class DBTransactionError extends DBExpectedError {
}
class_alias( DBTransactionError::class, 'DBTransactionError' );

View file

@ -530,7 +530,7 @@ abstract class LBFactory implements ILBFactory {
$prefix
);
$this->forEachLB( function( ILoadBalancer $lb ) use ( $prefix ) {
$this->forEachLB( function ( ILoadBalancer $lb ) use ( $prefix ) {
$lb->setDomainPrefix( $prefix );
} );
}

View file

@ -55,7 +55,7 @@ class SamplingStatsdClient extends StatsdClient {
$samplingRates = [ '*' => $sampleRate ];
}
if ( $samplingRates ) {
array_walk( $data, function( $item ) use ( $samplingRates ) {
array_walk( $data, function ( $item ) use ( $samplingRates ) {
/** @var $item StatsdData */
foreach ( $samplingRates as $pattern => $rate ) {
if ( fnmatch( $pattern, $item->getKey(), FNM_NOESCAPE ) ) {

View file

@ -103,7 +103,7 @@ class VirtualRESTServiceClient {
* @return array (prefix,VirtualRESTService) or (null,null) if none found
*/
public function getMountAndService( $path ) {
$cmpFunc = function( $a, $b ) {
$cmpFunc = function ( $a, $b ) {
$al = substr_count( $a, '/' );
$bl = substr_count( $b, '/' );
if ( $al === $bl ) {
@ -207,7 +207,7 @@ class VirtualRESTServiceClient {
}
// Function to get IDs that won't collide with keys in $armoredIndexMap
$idFunc = function() use ( &$curUniqueId ) {
$idFunc = function () use ( &$curUniqueId ) {
return $curUniqueId++;
};

View file

@ -38,7 +38,7 @@ class PageDataRequestHandler {
$parts = explode( '/', $subPage, 2 );
if ( $parts !== 2 ) {
$slot = $parts[0];
if ( $slot === 'main' or $slot === '' ) {
if ( $slot === 'main' || $slot === '' ) {
return true;
}
}

View file

@ -176,7 +176,7 @@ class RightsLogFormatter extends LogFormatter {
$oldmetadata =& $params['oldmetadata'];
// unset old metadata entry to ensure metadata goes at the end of the params array
unset( $params['oldmetadata'] );
$params['oldmetadata'] = array_map( function( $index ) use ( $params, $oldmetadata ) {
$params['oldmetadata'] = array_map( function ( $index ) use ( $params, $oldmetadata ) {
$result = [ 'group' => $params['4:array:oldgroups'][$index] ];
if ( isset( $oldmetadata[$index] ) ) {
$result += $oldmetadata[$index];
@ -194,7 +194,7 @@ class RightsLogFormatter extends LogFormatter {
$newmetadata =& $params['newmetadata'];
// unset old metadata entry to ensure metadata goes at the end of the params array
unset( $params['newmetadata'] );
$params['newmetadata'] = array_map( function( $index ) use ( $params, $newmetadata ) {
$params['newmetadata'] = array_map( function ( $index ) use ( $params, $newmetadata ) {
$result = [ 'group' => $params['5:array:newgroups'][$index] ];
if ( isset( $newmetadata[$index] ) ) {
$result += $newmetadata[$index];

View file

@ -3334,7 +3334,7 @@ class WikiPage implements Page, IDBAccessObject {
HTMLFileCache::clearFileCache( $title );
$revid = $revision ? $revision->getId() : null;
DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) {
DeferredUpdates::addCallableUpdate( function () use ( $title, $revid ) {
InfoAction::invalidateCache( $title, $revid );
} );
}

View file

@ -6070,7 +6070,7 @@ class Parser {
$e = new Exception;
$this->mInParse = $e->getTraceAsString();
$recursiveCheck = new ScopedCallback( function() {
$recursiveCheck = new ScopedCallback( function () {
$this->mInParse = false;
} );

View file

@ -73,7 +73,7 @@ class ProfilerSectionOnly extends Profiler {
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
usort( $data, function( $a, $b ) {
usort( $data, function ( $a, $b ) {
if ( $a['real'] === $b['real'] ) {
return 0;
}

View file

@ -201,7 +201,7 @@ class ProfilerXhprof extends Profiler {
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
usort( $data, function( $a, $b ) {
usort( $data, function ( $a, $b ) {
if ( $a['real'] === $b['real'] ) {
return 0;
}

View file

@ -378,7 +378,7 @@ class ExtensionProcessor implements Processor {
protected function extractExtensionMessagesFiles( $dir, array $info ) {
if ( isset( $info['ExtensionMessagesFiles'] ) ) {
$this->globals["wgExtensionMessagesFiles"] += array_map( function( $file ) use ( $dir ) {
$this->globals["wgExtensionMessagesFiles"] += array_map( function ( $file ) use ( $dir ) {
return "$dir/$file";
}, $info['ExtensionMessagesFiles'] );
}

View file

@ -400,7 +400,7 @@ class ExtensionRegistry {
protected function processAutoLoader( $dir, array $info ) {
if ( isset( $info['AutoloadClasses'] ) ) {
// Make paths absolute, relative to the JSON file
return array_map( function( $file ) use ( $dir ) {
return array_map( function ( $file ) use ( $dir ) {
return "$dir/$file";
}, $info['AutoloadClasses'] );
} else {

View file

@ -236,7 +236,7 @@ abstract class SearchEngine {
if ( $namespaces ) {
// Filter namespaces to only keep valid ones
$validNs = $this->searchableNamespaces();
$namespaces = array_filter( $namespaces, function( $ns ) use( $validNs ) {
$namespaces = array_filter( $namespaces, function ( $ns ) use( $validNs ) {
return $ns < 0 || isset( $validNs[$ns] );
} );
} else {
@ -464,7 +464,7 @@ abstract class SearchEngine {
}
}
$ns = array_map( function( $space ) {
$ns = array_map( function ( $space ) {
return $space == NS_MEDIA ? NS_FILE : $space;
}, $ns );
@ -550,7 +550,7 @@ abstract class SearchEngine {
* @return Title[]
*/
public function extractTitles( SearchSuggestionSet $completionResults ) {
return $completionResults->map( function( SearchSuggestion $sugg ) {
return $completionResults->map( function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle();
} );
}
@ -564,14 +564,14 @@ abstract class SearchEngine {
protected function processCompletionResults( $search, SearchSuggestionSet $suggestions ) {
$search = trim( $search );
// preload the titles with LinkBatch
$titles = $suggestions->map( function( SearchSuggestion $sugg ) {
$titles = $suggestions->map( function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle();
} );
$lb = new LinkBatch( $titles );
$lb->setCaller( __METHOD__ );
$lb->execute();
$results = $suggestions->map( function( SearchSuggestion $sugg ) {
$results = $suggestions->map( function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle()->getPrefixedText();
} );

View file

@ -180,7 +180,7 @@ class SearchSuggestionSet {
*/
public static function fromTitles( array $titles ) {
$score = count( $titles );
$suggestions = array_map( function( $title ) use ( &$score ) {
$suggestions = array_map( function ( $title ) use ( &$score ) {
return SearchSuggestion::fromTitle( $score--, $title );
}, $titles );
return new SearchSuggestionSet( $suggestions );
@ -196,7 +196,7 @@ class SearchSuggestionSet {
*/
public static function fromStrings( array $titles ) {
$score = count( $titles );
$suggestions = array_map( function( $title ) use ( &$score ) {
$suggestions = array_map( function ( $title ) use ( &$score ) {
return SearchSuggestion::fromText( $score--, $title );
}, $titles );
return new SearchSuggestionSet( $suggestions );

View file

@ -456,7 +456,7 @@ class SpecialPage implements MessageLocalizer {
$searchEngine->setLimitOffset( $limit, $offset );
$searchEngine->setNamespaces( [] );
$result = $searchEngine->defaultPrefixSearch( $search );
return array_map( function( Title $t ) {
return array_map( function ( Title $t ) {
return $t->getPrefixedText();
}, $result );
}

View file

@ -123,7 +123,7 @@ class SpecialBotPasswords extends FormSpecialPage {
$showGrants
),
'default' => array_map(
function( $g ) {
function ( $g ) {
return "grant-$g";
},
$this->botPassword->getGrants()
@ -131,14 +131,14 @@ class SpecialBotPasswords extends FormSpecialPage {
'tooltips' => array_combine(
array_map( 'MWGrants::getGrantsLink', $showGrants ),
array_map(
function( $rights ) use ( $lang ) {
function ( $rights ) use ( $lang ) {
return $lang->semicolonList( array_map( 'User::getRightDescription', $rights ) );
},
array_intersect_key( MWGrants::getRightsByGrant(), array_flip( $showGrants ) )
)
),
'force-options-on' => array_map(
function( $g ) {
function ( $g ) {
return "grant-$g";
},
MWGrants::getHiddenGrants()

View file

@ -115,7 +115,7 @@ class SpecialChangeContentModel extends FormSpecialPage {
'reason' => [
'type' => 'text',
'name' => 'reason',
'validation-callback' => function( $reason ) {
'validation-callback' => function ( $reason ) {
$match = EditPage::matchSummarySpamRegex( $reason );
if ( $match ) {
return $this->msg( 'spamprotectionmatch', $match )->parse();

View file

@ -105,7 +105,7 @@ class MovePageForm extends UnlistedSpecialPage {
$permErrors = $this->oldTitle->getUserPermissionsErrors( 'move', $user );
if ( count( $permErrors ) ) {
// Auto-block user's IP if the account was "hard" blocked
DeferredUpdates::addCallableUpdate( function() use ( $user ) {
DeferredUpdates::addCallableUpdate( function () use ( $user ) {
$user->spreadAnyEditBlock();
} );
throw new PermissionsError( 'move', $permErrors );

View file

@ -344,7 +344,7 @@ class UserrightsPage extends SpecialPage {
// UNLESS the user can only add this group (not remove it) and the expiry time
// is being brought forward (T156784)
$add = array_filter( $add,
function( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) {
function ( $group ) use ( $groups, $groupExpiries, $removable, $ugms ) {
if ( isset( $groupExpiries[$group] ) &&
!in_array( $group, $removable ) &&
isset( $ugms[$group] ) &&
@ -437,12 +437,12 @@ class UserrightsPage extends SpecialPage {
// make sure $oldUGMs and $newUGMs are in the same order, and serialise
// each UGM object to a simplified array
$oldUGMs = array_map( function( $group ) use ( $oldUGMs ) {
$oldUGMs = array_map( function ( $group ) use ( $oldUGMs ) {
return isset( $oldUGMs[$group] ) ?
self::serialiseUgmForLog( $oldUGMs[$group] ) :
null;
}, $oldGroups );
$newUGMs = array_map( function( $group ) use ( $newUGMs ) {
$newUGMs = array_map( function ( $group ) use ( $newUGMs ) {
return isset( $newUGMs[$group] ) ?
self::serialiseUgmForLog( $newUGMs[$group] ) :
null;

View file

@ -511,7 +511,7 @@ class SpecialVersion extends SpecialPage {
// in their proper section
continue;
}
$authors = array_map( function( $arr ) {
$authors = array_map( function ( $arr ) {
// If a homepage is set, link to it
if ( isset( $arr['homepage'] ) ) {
return "[{$arr['homepage']} {$arr['name']}]";

View file

@ -1891,7 +1891,7 @@ class Balancer {
$bad = array_uintersect_assoc(
$this->allowedHtmlElements,
BalanceSets::$unsupportedSet[BalanceSets::HTML_NAMESPACE],
function( $a, $b ) {
function ( $a, $b ) {
// Ignore the values (just intersect the keys) by saying
// all values are equal to each other.
return 0;

View file

@ -2506,7 +2506,7 @@ class User implements IDBAccessObject {
$cache->delete( $key, 1 );
} else {
wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
function() use ( $cache, $key ) {
function () use ( $cache, $key ) {
$cache->delete( $key );
},
__METHOD__
@ -3698,7 +3698,7 @@ class User implements IDBAccessObject {
}
// Try to update the DB post-send and only if needed...
DeferredUpdates::addCallableUpdate( function() use ( $title, $oldid ) {
DeferredUpdates::addCallableUpdate( function () use ( $title, $oldid ) {
if ( !$this->getNewtalk() ) {
return; // no notifications to clear
}

View file

@ -77,7 +77,7 @@ class BatchRowUpdate {
$this->reader = $reader;
$this->writer = $writer;
$this->generator = $generator;
$this->output = function() {
$this->output = function () {
}; // nop
}

View file

@ -715,4 +715,3 @@ class ZipDirectoryReader {
}
}
}

View file

@ -49,4 +49,3 @@ class CodeCleanerGlobalsPass extends \Psy\CodeCleaner\CodeCleanerPass {
return $nodes;
}
}

View file

@ -8,7 +8,7 @@ class ValidateRegistrationFile extends Maintenance {
$this->addArg( 'path', 'Path to extension.json/skin.json file.', true );
}
public function execute() {
$validator = new ExtensionJsonValidator( function( $msg ) {
$validator = new ExtensionJsonValidator( function ( $msg ) {
$this->error( $msg, 1 );
} );
$validator->checkDependencies();

View file

@ -38,7 +38,7 @@
</properties>
</rule>
<file>.</file>
<arg name="encoding" value="utf8"/>
<arg name="encoding" value="UTF-8"/>
<arg name="extensions" value="php,php5,inc,sample"/>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>*/languages/messages/Messages*.php</exclude-pattern>

View file

@ -240,7 +240,7 @@ class ParserTestRunner {
'name' => 'nullLockManager',
'class' => 'NullLockManager',
] ];
$reset = function() {
$reset = function () {
LockManagerGroup::destroySingletons();
};
$setup[] = $reset;
@ -288,7 +288,7 @@ class ParserTestRunner {
MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
MediaWikiServices::getInstance()->redefineService(
'MediaHandlerFactory',
function() {
function () {
return new MockMediaHandlerFactory();
}
);
@ -428,7 +428,7 @@ class ParserTestRunner {
* @return ScopedCallback
*/
protected function createTeardownObject( $teardown, $nextTeardown = null ) {
return new ScopedCallback( function() use ( $teardown, $nextTeardown ) {
return new ScopedCallback( function () use ( $teardown, $nextTeardown ) {
// Schedule teardown snippets in reverse order
$teardown = array_reverse( $teardown );

View file

@ -309,7 +309,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
ConfigFactory $oldFactory,
array $configurations
) {
return function( MediaWikiServices $services ) use ( $oldFactory, $configurations ) {
return function ( MediaWikiServices $services ) use ( $oldFactory, $configurations ) {
$factory = new ConfigFactory();
// clone configurations from $oldFactory that are not overwritten by $configurations

View file

@ -3,19 +3,19 @@
class WfArrayFilterTest extends \PHPUnit_Framework_TestCase {
public function testWfArrayFilter() {
$arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
$filtered = wfArrayFilter( $arr, function( $val, $key ) {
$filtered = wfArrayFilter( $arr, function ( $val, $key ) {
return $key !== 'b';
} );
$this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
$arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
$filtered = wfArrayFilter( $arr, function( $val, $key ) {
$filtered = wfArrayFilter( $arr, function ( $val, $key ) {
return $val !== 2;
} );
$this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
$arr = [ 'a', 'b', 'c' ];
$filtered = wfArrayFilter( $arr, function( $val, $key ) {
$filtered = wfArrayFilter( $arr, function ( $val, $key ) {
return $key !== 0;
} );
$this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered );
@ -23,13 +23,13 @@ class WfArrayFilterTest extends \PHPUnit_Framework_TestCase {
public function testWfArrayFilterByKey() {
$arr = [ 'a' => 1, 'b' => 2, 'c' => 3 ];
$filtered = wfArrayFilterByKey( $arr, function( $key ) {
$filtered = wfArrayFilterByKey( $arr, function ( $key ) {
return $key !== 'b';
} );
$this->assertSame( [ 'a' => 1, 'c' => 3 ], $filtered );
$arr = [ 'a', 'b', 'c' ];
$filtered = wfArrayFilterByKey( $arr, function( $key ) {
$filtered = wfArrayFilterByKey( $arr, function ( $key ) {
return $key !== 0;
} );
$this->assertSame( [ 1 => 'b', 2 => 'c' ], $filtered );

View file

@ -385,21 +385,21 @@ class LinkerTest extends MediaWikiLangTestCase {
return [
// Override $html
[
function( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
$html = 'foobar';
},
'<a href="/wiki/Special:BlankPage" title="Special:BlankPage">foobar</a>'
],
// Modify $attribs
[
function( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
$attribs['bar'] = 'baz';
},
'<a href="/wiki/Special:BlankPage" title="Special:BlankPage" bar="baz">Special:BlankPage</a>'
],
// Fully override return value and abort hook
[
function( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
function ( $dummy, $title, $options, &$html, &$attribs, &$ret ) {
$ret = 'blahblahblah';
return false;
},

View file

@ -77,7 +77,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$newServices->defineService(
'Test',
function() use ( $service1 ) {
function () use ( $service1 ) {
return $service1;
}
);
@ -121,7 +121,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$newServices->defineService(
'Test',
function() use ( &$instantiatorReturnValues ) {
function () use ( &$instantiatorReturnValues ) {
return array_shift( $instantiatorReturnValues );
}
);
@ -150,7 +150,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$newServices->redefineService(
'DBLoadBalancerFactory',
function() use ( $lbFactory ) {
function () use ( $lbFactory ) {
return $lbFactory;
}
);
@ -194,7 +194,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$newServices->defineService(
'Test',
function() use ( &$instantiatorReturnValues ) {
function () use ( &$instantiatorReturnValues ) {
return array_shift( $instantiatorReturnValues );
}
);
@ -217,7 +217,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$services->defineService(
'Test',
function() use ( &$serviceCounter ) {
function () use ( &$serviceCounter ) {
$serviceCounter++;
$service = $this->createMock( 'MediaWiki\Services\DestructibleService' );
$service->expects( $this->once() )->method( 'destroy' );
@ -247,7 +247,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
$services->defineService(
'Test',
function() {
function () {
$service = $this->createMock( 'MediaWiki\Services\DestructibleService' );
$service->expects( $this->never() )->method( 'destroy' );
return $service;

View file

@ -20,7 +20,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$this->assertEmpty( $names );
$name = 'TestService92834576';
$services->defineService( $name, function() {
$services->defineService( $name, function () {
return null;
} );
@ -34,7 +34,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$name = 'TestService92834576';
$this->assertFalse( $services->hasService( $name ) );
$services->defineService( $name, function() {
$services->defineService( $name, function () {
return null;
} );
@ -50,7 +50,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$services->defineService(
$name,
function( $actualLocator, $extra ) use ( $services, $theService, &$count ) {
function ( $actualLocator, $extra ) use ( $services, $theService, &$count ) {
$count++;
PHPUnit_Framework_Assert::assertSame( $services, $actualLocator );
PHPUnit_Framework_Assert::assertSame( $extra, 'Foo' );
@ -79,14 +79,14 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$services->defineService(
'Foo',
function() {
function () {
return new stdClass();
}
);
$services->defineService(
'Bar',
function() {
function () {
return new stdClass();
}
);
@ -122,7 +122,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$theService = new stdClass();
$name = 'TestService92834576';
$services->defineService( $name, function( $actualLocator ) use ( $services, $theService ) {
$services->defineService( $name, function ( $actualLocator ) use ( $services, $theService ) {
PHPUnit_Framework_Assert::assertSame( $services, $actualLocator );
return $theService;
} );
@ -137,13 +137,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$theService = new stdClass();
$name = 'TestService92834576';
$services->defineService( $name, function() use ( $theService ) {
$services->defineService( $name, function () use ( $theService ) {
return $theService;
} );
$this->setExpectedException( 'MediaWiki\Services\ServiceAlreadyDefinedException' );
$services->defineService( $name, function() use ( $theService ) {
$services->defineService( $name, function () use ( $theService ) {
return $theService;
} );
}
@ -152,10 +152,10 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$services = $this->newServiceContainer();
$wiring = [
'Foo' => function() {
'Foo' => function () {
return 'Foo!';
},
'Bar' => function() {
'Bar' => function () {
return 'Bar!';
},
];
@ -170,13 +170,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$services = $this->newServiceContainer();
$wiring = [
'Foo' => function() {
'Foo' => function () {
return 'Foo!';
},
'Bar' => function() {
'Bar' => function () {
return 'Bar!';
},
'Car' => function() {
'Car' => function () {
return 'FUBAR!';
},
];
@ -187,7 +187,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
// define a service before importing, so we can later check that
// existing service instances survive importWiring()
$newServices->defineService( 'Car', function() {
$newServices->defineService( 'Car', function () {
return 'Car!';
} );
@ -196,7 +196,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
// Define another service, so we can later check that extra wiring
// is not lost.
$newServices->defineService( 'Xar', function() {
$newServices->defineService( 'Xar', function () {
return 'Xar!';
} );
@ -249,7 +249,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$theService1 = new stdClass();
$name = 'TestService92834576';
$services->defineService( $name, function() {
$services->defineService( $name, function () {
PHPUnit_Framework_Assert::fail(
'The original instantiator function should not get called'
);
@ -258,7 +258,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
// redefine before instantiation
$services->redefineService(
$name,
function( $actualLocator, $extra ) use ( $services, $theService1 ) {
function ( $actualLocator, $extra ) use ( $services, $theService1 ) {
PHPUnit_Framework_Assert::assertSame( $services, $actualLocator );
PHPUnit_Framework_Assert::assertSame( 'Foo', $extra );
return $theService1;
@ -275,14 +275,14 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$theService1 = new stdClass();
$name = 'TestService92834576';
$services->defineService( $name, function() {
$services->defineService( $name, function () {
return 'Foo';
} );
// disable the service. we should be able to redefine it anyway.
$services->disableService( $name );
$services->redefineService( $name, function() use ( $theService1 ) {
$services->redefineService( $name, function () use ( $theService1 ) {
return $theService1;
} );
@ -298,7 +298,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
$services->redefineService( $name, function() use ( $theService ) {
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
@ -309,7 +309,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$theService = new stdClass();
$name = 'TestService92834576';
$services->defineService( $name, function() {
$services->defineService( $name, function () {
return 'Foo';
} );
@ -318,7 +318,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$this->setExpectedException( 'MediaWiki\Services\CannotReplaceActiveServiceException' );
$services->redefineService( $name, function() use ( $theService ) {
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
@ -331,13 +331,13 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$destructible->expects( $this->once() )
->method( 'destroy' );
$services->defineService( 'Foo', function() use ( $destructible ) {
$services->defineService( 'Foo', function () use ( $destructible ) {
return $destructible;
} );
$services->defineService( 'Bar', function() {
$services->defineService( 'Bar', function () {
return new stdClass();
} );
$services->defineService( 'Qux', function() {
$services->defineService( 'Qux', function () {
return new stdClass();
} );
@ -377,7 +377,7 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
$services->redefineService( $name, function() use ( $theService ) {
$services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
@ -390,11 +390,11 @@ class ServiceContainerTest extends PHPUnit_Framework_TestCase {
$destructible->expects( $this->once() )
->method( 'destroy' );
$services->defineService( 'Foo', function() use ( $destructible ) {
$services->defineService( 'Foo', function () use ( $destructible ) {
return $destructible;
} );
$services->defineService( 'Bar', function() {
$services->defineService( 'Bar', function () {
return new stdClass();
} );

View file

@ -4,7 +4,7 @@
*/
return [
'Foo' => function() {
'Foo' => function () {
return 'Foo!';
},
];

View file

@ -4,7 +4,7 @@
*/
return [
'Bar' => function() {
'Bar' => function () {
return 'Bar!';
},
];

View file

@ -21,9 +21,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$this->isType( 'array' ),
$this->isType( 'int' )
)
->will( $this->returnCallback( function( $a, $conj ) {
->will( $this->returnCallback( function ( $a, $conj ) {
$sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
return join( $sqlConj, array_map( function( $s ) {
return join( $sqlConj, array_map( function ( $s ) {
return '(' . $s . ')';
}, $a
) );
@ -31,7 +31,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$mock->expects( $this->any() )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
@ -41,7 +41,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$mock->expects( $this->any() )
->method( 'bitAnd' )
->willReturnCallback( function( $a, $b ) {
->willReturnCallback( function ( $a, $b ) {
return "($a & $b)";
} );
@ -106,12 +106,12 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$mock->expects( $this->any() )
->method( 'isAllowed' )
->will( $this->returnCallback( function( $action ) use ( $notAllowedAction ) {
->will( $this->returnCallback( function ( $action ) use ( $notAllowedAction ) {
return $action !== $notAllowedAction;
} ) );
$mock->expects( $this->any() )
->method( 'isAllowedAny' )
->will( $this->returnCallback( function() use ( $notAllowedAction ) {
->will( $this->returnCallback( function () use ( $notAllowedAction ) {
$actions = func_get_args();
return !in_array( $notAllowedAction, $actions );
} ) );
@ -1450,7 +1450,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$mockDb = $this->getMockDb();
$mockDb->expects( $this->any() )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
$mockDb->expects( $this->any() )
@ -1459,9 +1459,9 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
$this->isType( 'array' ),
$this->isType( 'int' )
)
->will( $this->returnCallback( function( $a, $conj ) {
->will( $this->returnCallback( function ( $a, $conj ) {
$sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
return join( $sqlConj, array_map( function( $s ) {
return join( $sqlConj, array_map( function ( $s ) {
return '(' . $s . ')';
}, $a
) );

View file

@ -48,7 +48,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
->getMock();
$mock->expects( $this->any() )
->method( 'makeKey' )
->will( $this->returnCallback( function() {
->will( $this->returnCallback( function () {
return implode( ':', func_get_args() );
} ) );
return $mock;
@ -313,12 +313,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
->will( $this->returnValue( 7 ) );
$mockDb->expects( $this->exactly( 1 ) )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
$mockDb->expects( $this->exactly( 1 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
@ -351,12 +351,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$mockDb = $this->getMockDb();
$mockDb->expects( $this->exactly( 2 * 3 ) )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
$mockDb->expects( $this->exactly( 3 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
$mockDb->expects( $this->any() )
@ -365,9 +365,9 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$this->isType( 'array' ),
$this->isType( 'int' )
)
->will( $this->returnCallback( function( $a, $conj ) {
->will( $this->returnCallback( function ( $a, $conj ) {
$sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
return join( $sqlConj, array_map( function( $s ) {
return join( $sqlConj, array_map( function ( $s ) {
return '(' . $s . ')';
}, $a
) );
@ -446,12 +446,12 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$mockDb = $this->getMockDb();
$mockDb->expects( $this->exactly( 2 * 3 ) )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
$mockDb->expects( $this->exactly( 3 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
$mockDb->expects( $this->any() )
@ -460,9 +460,9 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$this->isType( 'array' ),
$this->isType( 'int' )
)
->will( $this->returnCallback( function( $a, $conj ) {
->will( $this->returnCallback( function ( $a, $conj ) {
$sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
return join( $sqlConj, array_map( function( $s ) {
return join( $sqlConj, array_map( function ( $s ) {
return '(' . $s . ')';
}, $a
) );
@ -1970,7 +1970,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
// Note: This does not actually assert the job is correct
$callableCallCounter = 0;
$mockCallback = function( $callable ) use ( &$callableCallCounter ) {
$mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
$callableCallCounter++;
$this->assertInternalType( 'callable', $callable );
};
@ -2011,7 +2011,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
// Note: This does not actually assert the job is correct
$callableCallCounter = 0;
$mockCallback = function( $callable ) use ( &$callableCallCounter ) {
$mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
$callableCallCounter++;
$this->assertInternalType( 'callable', $callable );
};
@ -2105,13 +2105,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$callableCallCounter = 0;
$scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
function( $callable ) use ( &$callableCallCounter, $title, $user ) {
function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
$callableCallCounter++;
$this->verifyCallbackJob(
$callable,
$title,
$user->getId(),
function( $time ) {
function ( $time ) {
return $time === null;
}
);
@ -2172,13 +2172,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$addUpdateCallCounter = 0;
$scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
$addUpdateCallCounter++;
$this->verifyCallbackJob(
$callable,
$title,
$user->getId(),
function( $time ) {
function ( $time ) {
return $time !== null && $time > '20151212010101';
}
);
@ -2187,7 +2187,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$getTimestampCallCounter = 0;
$scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
$getTimestampCallCounter++;
$this->assertEquals( $title, $titleParam );
$this->assertEquals( $oldid, $oldidParam );
@ -2248,13 +2248,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$callableCallCounter = 0;
$scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
function( $callable ) use ( &$callableCallCounter, $title, $user ) {
function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
$callableCallCounter++;
$this->verifyCallbackJob(
$callable,
$title,
$user->getId(),
function( $time ) {
function ( $time ) {
return $time === null;
}
);
@ -2315,13 +2315,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$addUpdateCallCounter = 0;
$scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
$addUpdateCallCounter++;
$this->verifyCallbackJob(
$callable,
$title,
$user->getId(),
function( $time ) {
function ( $time ) {
return $time === '30151212010101';
}
);
@ -2330,7 +2330,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$getTimestampCallCounter = 0;
$scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
$getTimestampCallCounter++;
$this->assertEquals( $title, $titleParam );
$this->assertEquals( $oldid, $oldidParam );
@ -2393,13 +2393,13 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$addUpdateCallCounter = 0;
$scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
function( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
$addUpdateCallCounter++;
$this->verifyCallbackJob(
$callable,
$title,
$user->getId(),
function( $time ) {
function ( $time ) {
return $time === false;
}
);
@ -2408,7 +2408,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
$getTimestampCallCounter = 0;
$scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
function( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
$getTimestampCallCounter++;
$this->assertEquals( $title, $titleParam );
$this->assertEquals( $oldid, $oldidParam );
@ -2454,7 +2454,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
->will( $this->returnValue( true ) );
$mockDb->expects( $this->exactly( 1 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
@ -2484,7 +2484,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
->will( $this->returnValue( true ) );
$mockDb->expects( $this->exactly( 0 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
@ -2515,7 +2515,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
->will( $this->returnValue( true ) );
$mockDb->expects( $this->exactly( 1 ) )
->method( 'timestamp' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return 'TS' . $value . 'TS';
} ) );
$mockDb->expects( $this->once() )

View file

@ -14,7 +14,7 @@ class ApiPageSetTest extends ApiTestCase {
],
'A simple merge policy adds the redirect data in' => [
function( $current, $new ) {
function ( $current, $new ) {
if ( !isset( $current['index'] ) || $new['index'] < $current['index'] ) {
$current['index'] = $new['index'];
}

View file

@ -210,7 +210,7 @@ class ApiQueryWatchlistIntegrationTest extends ApiTestCase {
// not checking values of all keys of the actual item, so removing unwanted keys from comparison
$actualItemsOnlyComparedValues = array_map(
function( array $item ) use ( $keysUsedInValueComparison ) {
function ( array $item ) use ( $keysUsedInValueComparison ) {
return array_intersect_key( $item, array_flip( $keysUsedInValueComparison ) );
},
$actualItems

View file

@ -87,7 +87,7 @@ class RandomImageGenerator {
__DIR__ . '/words.txt'
] as $dictionaryFile
) {
if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) {
if ( is_file( $dictionaryFile ) && is_readable( $dictionaryFile ) ) {
$this->dictionaryFile = $dictionaryFile;
break;
}

View file

@ -63,7 +63,7 @@ class ConfigFactoryTest extends MediaWikiTestCase {
// define new config instance
$newFactory = new ConfigFactory();
$newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
$newFactory->register( 'bar', function() {
$newFactory->register( 'bar', function () {
return new HashConfig();
} );

View file

@ -28,7 +28,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
CONTENT_MODEL_CSS => 'CssContentHandler',
CONTENT_MODEL_TEXT => 'TextContentHandler',
'testing' => 'DummyContentHandlerForTesting',
'testing-callbacks' => function( $modelId ) {
'testing-callbacks' => function ( $modelId ) {
return new DummyContentHandlerForTesting( $modelId );
}
],
@ -418,7 +418,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
$searchEngine->expects( $this->any() )
->method( 'makeSearchFieldMapping' )
->will( $this->returnCallback( function( $name, $type ) {
->will( $this->returnCallback( function ( $name, $type ) {
return new DummySearchIndexFieldDefinition( $name, $type );
} ) );

View file

@ -112,7 +112,7 @@ class JobTest extends MediaWikiTestCase {
public function provideTestJobFactory() {
return [
'class name' => [ 'NullJob' ],
'closure' => [ function( Title $title, array $params ) {
'closure' => [ function ( Title $title, array $params ) {
return new NullJob( $title, $params );
} ],
'function' => [ [ $this, 'newNullJob' ] ],

View file

@ -17,7 +17,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
// No args
[
[
function() {
function () {
return 'foo';
}
],
@ -26,7 +26,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
// Has args
[
[
function( $i ) {
function ( $i ) {
return $i;
},
'bar'
@ -41,7 +41,7 @@ class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
* it is never converted to a string
*/
public function testCallbackNotCalled() {
$ds = new DeferredStringifier( function() {
$ds = new DeferredStringifier( function () {
throw new Exception( 'This should not be reached!' );
} );
// No exception was thrown

View file

@ -27,13 +27,13 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase {
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
'args' => [
function() {
function () {
return 'wrapped';
},
'unwrapped',
],
'calls' => [
'setter' => [ function() {
'setter' => [ function () {
return 'wrapped';
}, ],
],
@ -54,13 +54,13 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase {
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
'args' => [
function() {
function () {
return 'wrapped';
},
'unwrapped',
],
'calls' => [
'setter' => [ function() {
'setter' => [ function () {
return 'wrapped';
}, ],
],
@ -74,11 +74,11 @@ class ObjectFactoryTest extends PHPUnit_Framework_TestCase {
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
'args' => [ function() {
'args' => [ function () {
return 'unwrapped';
}, ],
'calls' => [
'setter' => [ function() {
'setter' => [ function () {
return 'unwrapped';
}, ],
],

View file

@ -66,7 +66,7 @@ XML;
null,
false,
[
'processing_instruction_handler' => function() use ( &$called ) {
'processing_instruction_handler' => function () use ( &$called ) {
$called = true;
}
]

View file

@ -176,7 +176,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase {
$priorValue = null;
$priorAsOf = null;
$wasSet = 0;
$func = function( $old, &$ttl, &$opts, $asOf )
$func = function ( $old, &$ttl, &$opts, $asOf )
use ( &$wasSet, &$priorValue, &$priorAsOf, $value )
{
++$wasSet;
@ -583,7 +583,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase {
$value = wfRandomString();
$calls = 0;
$func = function() use ( &$calls, $value, $cache, $key ) {
$func = function () use ( &$calls, $value, $cache, $key ) {
++$calls;
// Immediately kill any mutex rather than waiting a second
$cache->delete( $cache::MUTEX_KEY_PREFIX . $key );
@ -625,7 +625,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase {
$value = wfRandomString();
$calls = 0;
$func = function( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) {
$func = function ( $oldValue, &$ttl, &$setOpts ) use ( &$calls, $value, $cache, $key ) {
++$calls;
$setOpts['since'] = microtime( true ) - 10;
// Immediately kill any mutex rather than waiting a second
@ -659,7 +659,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase {
$busyValue = wfRandomString();
$calls = 0;
$func = function() use ( &$calls, $value, $cache, $key ) {
$func = function () use ( &$calls, $value, $cache, $key ) {
++$calls;
// Immediately kill any mutex rather than waiting a second
$cache->delete( $cache::MUTEX_KEY_PREFIX . $key );
@ -921,7 +921,7 @@ class WANObjectCacheTest extends PHPUnit_Framework_TestCase {
$value = wfRandomString();
$wasSet = 0;
$func = function( $old, &$ttl ) use ( &$wasSet, $value ) {
$func = function ( $old, &$ttl ) use ( &$wasSet, $value ) {
++$wasSet;
return $value;
};

View file

@ -199,7 +199,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
* @covers ResourceLoader::getModule
*/
public function testGetModuleFactory() {
$factory = function( array $info ) {
$factory = function ( array $info ) {
$this->assertArrayHasKey( 'kitten', $info );
return new ResourceLoaderTestModule( $info );
};

View file

@ -185,7 +185,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
public function testSearch( array $case ) {
$this->search->setLimitOffset( 3 );
$results = $this->search->defaultPrefixSearch( $case['query'] );
$results = array_map( function( Title $t ) {
$results = array_map( function ( Title $t ) {
return $t->getPrefixedText();
}, $results );
@ -203,7 +203,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
public function testSearchWithOffset( array $case ) {
$this->search->setLimitOffset( 3, 1 );
$results = $this->search->defaultPrefixSearch( $case['query'] );
$results = array_map( function( Title $t ) {
$results = array_map( function ( Title $t ) {
return $t->getPrefixedText();
}, $results );
@ -349,7 +349,7 @@ class SearchEnginePrefixTest extends MediaWikiLangTestCase {
$search->setLimitOffset( 3 );
$results = $search->completionSearch( $case['query'] );
$results = $results->map( function( SearchSuggestion $s ) {
$results = $results->map( function ( SearchSuggestion $s ) {
return $s->getText();
} );

View file

@ -43,7 +43,7 @@ class SearchSuggestionSetTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals( 3, $set->getBestScore() );
$this->assertEquals( 1, $suggestion->getScore() );
$scores = $set->map( function( $s ) {
$scores = $set->map( function ( $s ) {
return $s->getScore();
} );
$sorted = $scores;
@ -80,7 +80,7 @@ class SearchSuggestionSetTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals( 6, $set->getBestScore() );
$this->assertEquals( 6, $suggestion->getScore() );
$scores = $set->map( function( $s ) {
$scores = $set->map( function ( $s ) {
return $s->getScore();
} );
$sorted = $scores;

View file

@ -101,7 +101,7 @@ class CachingSiteStoreTest extends MediaWikiTestCase {
$dbSiteStore->expects( $this->any() )
->method( 'getSites' )
->will( $this->returnCallback( function() {
->will( $this->returnCallback( function () {
$siteList = new SiteList();
$siteList->setSite( $this->getTestSite() );

View file

@ -183,7 +183,7 @@ class SpecialSearchTest extends MediaWikiTestCase {
$rewrittenQuery,
array $resultTitles
) {
$results = array_map( function( $title ) {
$results = array_map( function ( $title ) {
return SearchResult::newFromTitle( $title );
}, $resultTitles );

View file

@ -36,7 +36,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
$batchSize = 2;
$reader = new BatchRowIterator( $db, 'some_table', 'id_field', $batchSize );
$response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function() {
$response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function () {
static $i = 0;
return [ 'id_field' => ++$i ];
} );
@ -171,7 +171,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
public function testReaderSelectConditionsMultiplePrimaryKeys(
$message, $expectedSecondIteration, $primaryKeys, $batchSize = 3
) {
$results = $this->genSelectResult( $batchSize, $batchSize * 3, function() {
$results = $this->genSelectResult( $batchSize, $batchSize * 3, function () {
static $i = 0, $j = 100, $k = 1000;
return [ 'id_field' => ++$i, 'foo' => ++$j, 'bar' => ++$k ];
} );
@ -204,7 +204,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
->will( $this->consecutivelyReturnFromSelect( $retvals ) );
$db->expects( $this->any() )
->method( 'addQuotes' )
->will( $this->returnCallback( function( $value ) {
->will( $this->returnCallback( function ( $value ) {
return "'$value'"; // not real quoting: doesn't matter in test
} ) );