mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP 8.4. The explicit nullable type must be used instead. Bug: T376276 Change-Id: I303342cf1a002d5f0afc77ce147ce9453ea5282e
This commit is contained in:
parent
6757ee9d32
commit
63de22357d
|
@ -24,7 +24,7 @@ use Psr\Container\ContainerInterface;
|
|||
|
||||
class AbuseFilterServices {
|
||||
|
||||
public static function getHookRunner( ContainerInterface $services = null ): AbuseFilterHookRunner {
|
||||
public static function getHookRunner( ?ContainerInterface $services = null ): AbuseFilterHookRunner {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( AbuseFilterHookRunner::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return KeywordsManager
|
||||
*/
|
||||
public static function getKeywordsManager( ContainerInterface $services = null ): KeywordsManager {
|
||||
public static function getKeywordsManager( ?ContainerInterface $services = null ): KeywordsManager {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( KeywordsManager::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterProfiler
|
||||
*/
|
||||
public static function getFilterProfiler( ContainerInterface $services = null ): FilterProfiler {
|
||||
public static function getFilterProfiler( ?ContainerInterface $services = null ): FilterProfiler {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterProfiler::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return AbuseFilterPermissionManager
|
||||
*/
|
||||
public static function getPermissionManager( ContainerInterface $services = null ): AbuseFilterPermissionManager {
|
||||
public static function getPermissionManager( ?ContainerInterface $services = null ): AbuseFilterPermissionManager {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( AbuseFilterPermissionManager::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ChangeTagger
|
||||
*/
|
||||
public static function getChangeTagger( ContainerInterface $services = null ): ChangeTagger {
|
||||
public static function getChangeTagger( ?ContainerInterface $services = null ): ChangeTagger {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ChangeTagger::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ChangeTagsManager
|
||||
*/
|
||||
public static function getChangeTagsManager( ContainerInterface $services = null ): ChangeTagsManager {
|
||||
public static function getChangeTagsManager( ?ContainerInterface $services = null ): ChangeTagsManager {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ChangeTagsManager::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ChangeTagValidator
|
||||
*/
|
||||
public static function getChangeTagValidator( ContainerInterface $services = null ): ChangeTagValidator {
|
||||
public static function getChangeTagValidator( ?ContainerInterface $services = null ): ChangeTagValidator {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ChangeTagValidator::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return BlockAutopromoteStore
|
||||
*/
|
||||
public static function getBlockAutopromoteStore( ContainerInterface $services = null ): BlockAutopromoteStore {
|
||||
public static function getBlockAutopromoteStore( ?ContainerInterface $services = null ): BlockAutopromoteStore {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( BlockAutopromoteStore::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterUser
|
||||
*/
|
||||
public static function getFilterUser( ContainerInterface $services = null ): FilterUser {
|
||||
public static function getFilterUser( ?ContainerInterface $services = null ): FilterUser {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterUser::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return CentralDBManager
|
||||
*/
|
||||
public static function getCentralDBManager( ContainerInterface $services = null ): CentralDBManager {
|
||||
public static function getCentralDBManager( ?ContainerInterface $services = null ): CentralDBManager {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( CentralDBManager::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return RuleCheckerFactory
|
||||
*/
|
||||
public static function getRuleCheckerFactory( ContainerInterface $services = null ): RuleCheckerFactory {
|
||||
public static function getRuleCheckerFactory( ?ContainerInterface $services = null ): RuleCheckerFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( RuleCheckerFactory::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterLookup
|
||||
*/
|
||||
public static function getFilterLookup( ContainerInterface $services = null ): FilterLookup {
|
||||
public static function getFilterLookup( ?ContainerInterface $services = null ): FilterLookup {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterLookup::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return EmergencyCache
|
||||
*/
|
||||
public static function getEmergencyCache( ContainerInterface $services = null ): EmergencyCache {
|
||||
public static function getEmergencyCache( ?ContainerInterface $services = null ): EmergencyCache {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( EmergencyCache::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return EmergencyWatcher
|
||||
*/
|
||||
public static function getEmergencyWatcher( ContainerInterface $services = null ): EmergencyWatcher {
|
||||
public static function getEmergencyWatcher( ?ContainerInterface $services = null ): EmergencyWatcher {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( EmergencyWatcher::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return EchoNotifier
|
||||
*/
|
||||
public static function getEchoNotifier( ContainerInterface $services = null ): EchoNotifier {
|
||||
public static function getEchoNotifier( ?ContainerInterface $services = null ): EchoNotifier {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( EchoNotifier::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterValidator
|
||||
*/
|
||||
public static function getFilterValidator( ContainerInterface $services = null ): FilterValidator {
|
||||
public static function getFilterValidator( ?ContainerInterface $services = null ): FilterValidator {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterValidator::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterCompare
|
||||
*/
|
||||
public static function getFilterCompare( ContainerInterface $services = null ): FilterCompare {
|
||||
public static function getFilterCompare( ?ContainerInterface $services = null ): FilterCompare {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterCompare::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterImporter
|
||||
*/
|
||||
public static function getFilterImporter( ContainerInterface $services = null ): FilterImporter {
|
||||
public static function getFilterImporter( ?ContainerInterface $services = null ): FilterImporter {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterImporter::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterStore
|
||||
*/
|
||||
public static function getFilterStore( ContainerInterface $services = null ): FilterStore {
|
||||
public static function getFilterStore( ?ContainerInterface $services = null ): FilterStore {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterStore::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ConsequencesFactory
|
||||
*/
|
||||
public static function getConsequencesFactory( ContainerInterface $services = null ): ConsequencesFactory {
|
||||
public static function getConsequencesFactory( ?ContainerInterface $services = null ): ConsequencesFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ConsequencesFactory::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return EditBoxBuilderFactory
|
||||
*/
|
||||
public static function getEditBoxBuilderFactory( ContainerInterface $services = null ): EditBoxBuilderFactory {
|
||||
public static function getEditBoxBuilderFactory( ?ContainerInterface $services = null ): EditBoxBuilderFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( EditBoxBuilderFactory::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ConsequencesLookup
|
||||
*/
|
||||
public static function getConsequencesLookup( ContainerInterface $services = null ): ConsequencesLookup {
|
||||
public static function getConsequencesLookup( ?ContainerInterface $services = null ): ConsequencesLookup {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ConsequencesLookup::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return ConsequencesRegistry
|
||||
*/
|
||||
public static function getConsequencesRegistry( ContainerInterface $services = null ): ConsequencesRegistry {
|
||||
public static function getConsequencesRegistry( ?ContainerInterface $services = null ): ConsequencesRegistry {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ConsequencesRegistry::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return AbuseLoggerFactory
|
||||
*/
|
||||
public static function getAbuseLoggerFactory( ContainerInterface $services = null ): AbuseLoggerFactory {
|
||||
public static function getAbuseLoggerFactory( ?ContainerInterface $services = null ): AbuseLoggerFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( AbuseLoggerFactory::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return UpdateHitCountWatcher
|
||||
*/
|
||||
public static function getUpdateHitCountWatcher( ContainerInterface $services = null ): UpdateHitCountWatcher {
|
||||
public static function getUpdateHitCountWatcher( ?ContainerInterface $services = null ): UpdateHitCountWatcher {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( UpdateHitCountWatcher::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return VariablesBlobStore
|
||||
*/
|
||||
public static function getVariablesBlobStore( ContainerInterface $services = null ): VariablesBlobStore {
|
||||
public static function getVariablesBlobStore( ?ContainerInterface $services = null ): VariablesBlobStore {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( VariablesBlobStore::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ class AbuseFilterServices {
|
|||
* @return ConsequencesExecutorFactory
|
||||
*/
|
||||
public static function getConsequencesExecutorFactory(
|
||||
ContainerInterface $services = null
|
||||
?ContainerInterface $services = null
|
||||
): ConsequencesExecutorFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( ConsequencesExecutorFactory::SERVICE_NAME );
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return FilterRunnerFactory
|
||||
*/
|
||||
public static function getFilterRunnerFactory( ContainerInterface $services = null ): FilterRunnerFactory {
|
||||
public static function getFilterRunnerFactory( ?ContainerInterface $services = null ): FilterRunnerFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( FilterRunnerFactory::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return SpecsFormatter
|
||||
*/
|
||||
public static function getSpecsFormatter( ContainerInterface $services = null ): SpecsFormatter {
|
||||
public static function getSpecsFormatter( ?ContainerInterface $services = null ): SpecsFormatter {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( SpecsFormatter::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return VariablesFormatter
|
||||
*/
|
||||
public static function getVariablesFormatter( ContainerInterface $services = null ): VariablesFormatter {
|
||||
public static function getVariablesFormatter( ?ContainerInterface $services = null ): VariablesFormatter {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( VariablesFormatter::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return LazyVariableComputer
|
||||
*/
|
||||
public static function getLazyVariableComputer( ContainerInterface $services = null ): LazyVariableComputer {
|
||||
public static function getLazyVariableComputer( ?ContainerInterface $services = null ): LazyVariableComputer {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( LazyVariableComputer::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return TextExtractor
|
||||
*/
|
||||
public static function getTextExtractor( ContainerInterface $services = null ): TextExtractor {
|
||||
public static function getTextExtractor( ?ContainerInterface $services = null ): TextExtractor {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( TextExtractor::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return VariablesManager
|
||||
*/
|
||||
public static function getVariablesManager( ContainerInterface $services = null ): VariablesManager {
|
||||
public static function getVariablesManager( ?ContainerInterface $services = null ): VariablesManager {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( VariablesManager::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ class AbuseFilterServices {
|
|||
* @return VariableGeneratorFactory
|
||||
*/
|
||||
public static function getVariableGeneratorFactory(
|
||||
ContainerInterface $services = null
|
||||
?ContainerInterface $services = null
|
||||
): VariableGeneratorFactory {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( VariableGeneratorFactory::SERVICE_NAME );
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return EditRevUpdater
|
||||
*/
|
||||
public static function getEditRevUpdater( ContainerInterface $services = null ): EditRevUpdater {
|
||||
public static function getEditRevUpdater( ?ContainerInterface $services = null ): EditRevUpdater {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( EditRevUpdater::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return BlockedDomainStorage
|
||||
*/
|
||||
public static function getBlockedDomainStorage( ContainerInterface $services = null ): BlockedDomainStorage {
|
||||
public static function getBlockedDomainStorage( ?ContainerInterface $services = null ): BlockedDomainStorage {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( BlockedDomainStorage::SERVICE_NAME );
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ class AbuseFilterServices {
|
|||
* @param ContainerInterface|null $services
|
||||
* @return BlockedDomainFilter
|
||||
*/
|
||||
public static function getBlockedDomainFilter( ContainerInterface $services = null ): BlockedDomainFilter {
|
||||
public static function getBlockedDomainFilter( ?ContainerInterface $services = null ): BlockedDomainFilter {
|
||||
return ( $services ?? MediaWikiServices::getInstance() )->get( BlockedDomainFilter::SERVICE_NAME );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class AutoPromoteGroupsHandler implements GetAutoPromoteGroupsHook {
|
|||
public function __construct(
|
||||
ConsequencesRegistry $consequencesRegistry,
|
||||
BlockAutopromoteStore $blockAutopromoteStore,
|
||||
BagOStuff $cache = null
|
||||
?BagOStuff $cache = null
|
||||
) {
|
||||
$this->cache = $cache ?? new HashBagOStuff();
|
||||
$this->consequencesRegistry = $consequencesRegistry;
|
||||
|
|
|
@ -16,7 +16,7 @@ class AFPSyntaxTree {
|
|||
/**
|
||||
* @param AFPTreeNode|null $root
|
||||
*/
|
||||
public function __construct( AFPTreeNode $root = null ) {
|
||||
public function __construct( ?AFPTreeNode $root = null ) {
|
||||
$this->rootNode = $root;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ class FilterEvaluator {
|
|||
IBufferingStatsdDataFactory $statsdDataFactory,
|
||||
Equivset $equivset,
|
||||
int $conditionsLimit,
|
||||
VariableHolder $vars = null
|
||||
?VariableHolder $vars = null
|
||||
) {
|
||||
$this->contLang = $contLang;
|
||||
$this->cache = $cache;
|
||||
|
|
|
@ -72,7 +72,7 @@ class RuleCheckerFactory {
|
|||
* @param VariableHolder|null $vars
|
||||
* @return FilterEvaluator
|
||||
*/
|
||||
public function newRuleChecker( VariableHolder $vars = null ): FilterEvaluator {
|
||||
public function newRuleChecker( ?VariableHolder $vars = null ): FilterEvaluator {
|
||||
return new FilterEvaluator(
|
||||
$this->contLang,
|
||||
$this->cache,
|
||||
|
|
|
@ -53,7 +53,7 @@ class RCVariableGenerator extends VariableGenerator {
|
|||
WikiPageFactory $wikiPageFactory,
|
||||
RecentChange $rc,
|
||||
User $contextUser,
|
||||
VariableHolder $vars = null
|
||||
?VariableHolder $vars = null
|
||||
) {
|
||||
parent::__construct( $hookRunner, $userFactory, $vars );
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class RunVariableGenerator extends VariableGenerator {
|
|||
WikiPageFactory $wikiPageFactory,
|
||||
User $user,
|
||||
Title $title,
|
||||
VariableHolder $vars = null
|
||||
?VariableHolder $vars = null
|
||||
) {
|
||||
parent::__construct( $hookRunner, $userFactory, $vars );
|
||||
$this->textExtractor = $textExtractor;
|
||||
|
@ -152,7 +152,7 @@ class RunVariableGenerator extends VariableGenerator {
|
|||
Content $newcontent,
|
||||
string $text,
|
||||
string $oldtext,
|
||||
Content $oldcontent = null
|
||||
?Content $oldcontent = null
|
||||
): VariableHolder {
|
||||
$this->addUserVars( $this->user )
|
||||
->addTitleVars( $this->title, 'page' );
|
||||
|
|
|
@ -34,7 +34,7 @@ class VariableGenerator {
|
|||
public function __construct(
|
||||
AbuseFilterHookRunner $hookRunner,
|
||||
UserFactory $userFactory,
|
||||
VariableHolder $vars = null
|
||||
?VariableHolder $vars = null
|
||||
) {
|
||||
$this->hookRunner = $hookRunner;
|
||||
$this->userFactory = $userFactory;
|
||||
|
@ -56,7 +56,7 @@ class VariableGenerator {
|
|||
* this is the entry. Null if it's for the current action being filtered.
|
||||
* @return $this For chaining
|
||||
*/
|
||||
public function addGenericVars( RecentChange $rc = null ): self {
|
||||
public function addGenericVars( ?RecentChange $rc = null ): self {
|
||||
$timestamp = $rc
|
||||
? MWTimestamp::convert( TS_UNIX, $rc->getAttribute( 'rc_timestamp' ) )
|
||||
: wfTimestamp( TS_UNIX );
|
||||
|
@ -76,7 +76,7 @@ class VariableGenerator {
|
|||
* this is the entry. Null if it's for the current action being filtered.
|
||||
* @return $this For chaining
|
||||
*/
|
||||
public function addUserVars( UserIdentity $userIdentity, RecentChange $rc = null ): self {
|
||||
public function addUserVars( UserIdentity $userIdentity, ?RecentChange $rc = null ): self {
|
||||
$asOf = $rc ? $rc->getAttribute( 'rc_timestamp' ) : wfTimestampNow();
|
||||
$user = $this->userFactory->newFromUserIdentity( $userIdentity );
|
||||
|
||||
|
@ -148,7 +148,7 @@ class VariableGenerator {
|
|||
public function addTitleVars(
|
||||
Title $title,
|
||||
string $prefix,
|
||||
RecentChange $rc = null
|
||||
?RecentChange $rc = null
|
||||
): self {
|
||||
if ( $rc && $rc->getAttribute( 'rc_type' ) == RC_NEW ) {
|
||||
$this->vars->setVar( $prefix . '_id', 0 );
|
||||
|
@ -239,7 +239,7 @@ class VariableGenerator {
|
|||
WikiPage $page,
|
||||
UserIdentity $userIdentity,
|
||||
bool $forFilter = true,
|
||||
PreparedUpdate $update = null
|
||||
?PreparedUpdate $update = null
|
||||
): self {
|
||||
$this->addDerivedEditVars();
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class VariableGeneratorFactory {
|
|||
* @param VariableHolder|null $holder
|
||||
* @return VariableGenerator
|
||||
*/
|
||||
public function newGenerator( VariableHolder $holder = null ): VariableGenerator {
|
||||
public function newGenerator( ?VariableHolder $holder = null ): VariableGenerator {
|
||||
return new VariableGenerator( $this->hookRunner, $this->userFactory, $holder );
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class VariableGeneratorFactory {
|
|||
* @param VariableHolder|null $holder
|
||||
* @return RunVariableGenerator
|
||||
*/
|
||||
public function newRunGenerator( User $user, Title $title, VariableHolder $holder = null ): RunVariableGenerator {
|
||||
public function newRunGenerator( User $user, Title $title, ?VariableHolder $holder = null ): RunVariableGenerator {
|
||||
return new RunVariableGenerator(
|
||||
$this->hookRunner,
|
||||
$this->userFactory,
|
||||
|
@ -89,7 +89,7 @@ class VariableGeneratorFactory {
|
|||
public function newRCGenerator(
|
||||
RecentChange $rc,
|
||||
User $contextUser,
|
||||
VariableHolder $holder = null
|
||||
?VariableHolder $holder = null
|
||||
): RCVariableGenerator {
|
||||
return new RCVariableGenerator(
|
||||
$this->hookRunner,
|
||||
|
|
|
@ -22,7 +22,7 @@ trait AbuseFilterCreateAccountTestTrait {
|
|||
protected function createAccount(
|
||||
string $accountName,
|
||||
bool $autocreate = false,
|
||||
User $creator = null
|
||||
?User $creator = null
|
||||
): StatusValue {
|
||||
$userFactory = MediaWikiServices::getInstance()->getUserFactory();
|
||||
$user = $userFactory->newFromName( $accountName );
|
||||
|
|
|
@ -41,7 +41,7 @@ class RCVariableGeneratorTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers \MediaWiki\Extension\AbuseFilter\VariableGenerator\RCVariableGenerator
|
||||
* @dataProvider provideRCRowTypes
|
||||
*/
|
||||
public function testGetVarsFromRCRow( string $type, string $action, UserIdentity $userIdentity = null ) {
|
||||
public function testGetVarsFromRCRow( string $type, string $action, ?UserIdentity $userIdentity = null ) {
|
||||
if ( $userIdentity && !$userIdentity->isRegistered() ) {
|
||||
// If we are testing anonymous user, make sure we disable temp accounts.
|
||||
$this->disableAutoCreateTempUser();
|
||||
|
|
|
@ -93,7 +93,7 @@ class ActionVariablesIntegrationTest extends ApiTestCase {
|
|||
$this->setService( ConsequencesLookup::SERVICE_NAME, $consequencesLookup );
|
||||
}
|
||||
|
||||
private function setAbuseLoggerFactoryWithEavesdrop( VariableHolder &$varHolder = null ): void {
|
||||
private function setAbuseLoggerFactoryWithEavesdrop( ?VariableHolder &$varHolder = null ): void {
|
||||
$factory = $this->createMock( AbuseLoggerFactory::class );
|
||||
$factory->method( 'newLogger' )
|
||||
->willReturnCallback( function ( $title, $user, $vars ) use ( &$varHolder ) {
|
||||
|
@ -298,7 +298,7 @@ class ActionVariablesIntegrationTest extends ApiTestCase {
|
|||
* @covers \MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer
|
||||
*/
|
||||
public function testEditVariables(
|
||||
array $expected, array $params, Content $oldContent = null
|
||||
array $expected, array $params, ?Content $oldContent = null
|
||||
) {
|
||||
$time = time();
|
||||
MWTimestamp::setFakeTime( $time );
|
||||
|
@ -386,7 +386,7 @@ class ActionVariablesIntegrationTest extends ApiTestCase {
|
|||
array $expected,
|
||||
string $accountName = 'New account',
|
||||
bool $autocreate = false,
|
||||
string $creatorName = null
|
||||
?string $creatorName = null
|
||||
) {
|
||||
$varHolder = null;
|
||||
$this->prepareServices();
|
||||
|
|
|
@ -14,7 +14,7 @@ trait AbuseFilterApiTestTrait {
|
|||
* @param FilterEvaluator|null $ruleChecker
|
||||
* @return RuleCheckerFactory
|
||||
*/
|
||||
protected function getRuleCheckerFactory( FilterEvaluator $ruleChecker = null ): RuleCheckerFactory {
|
||||
protected function getRuleCheckerFactory( ?FilterEvaluator $ruleChecker = null ): RuleCheckerFactory {
|
||||
$factory = $this->createMock( RuleCheckerFactory::class );
|
||||
if ( $ruleChecker !== null ) {
|
||||
$factory->expects( $this->atLeastOnce() )
|
||||
|
|
|
@ -21,7 +21,7 @@ class EchoNotifierTest extends MediaWikiIntegrationTestCase {
|
|||
'2' => 42,
|
||||
];
|
||||
|
||||
private function getFilterLookup( int $userID = null ): FilterLookup {
|
||||
private function getFilterLookup( ?int $userID = null ): FilterLookup {
|
||||
$lookup = $this->createMock( FilterLookup::class );
|
||||
$lookup->method( 'getFilter' )
|
||||
->willReturnCallback( function ( $filter, $global ) use ( $userID ) {
|
||||
|
|
|
@ -37,9 +37,9 @@ class FilterRunnerTest extends MediaWikiIntegrationTestCase {
|
|||
* @return FilterRunner
|
||||
*/
|
||||
private function getRunner(
|
||||
ChangeTagger $changeTagger = null,
|
||||
EditStashCache $cache = null,
|
||||
VariableHolder $vars = null,
|
||||
?ChangeTagger $changeTagger = null,
|
||||
?EditStashCache $cache = null,
|
||||
?VariableHolder $vars = null,
|
||||
$group = 'default'
|
||||
): FilterRunner {
|
||||
$opts = new ServiceOptions(
|
||||
|
|
|
@ -29,12 +29,12 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
|
||||
private function getThrottle(
|
||||
array $throttleParams = [],
|
||||
BagOStuff $cache = null,
|
||||
?BagOStuff $cache = null,
|
||||
bool $globalFilter = false,
|
||||
UserIdentity $user = null,
|
||||
Title $title = null,
|
||||
UserEditTracker $editTracker = null,
|
||||
string $ip = null
|
||||
?UserIdentity $user = null,
|
||||
?Title $title = null,
|
||||
?UserEditTracker $editTracker = null,
|
||||
?string $ip = null
|
||||
) {
|
||||
$specifier = new ActionSpecifier(
|
||||
'some-action',
|
||||
|
@ -95,7 +95,7 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @dataProvider provideThrottle
|
||||
*/
|
||||
public function testExecute( Throttle $throttle, bool $shouldDisable, MockObject $cache = null ) {
|
||||
public function testExecute( Throttle $throttle, bool $shouldDisable, ?MockObject $cache = null ) {
|
||||
if ( $cache ) {
|
||||
/** @var Throttle $wrapper */
|
||||
$wrapper = TestingAccessWrapper::newFromObject( $throttle );
|
||||
|
@ -115,7 +115,7 @@ class ThrottleTest extends MediaWikiUnitTestCase {
|
|||
string $ip,
|
||||
Title $title,
|
||||
UserIdentity $user,
|
||||
UserEditTracker $editTracker = null
|
||||
?UserEditTracker $editTracker = null
|
||||
) {
|
||||
$throttle = $this->getThrottle( [], null, false, $user, $title, $editTracker, $ip );
|
||||
/** @var Throttle $throttleWrapper */
|
||||
|
|
|
@ -21,7 +21,7 @@ use Wikimedia\TestingAccessWrapper;
|
|||
class WarnTest extends MediaWikiUnitTestCase {
|
||||
use ConsequenceGetMessageTestTrait;
|
||||
|
||||
private function getWarn( Parameters $params = null ): Warn {
|
||||
private function getWarn( ?Parameters $params = null ): Warn {
|
||||
return new Warn(
|
||||
$params ?? $this->createMock( Parameters::class ),
|
||||
'foo-bar-message',
|
||||
|
|
|
@ -42,9 +42,9 @@ class EditRevUpdaterTest extends MediaWikiUnitTestCase {
|
|||
* @return EditRevUpdater
|
||||
*/
|
||||
private function getUpdater(
|
||||
IDatabase $localDB = null,
|
||||
IDatabase $centralDB = null,
|
||||
RevisionLookup $revLookup = null
|
||||
?IDatabase $localDB = null,
|
||||
?IDatabase $centralDB = null,
|
||||
?RevisionLookup $revLookup = null
|
||||
): EditRevUpdater {
|
||||
$lbFactory = $this->createMock( LBFactory::class );
|
||||
$lbFactory->method( 'getPrimaryDatabase' )
|
||||
|
|
|
@ -40,9 +40,9 @@ class FilterImporterTest extends MediaWikiUnitTestCase {
|
|||
* @return FilterImporter
|
||||
*/
|
||||
private function getImporter(
|
||||
array $groups = null,
|
||||
bool $isCentral = null,
|
||||
array $actions = null
|
||||
?array $groups = null,
|
||||
?bool $isCentral = null,
|
||||
?array $actions = null
|
||||
): FilterImporter {
|
||||
$actions = array_fill_keys( $actions ?? [ 'warn', 'disallow', 'block' ], true );
|
||||
$registry = new ConsequencesRegistry(
|
||||
|
|
|
@ -43,9 +43,9 @@ class FilterLookupTest extends MediaWikiUnitTestCase {
|
|||
* @return FilterLookup
|
||||
*/
|
||||
private function getLookup(
|
||||
IDatabase $db = null,
|
||||
?IDatabase $db = null,
|
||||
$centralDB = false,
|
||||
WANObjectCache $cache = null,
|
||||
?WANObjectCache $cache = null,
|
||||
bool $filterIsCentral = false
|
||||
): FilterLookup {
|
||||
$lb = $this->createMock( ILoadBalancer::class );
|
||||
|
|
|
@ -34,7 +34,7 @@ class FilterProfilerTest extends MediaWikiUnitTestCase {
|
|||
'matches' => 0,
|
||||
];
|
||||
|
||||
private function getFilterProfiler( LoggerInterface $logger = null ): FilterProfiler {
|
||||
private function getFilterProfiler( ?LoggerInterface $logger = null ): FilterProfiler {
|
||||
$options = [
|
||||
'AbuseFilterConditionLimit' => 1000,
|
||||
'AbuseFilterSlowFilterRuntimeLimit' => 500,
|
||||
|
|
|
@ -37,8 +37,8 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
* @return FilterValidator
|
||||
*/
|
||||
private function getFilterValidator(
|
||||
AbuseFilterPermissionManager $permissionManager = null,
|
||||
FilterEvaluator $ruleChecker = null,
|
||||
?AbuseFilterPermissionManager $permissionManager = null,
|
||||
?FilterEvaluator $ruleChecker = null,
|
||||
array $restrictions = [],
|
||||
array $validFilterGroups = [ 'default' ]
|
||||
): FilterValidator {
|
||||
|
@ -481,8 +481,8 @@ class FilterValidatorTest extends MediaWikiUnitTestCase {
|
|||
public function testCheckAll(
|
||||
AbstractFilter $newFilter,
|
||||
?string $expectedError,
|
||||
AbuseFilterPermissionManager $permissionManager = null,
|
||||
FilterEvaluator $ruleChecker = null,
|
||||
?AbuseFilterPermissionManager $permissionManager = null,
|
||||
?FilterEvaluator $ruleChecker = null,
|
||||
array $restrictions = [],
|
||||
bool $isFatalError = false
|
||||
) {
|
||||
|
|
|
@ -45,7 +45,7 @@ abstract class ParserTestCase extends MediaWikiUnitTestCase {
|
|||
* @param LoggerInterface|null $logger
|
||||
* @return FilterEvaluator
|
||||
*/
|
||||
protected function getParser( LoggerInterface $logger = null ) {
|
||||
protected function getParser( ?LoggerInterface $logger = null ) {
|
||||
// We're not interested in caching or logging; tests should call respectively setCache
|
||||
// and setLogger if they want to test any of those.
|
||||
$keywordsManager = new KeywordsManager( $this->createMock( AbuseFilterHookRunner::class ) );
|
||||
|
|
|
@ -24,8 +24,8 @@ use Wikimedia\TestingAccessWrapper;
|
|||
class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
||||
|
||||
private function getStore(
|
||||
BlobStoreFactory $blobStoreFactory = null,
|
||||
BlobStore $blobStore = null
|
||||
?BlobStoreFactory $blobStoreFactory = null,
|
||||
?BlobStore $blobStore = null
|
||||
): VariablesBlobStore {
|
||||
$manager = $this->createMock( VariablesManager::class );
|
||||
$manager->method( 'dumpAllVars' )->willReturnCallback( static function ( VariableHolder $holder ) {
|
||||
|
@ -180,7 +180,7 @@ class VariablesBlobStoreTest extends MediaWikiUnitTestCase {
|
|||
/**
|
||||
* @dataProvider provideVariables
|
||||
*/
|
||||
public function testRoundTrip( array $toStore, array $expected = null ) {
|
||||
public function testRoundTrip( array $toStore, ?array $expected = null ) {
|
||||
$blobStore = $this->getBlobStore();
|
||||
$blobStoreFactory = $this->createMock( BlobStoreFactory::class );
|
||||
$blobStoreFactory->method( 'newBlobStore' )->willReturn( $blobStore );
|
||||
|
|
|
@ -23,7 +23,7 @@ class VariablesManagerTest extends MediaWikiUnitTestCase {
|
|||
* @param LazyVariableComputer|null $lazyComputer
|
||||
* @return VariablesManager
|
||||
*/
|
||||
private function getManager( LazyVariableComputer $lazyComputer = null ): VariablesManager {
|
||||
private function getManager( ?LazyVariableComputer $lazyComputer = null ): VariablesManager {
|
||||
return new VariablesManager(
|
||||
new KeywordsManager( $this->createMock( AbuseFilterHookRunner::class ) ),
|
||||
$lazyComputer ?? $this->createMock( LazyVariableComputer::class )
|
||||
|
|
Loading…
Reference in a new issue