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
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;
} );
}
}
$previousValue = self::$instance;
self::$instance = $store;
- return new ScopedCallback( function() use ( $previousValue ) {
+ return new ScopedCallback( function () use ( $previousValue ) {
self::$instance = $previousValue;
} );
}
use MediaWiki\MediaWikiServices;
return [
- 'DBLoadBalancerFactory' => function( MediaWikiServices $services ) {
+ 'DBLoadBalancerFactory' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
$lbConf = MWLBFactory::applyDefaultConfig(
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.
return new CachingSiteStore( $rawSiteStore, $cache );
},
- 'SiteLookup' => function( MediaWikiServices $services ) {
+ 'SiteLookup' => function ( MediaWikiServices $services ) {
$cacheFile = $services->getMainConfig()->get( 'SitesCacheFile' );
if ( $cacheFile !== false ) {
}
},
- 'ConfigFactory' => function( MediaWikiServices $services ) {
+ 'ConfigFactory' => function ( MediaWikiServices $services ) {
// Use the bootstrap config to initialize the ConfigFactory.
$registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
$factory = new ConfigFactory();
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(
);
},
- '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' );
return $factory;
},
- 'WatchedItemStore' => function( MediaWikiServices $services ) {
+ 'WatchedItemStore' => function ( MediaWikiServices $services ) {
$store = new WatchedItemStore(
$services->getDBLoadBalancer(),
new HashBagOStuff( [ 'maxKeys' => 100 ] ),
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(
[
// 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 ?: '';
}
],
);
},
- 'CryptHKDF' => function( MediaWikiServices $services ) {
+ 'CryptHKDF' => function ( MediaWikiServices $services ) {
$config = $services->getMainConfig();
$secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
);
},
- '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 = [
return new MimeMagic( $params );
},
- 'ProxyLookup' => function( MediaWikiServices $services ) {
+ 'ProxyLookup' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
return new ProxyLookup(
$mainConfig->get( 'SquidServers' ),
);
},
- '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' ) ) {
}
},
- 'GenderCache' => function( MediaWikiServices $services ) {
+ 'GenderCache' => function ( MediaWikiServices $services ) {
return new GenderCache();
},
- '_MediaWikiTitleCodec' => function( MediaWikiServices $services ) {
+ '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) {
global $wgContLang;
return new MediaWikiTitleCodec(
);
},
- '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' );
return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
},
- 'MainWANObjectCache' => function( MediaWikiServices $services ) {
+ 'MainWANObjectCache' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
$id = $mainConfig->get( 'MainWANCache' );
return \ObjectCache::newWANCacheFromParams( $params );
},
- 'LocalServerObjectCache' => function( MediaWikiServices $services ) {
+ 'LocalServerObjectCache' => function ( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
if ( function_exists( 'apc_fetch' ) ) {
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( [] ) );
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()
$allFields = get_object_vars( $row );
$rcKeys = array_filter(
array_keys( $allFields ),
- function( $key ) {
+ function ( $key ) {
return substr( $key, 0, 3 ) === 'rc_';
}
);
}
$previousValue = $this->deferredUpdatesAddCallableUpdateCallback;
$this->deferredUpdatesAddCallableUpdateCallback = $callback;
- return new ScopedCallback( function() use ( $previousValue ) {
+ return new ScopedCallback( function () use ( $previousValue ) {
$this->deferredUpdatesAddCallableUpdateCallback = $previousValue;
} );
}
}
$previousValue = $this->revisionGetTimestampFromIdCallback;
$this->revisionGetTimestampFromIdCallback = $callback;
- return new ScopedCallback( function() use ( $previousValue ) {
+ return new ScopedCallback( function () use ( $previousValue ) {
$this->revisionGetTimestampFromIdCallback = $previousValue;
} );
}
// Calls DeferredUpdates::addCallableUpdate in normal operation
call_user_func(
$this->deferredUpdatesAddCallableUpdateCallback,
- function() use ( $job ) {
+ function () use ( $job ) {
$job->run();
}
);
if ( $this->fld_watched ) {
foreach ( $timestamps as $namespaceId => $dbKeys ) {
$this->watched[$namespaceId] = array_map(
- function( $x ) {
+ function ( $x ) {
return $x !== false;
},
$dbKeys
$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()]
];
$titlesWithThresholds = array_merge(
$titlesWithThresholds,
array_map(
- function( LinkTarget $target ) {
+ function ( LinkTarget $target ) {
return [ $target, null ];
},
$this->missing
$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'];
}
}
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() ),
}
$attribs = $data['attribs'];
unset( $data['attribs'] );
- $attribs = wfArrayFilterByKey( $attribs, function( $key ) {
+ $attribs = wfArrayFilterByKey( $attribs, function ( $key ) {
return $key === 'class' || Sanitizer::isReservedDataAttribute( $key );
} );
* @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 );
* @param Status $status
* @throws FatalError
*/
- $error = function( $status ) {
+ $error = function ( $status ) {
throw new FatalError( $status->getWikiText() );
};
* @return Closure
*/
protected function getDBFactory() {
- return function( $index ) {
+ return function ( $index ) {
return wfGetLB( $this->wiki )->getConnectionRef( $index, [], $this->wiki );
};
}
* @return Closure
*/
protected function getDBFactory() {
- return function( $index ) {
+ return function ( $index ) {
return wfGetDB( $index );
};
}
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();
// 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;
}
$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;
$services = \MediaWiki\MediaWikiServices::getInstance();
$connection = $status->value;
- $services->redefineService( 'DBLoadBalancerFactory', function() use ( $connection ) {
+ $services->redefineService( 'DBLoadBalancerFactory', function () use ( $connection ) {
return LBFactorySingle::newFromConnection( $connection );
} );
}
// 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;
};
// 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 );
if ( $this->liveRing === null || $this->ejectionNextExpiry <= $now ) {
$this->ejectionExpiries = array_filter(
$this->ejectionExpiries,
- function( $expiry ) use ( $now ) {
+ function ( $expiry ) use ( $now ) {
return ( $expiry > $now );
}
);
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 ) );
$realOps = $this->substOpBatchPaths( $ops, $backend );
if ( $this->asyncWrites && !$this->hasVolatileSources( $ops ) ) {
DeferredUpdates::addCallableUpdate(
- function() use ( $backend, $realOps ) {
+ function () use ( $backend, $realOps ) {
$backend->doQuickOperations( $realOps );
}
);
$realParams = $this->substOpPaths( $params, $backend );
if ( $this->asyncWrites ) {
DeferredUpdates::addCallableUpdate(
- function() use ( $backend, $method, $realParams ) {
+ function () use ( $backend, $method, $realParams ) {
$backend->$method( $realParams );
}
);
$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 ) {
}
class_alias( DatabaseSqlite::class, 'DatabaseSqlite' );
-
}
class_alias( FakeResultWrapper::class, 'FakeResultWrapper' );
-
}
class_alias( DBTransactionError::class, 'DBTransactionError' );
-
$prefix
);
- $this->forEachLB( function( ILoadBalancer $lb ) use ( $prefix ) {
+ $this->forEachLB( function ( ILoadBalancer $lb ) use ( $prefix ) {
$lb->setDomainPrefix( $prefix );
} );
}
$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 ) ) {
* @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 ) {
}
// Function to get IDs that won't collide with keys in $armoredIndexMap
- $idFunc = function() use ( &$curUniqueId ) {
+ $idFunc = function () use ( &$curUniqueId ) {
return $curUniqueId++;
};
$parts = explode( '/', $subPage, 2 );
if ( $parts !== 2 ) {
$slot = $parts[0];
- if ( $slot === 'main' or $slot === '' ) {
+ if ( $slot === 'main' || $slot === '' ) {
return true;
}
}
$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];
$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];
HTMLFileCache::clearFileCache( $title );
$revid = $revision ? $revision->getId() : null;
- DeferredUpdates::addCallableUpdate( function() use ( $title, $revid ) {
+ DeferredUpdates::addCallableUpdate( function () use ( $title, $revid ) {
InfoAction::invalidateCache( $title, $revid );
} );
}
$e = new Exception;
$this->mInParse = $e->getTraceAsString();
- $recursiveCheck = new ScopedCallback( function() {
+ $recursiveCheck = new ScopedCallback( function () {
$this->mInParse = false;
} );
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
- usort( $data, function( $a, $b ) {
+ usort( $data, function ( $a, $b ) {
if ( $a['real'] === $b['real'] ) {
return 0;
}
*/
protected function getFunctionReport() {
$data = $this->getFunctionStats();
- usort( $data, function( $a, $b ) {
+ usort( $data, function ( $a, $b ) {
if ( $a['real'] === $b['real'] ) {
return 0;
}
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'] );
}
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 {
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 {
}
}
- $ns = array_map( function( $space ) {
+ $ns = array_map( function ( $space ) {
return $space == NS_MEDIA ? NS_FILE : $space;
}, $ns );
* @return Title[]
*/
public function extractTitles( SearchSuggestionSet $completionResults ) {
- return $completionResults->map( function( SearchSuggestion $sugg ) {
+ return $completionResults->map( function ( SearchSuggestion $sugg ) {
return $sugg->getSuggestedTitle();
} );
}
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();
} );
*/
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 );
*/
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 );
$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 );
}
$showGrants
),
'default' => array_map(
- function( $g ) {
+ function ( $g ) {
return "grant-$g";
},
$this->botPassword->getGrants()
'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()
'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();
$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 );
// 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] ) &&
// 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;
// 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']}]";
$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;
$cache->delete( $key, 1 );
} else {
wfGetDB( DB_MASTER )->onTransactionPreCommitOrIdle(
- function() use ( $cache, $key ) {
+ function () use ( $cache, $key ) {
$cache->delete( $key );
},
__METHOD__
}
// 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
}
$this->reader = $reader;
$this->writer = $writer;
$this->generator = $generator;
- $this->output = function() {
+ $this->output = function () {
}; // nop
}
$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();
</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>
'name' => 'nullLockManager',
'class' => 'NullLockManager',
] ];
- $reset = function() {
+ $reset = function () {
LockManagerGroup::destroySingletons();
};
$setup[] = $reset;
MediaWikiServices::getInstance()->disableService( 'MediaHandlerFactory' );
MediaWikiServices::getInstance()->redefineService(
'MediaHandlerFactory',
- function() {
+ function () {
return new MockMediaHandlerFactory();
}
);
* @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 );
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
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 );
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 );
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;
},
$newServices->defineService(
'Test',
- function() use ( $service1 ) {
+ function () use ( $service1 ) {
return $service1;
}
);
$newServices->defineService(
'Test',
- function() use ( &$instantiatorReturnValues ) {
+ function () use ( &$instantiatorReturnValues ) {
return array_shift( $instantiatorReturnValues );
}
);
$newServices->redefineService(
'DBLoadBalancerFactory',
- function() use ( $lbFactory ) {
+ function () use ( $lbFactory ) {
return $lbFactory;
}
);
$newServices->defineService(
'Test',
- function() use ( &$instantiatorReturnValues ) {
+ function () use ( &$instantiatorReturnValues ) {
return array_shift( $instantiatorReturnValues );
}
);
$services->defineService(
'Test',
- function() use ( &$serviceCounter ) {
+ function () use ( &$serviceCounter ) {
$serviceCounter++;
$service = $this->createMock( 'MediaWiki\Services\DestructibleService' );
$service->expects( $this->once() )->method( 'destroy' );
$services->defineService(
'Test',
- function() {
+ function () {
$service = $this->createMock( 'MediaWiki\Services\DestructibleService' );
$service->expects( $this->never() )->method( 'destroy' );
return $service;
$this->assertEmpty( $names );
$name = 'TestService92834576';
- $services->defineService( $name, function() {
+ $services->defineService( $name, function () {
return null;
} );
$name = 'TestService92834576';
$this->assertFalse( $services->hasService( $name ) );
- $services->defineService( $name, function() {
+ $services->defineService( $name, function () {
return null;
} );
$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' );
$services->defineService(
'Foo',
- function() {
+ function () {
return new stdClass();
}
);
$services->defineService(
'Bar',
- function() {
+ function () {
return new stdClass();
}
);
$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;
} );
$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;
} );
}
$services = $this->newServiceContainer();
$wiring = [
- 'Foo' => function() {
+ 'Foo' => function () {
return 'Foo!';
},
- 'Bar' => function() {
+ 'Bar' => function () {
return 'Bar!';
},
];
$services = $this->newServiceContainer();
$wiring = [
- 'Foo' => function() {
+ 'Foo' => function () {
return 'Foo!';
},
- 'Bar' => function() {
+ 'Bar' => function () {
return 'Bar!';
},
- 'Car' => function() {
+ 'Car' => function () {
return 'FUBAR!';
},
];
// 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!';
} );
// Define another service, so we can later check that extra wiring
// is not lost.
- $newServices->defineService( 'Xar', function() {
+ $newServices->defineService( 'Xar', function () {
return 'Xar!';
} );
$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'
);
// 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;
$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;
} );
$this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
- $services->redefineService( $name, function() use ( $theService ) {
+ $services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
$theService = new stdClass();
$name = 'TestService92834576';
- $services->defineService( $name, function() {
+ $services->defineService( $name, function () {
return 'Foo';
} );
$this->setExpectedException( 'MediaWiki\Services\CannotReplaceActiveServiceException' );
- $services->redefineService( $name, function() use ( $theService ) {
+ $services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
$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();
} );
$this->setExpectedException( 'MediaWiki\Services\NoSuchServiceException' );
- $services->redefineService( $name, function() use ( $theService ) {
+ $services->redefineService( $name, function () use ( $theService ) {
return $theService;
} );
}
$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();
} );
*/
return [
- 'Foo' => function() {
+ 'Foo' => function () {
return 'Foo!';
},
];
*/
return [
- 'Bar' => function() {
+ 'Bar' => function () {
return 'Bar!';
},
];
$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
) );
$mock->expects( $this->any() )
->method( 'addQuotes' )
- ->will( $this->returnCallback( function( $value ) {
+ ->will( $this->returnCallback( function ( $value ) {
return "'$value'";
} ) );
$mock->expects( $this->any() )
->method( 'bitAnd' )
- ->willReturnCallback( function( $a, $b ) {
+ ->willReturnCallback( function ( $a, $b ) {
return "($a & $b)";
} );
$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 );
} ) );
$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() )
$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
) );
->getMock();
$mock->expects( $this->any() )
->method( 'makeKey' )
- ->will( $this->returnCallback( function() {
+ ->will( $this->returnCallback( function () {
return implode( ':', func_get_args() );
} ) );
return $mock;
->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';
} ) );
$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() )
$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
) );
$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() )
$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
) );
// 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 );
};
// 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 );
};
$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;
}
);
$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';
}
);
$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 );
$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;
}
);
$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';
}
);
$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 );
$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;
}
);
$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 );
->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';
} ) );
->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';
} ) );
->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() )
],
'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'];
}
// 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
__DIR__ . '/words.txt'
] as $dictionaryFile
) {
- if ( is_file( $dictionaryFile ) and is_readable( $dictionaryFile ) ) {
+ if ( is_file( $dictionaryFile ) && is_readable( $dictionaryFile ) ) {
$this->dictionaryFile = $dictionaryFile;
break;
}
// define new config instance
$newFactory = new ConfigFactory();
$newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
- $newFactory->register( 'bar', function() {
+ $newFactory->register( 'bar', function () {
return new HashConfig();
} );
CONTENT_MODEL_CSS => 'CssContentHandler',
CONTENT_MODEL_TEXT => 'TextContentHandler',
'testing' => 'DummyContentHandlerForTesting',
- 'testing-callbacks' => function( $modelId ) {
+ 'testing-callbacks' => function ( $modelId ) {
return new DummyContentHandlerForTesting( $modelId );
}
],
$searchEngine->expects( $this->any() )
->method( 'makeSearchFieldMapping' )
- ->will( $this->returnCallback( function( $name, $type ) {
+ ->will( $this->returnCallback( function ( $name, $type ) {
return new DummySearchIndexFieldDefinition( $name, $type );
} ) );
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' ] ],
// No args
[
[
- function() {
+ function () {
return 'foo';
}
],
// Has args
[
[
- function( $i ) {
+ function ( $i ) {
return $i;
},
'bar'
* 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
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
'args' => [
- function() {
+ function () {
return 'wrapped';
},
'unwrapped',
],
'calls' => [
- 'setter' => [ function() {
+ 'setter' => [ function () {
return 'wrapped';
}, ],
],
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
'args' => [
- function() {
+ function () {
return 'wrapped';
},
'unwrapped',
],
'calls' => [
- 'setter' => [ function() {
+ 'setter' => [ function () {
return 'wrapped';
}, ],
],
$obj = ObjectFactory::getObjectFromSpec( [
'class' => 'ObjectFactoryTestFixture',
- 'args' => [ function() {
+ 'args' => [ function () {
return 'unwrapped';
}, ],
'calls' => [
- 'setter' => [ function() {
+ 'setter' => [ function () {
return 'unwrapped';
}, ],
],
null,
false,
[
- 'processing_instruction_handler' => function() use ( &$called ) {
+ 'processing_instruction_handler' => function () use ( &$called ) {
$called = true;
}
]
$priorValue = null;
$priorAsOf = null;
$wasSet = 0;
- $func = function( $old, &$ttl, &$opts, $asOf )
+ $func = function ( $old, &$ttl, &$opts, $asOf )
use ( &$wasSet, &$priorValue, &$priorAsOf, $value )
{
++$wasSet;
$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 );
$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
$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 );
$value = wfRandomString();
$wasSet = 0;
- $func = function( $old, &$ttl ) use ( &$wasSet, $value ) {
+ $func = function ( $old, &$ttl ) use ( &$wasSet, $value ) {
++$wasSet;
return $value;
};
* @covers ResourceLoader::getModule
*/
public function testGetModuleFactory() {
- $factory = function( array $info ) {
+ $factory = function ( array $info ) {
$this->assertArrayHasKey( 'kitten', $info );
return new ResourceLoaderTestModule( $info );
};
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 );
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 );
$search->setLimitOffset( 3 );
$results = $search->completionSearch( $case['query'] );
- $results = $results->map( function( SearchSuggestion $s ) {
+ $results = $results->map( function ( SearchSuggestion $s ) {
return $s->getText();
} );
$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;
$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;
$dbSiteStore->expects( $this->any() )
->method( 'getSites' )
- ->will( $this->returnCallback( function() {
+ ->will( $this->returnCallback( function () {
$siteList = new SiteList();
$siteList->setSite( $this->getTestSite() );
$rewrittenQuery,
array $resultTitles
) {
- $results = array_map( function( $title ) {
+ $results = array_map( function ( $title ) {
return SearchResult::newFromTitle( $title );
}, $resultTitles );
$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 ];
} );
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 ];
} );
->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
} ) );