diff --git a/includes/AbuseFilterServices.php b/includes/AbuseFilterServices.php index d258695f4..34f565903 100644 --- a/includes/AbuseFilterServices.php +++ b/includes/AbuseFilterServices.php @@ -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 ); } } diff --git a/includes/Hooks/Handlers/AutoPromoteGroupsHandler.php b/includes/Hooks/Handlers/AutoPromoteGroupsHandler.php index 77e8d67e4..6f7f5acf5 100644 --- a/includes/Hooks/Handlers/AutoPromoteGroupsHandler.php +++ b/includes/Hooks/Handlers/AutoPromoteGroupsHandler.php @@ -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; diff --git a/includes/Parser/AFPSyntaxTree.php b/includes/Parser/AFPSyntaxTree.php index 352df97e1..6551eb2f1 100644 --- a/includes/Parser/AFPSyntaxTree.php +++ b/includes/Parser/AFPSyntaxTree.php @@ -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; } diff --git a/includes/Parser/FilterEvaluator.php b/includes/Parser/FilterEvaluator.php index f0ad5da72..1e5e5acbd 100644 --- a/includes/Parser/FilterEvaluator.php +++ b/includes/Parser/FilterEvaluator.php @@ -216,7 +216,7 @@ class FilterEvaluator { IBufferingStatsdDataFactory $statsdDataFactory, Equivset $equivset, int $conditionsLimit, - VariableHolder $vars = null + ?VariableHolder $vars = null ) { $this->contLang = $contLang; $this->cache = $cache; diff --git a/includes/Parser/RuleCheckerFactory.php b/includes/Parser/RuleCheckerFactory.php index 47f0be340..7b258c87d 100644 --- a/includes/Parser/RuleCheckerFactory.php +++ b/includes/Parser/RuleCheckerFactory.php @@ -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, diff --git a/includes/VariableGenerator/RCVariableGenerator.php b/includes/VariableGenerator/RCVariableGenerator.php index da75c6746..2e7381111 100644 --- a/includes/VariableGenerator/RCVariableGenerator.php +++ b/includes/VariableGenerator/RCVariableGenerator.php @@ -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 ); diff --git a/includes/VariableGenerator/RunVariableGenerator.php b/includes/VariableGenerator/RunVariableGenerator.php index f732eb01a..1b0f029c8 100644 --- a/includes/VariableGenerator/RunVariableGenerator.php +++ b/includes/VariableGenerator/RunVariableGenerator.php @@ -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' ); diff --git a/includes/VariableGenerator/VariableGenerator.php b/includes/VariableGenerator/VariableGenerator.php index 656146a9d..74a0e2752 100644 --- a/includes/VariableGenerator/VariableGenerator.php +++ b/includes/VariableGenerator/VariableGenerator.php @@ -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(); diff --git a/includes/VariableGenerator/VariableGeneratorFactory.php b/includes/VariableGenerator/VariableGeneratorFactory.php index 09f5c2708..4e72f9cbe 100644 --- a/includes/VariableGenerator/VariableGeneratorFactory.php +++ b/includes/VariableGenerator/VariableGeneratorFactory.php @@ -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, diff --git a/tests/phpunit/AbuseFilterCreateAccountTestTrait.php b/tests/phpunit/AbuseFilterCreateAccountTestTrait.php index 276df5256..bf88daf62 100644 --- a/tests/phpunit/AbuseFilterCreateAccountTestTrait.php +++ b/tests/phpunit/AbuseFilterCreateAccountTestTrait.php @@ -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 ); diff --git a/tests/phpunit/RCVariableGeneratorTest.php b/tests/phpunit/RCVariableGeneratorTest.php index 12b99e994..e65a4991a 100644 --- a/tests/phpunit/RCVariableGeneratorTest.php +++ b/tests/phpunit/RCVariableGeneratorTest.php @@ -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(); diff --git a/tests/phpunit/integration/ActionVariablesIntegrationTest.php b/tests/phpunit/integration/ActionVariablesIntegrationTest.php index 4f0750d47..038304990 100644 --- a/tests/phpunit/integration/ActionVariablesIntegrationTest.php +++ b/tests/phpunit/integration/ActionVariablesIntegrationTest.php @@ -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(); diff --git a/tests/phpunit/integration/Api/AbuseFilterApiTestTrait.php b/tests/phpunit/integration/Api/AbuseFilterApiTestTrait.php index fadfdaa35..28fa51bd8 100644 --- a/tests/phpunit/integration/Api/AbuseFilterApiTestTrait.php +++ b/tests/phpunit/integration/Api/AbuseFilterApiTestTrait.php @@ -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() ) diff --git a/tests/phpunit/integration/EchoNotifierTest.php b/tests/phpunit/integration/EchoNotifierTest.php index 1c69a7f9b..6fa9c6cb0 100644 --- a/tests/phpunit/integration/EchoNotifierTest.php +++ b/tests/phpunit/integration/EchoNotifierTest.php @@ -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 ) { diff --git a/tests/phpunit/integration/FilterRunnerTest.php b/tests/phpunit/integration/FilterRunnerTest.php index 03921bdad..908e14bec 100644 --- a/tests/phpunit/integration/FilterRunnerTest.php +++ b/tests/phpunit/integration/FilterRunnerTest.php @@ -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( diff --git a/tests/phpunit/unit/Consequences/Consequence/ThrottleTest.php b/tests/phpunit/unit/Consequences/Consequence/ThrottleTest.php index 6a5b60ffd..fe00b8e62 100644 --- a/tests/phpunit/unit/Consequences/Consequence/ThrottleTest.php +++ b/tests/phpunit/unit/Consequences/Consequence/ThrottleTest.php @@ -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 */ diff --git a/tests/phpunit/unit/Consequences/Consequence/WarnTest.php b/tests/phpunit/unit/Consequences/Consequence/WarnTest.php index 7740f52d6..78fc56ca6 100644 --- a/tests/phpunit/unit/Consequences/Consequence/WarnTest.php +++ b/tests/phpunit/unit/Consequences/Consequence/WarnTest.php @@ -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', diff --git a/tests/phpunit/unit/EditRevUpdaterTest.php b/tests/phpunit/unit/EditRevUpdaterTest.php index de943cdad..2d3e1cbdf 100644 --- a/tests/phpunit/unit/EditRevUpdaterTest.php +++ b/tests/phpunit/unit/EditRevUpdaterTest.php @@ -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' ) diff --git a/tests/phpunit/unit/FilterImporterTest.php b/tests/phpunit/unit/FilterImporterTest.php index ecf733990..0cd0477cb 100644 --- a/tests/phpunit/unit/FilterImporterTest.php +++ b/tests/phpunit/unit/FilterImporterTest.php @@ -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( diff --git a/tests/phpunit/unit/FilterLookupTest.php b/tests/phpunit/unit/FilterLookupTest.php index 8db8ac539..c860162a9 100644 --- a/tests/phpunit/unit/FilterLookupTest.php +++ b/tests/phpunit/unit/FilterLookupTest.php @@ -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 ); diff --git a/tests/phpunit/unit/FilterProfilerTest.php b/tests/phpunit/unit/FilterProfilerTest.php index ed40784c5..acefb1b09 100644 --- a/tests/phpunit/unit/FilterProfilerTest.php +++ b/tests/phpunit/unit/FilterProfilerTest.php @@ -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, diff --git a/tests/phpunit/unit/FilterValidatorTest.php b/tests/phpunit/unit/FilterValidatorTest.php index 2bf116219..5a6c80456 100644 --- a/tests/phpunit/unit/FilterValidatorTest.php +++ b/tests/phpunit/unit/FilterValidatorTest.php @@ -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 ) { diff --git a/tests/phpunit/unit/Parser/ParserTestCase.php b/tests/phpunit/unit/Parser/ParserTestCase.php index 5d7105a12..c816b2b9e 100644 --- a/tests/phpunit/unit/Parser/ParserTestCase.php +++ b/tests/phpunit/unit/Parser/ParserTestCase.php @@ -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 ) ); diff --git a/tests/phpunit/unit/Variables/VariablesBlobStoreTest.php b/tests/phpunit/unit/Variables/VariablesBlobStoreTest.php index 1fdeb3efd..dae65fa04 100644 --- a/tests/phpunit/unit/Variables/VariablesBlobStoreTest.php +++ b/tests/phpunit/unit/Variables/VariablesBlobStoreTest.php @@ -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 ); diff --git a/tests/phpunit/unit/Variables/VariablesManagerTest.php b/tests/phpunit/unit/Variables/VariablesManagerTest.php index 9616e789c..455fd69ee 100644 --- a/tests/phpunit/unit/Variables/VariablesManagerTest.php +++ b/tests/phpunit/unit/Variables/VariablesManagerTest.php @@ -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 )