From c65c1c17976ea8464413b8db5618c8d1d0bf7a92 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 15:32:33 +0100 Subject: [PATCH 1/2] [rector] add AvoidFeatureSetAttributeInRectorRule --- composer.json | 2 +- config/rector-rules.neon | 1 + .../RuleIdentifier/RectorRuleIdentifier.php | 2 + .../AvoidFeatureSetAttributeInRectorRule.php | 100 ++++++++++++++++++ ...oidFeatureSetAttributeInRectorRuleTest.php | 34 ++++++ .../Fixture/SetLocalAttribute.php | 24 +++++ .../Fixture/SkipAllowedSetAttributesNode.php | 26 +++++ .../config/configured_rule.neon | 2 + 8 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 src/Rules/Rector/AvoidFeatureSetAttributeInRectorRule.php create mode 100644 tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/AvoidFeatureSetAttributeInRectorRuleTest.php create mode 100644 tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SetLocalAttribute.php create mode 100644 tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SkipAllowedSetAttributesNode.php create mode 100644 tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/config/configured_rule.neon diff --git a/composer.json b/composer.json index 7448a2c0..2bd04ce5 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "symfony/framework-bundle": "6.1.*", "phpecs/phpecs": "^2.2", "tomasvotruba/class-leak": "^2.1", - "rector/rector": "^2.2", + "rector/rector": "^2.2.11", "phpstan/extension-installer": "^1.4", "symplify/phpstan-extensions": "^12.0", "tomasvotruba/unused-public": "^2.1", diff --git a/config/rector-rules.neon b/config/rector-rules.neon index 7dcac6df..b3b601d7 100644 --- a/config/rector-rules.neon +++ b/config/rector-rules.neon @@ -8,6 +8,7 @@ rules: - Symplify\PHPStanRules\Rules\Rector\PreferDirectIsNameRule - Symplify\PHPStanRules\Rules\Rector\NoOnlyNullReturnInRefactorRule - Symplify\PHPStanRules\Rules\Rector\NoIntegerRefactorReturnRule + - Symplify\PHPStanRules\Rules\Rector\AvoidFeatureSetAttributeInRectorRule services: # $node->getAttribute($1) => Type|null by $1 diff --git a/src/Enum/RuleIdentifier/RectorRuleIdentifier.php b/src/Enum/RuleIdentifier/RectorRuleIdentifier.php index 26490951..bb44a4e4 100644 --- a/src/Enum/RuleIdentifier/RectorRuleIdentifier.php +++ b/src/Enum/RuleIdentifier/RectorRuleIdentifier.php @@ -21,4 +21,6 @@ final class RectorRuleIdentifier public const NO_ONLY_NULL_RETURN_IN_REFACTOR = 'rector.noOnlyNullReturnInRefactor'; public const NO_INTEGER_REFACTOR_RETURN = 'rector.noIntegerRefactorReturn'; + + public const AVOID_FEATURE_SET_ATTRIBUTE_IN_RECTOR = 'rector.avoidFeatureSetAttributeInRector'; } diff --git a/src/Rules/Rector/AvoidFeatureSetAttributeInRectorRule.php b/src/Rules/Rector/AvoidFeatureSetAttributeInRectorRule.php new file mode 100644 index 00000000..d84d05f2 --- /dev/null +++ b/src/Rules/Rector/AvoidFeatureSetAttributeInRectorRule.php @@ -0,0 +1,100 @@ + + */ +final class AvoidFeatureSetAttributeInRectorRule implements Rule +{ + /** + * @var string + */ + public const ERROR_MESSAGE = 'Instead of using Rector rule to setAttribute("%s") to be used later, create a service extending "DecoratingNodeVisitorInterface". This ensures attribute decoration and node changes are in 2 separated steps.'; + + /** + * @var string[] + */ + private const ALLOWED_ATTRIBUTES = ['kind', 'origNode', 'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos']; + + public function getNodeType(): string + { + return InClassNode::class; + } + + /** + * @param InClassNode $node + */ + public function processNode(Node $node, Scope $scope): array + { + $classReflection = $scope->getClassReflection(); + if (! $classReflection instanceof ClassReflection) { + return []; + } + + if (! $classReflection->is(AbstractRector::class)) { + return []; + } + + $classLike = $node->getOriginalNode(); + + $nodeFinder = new NodeFinder(); + + /** @var MethodCall[] $methodCalls */ + $methodCalls = $nodeFinder->findInstanceOf($classLike, MethodCall::class); + + $ruleErrors = []; + + foreach ($methodCalls as $methodCall) { + if (! NamingHelper::isName($methodCall->name, 'setAttribute')) { + continue; + } + + $attributeName = $this->resolveAttributeKeyValue($methodCall, $scope); + if (! is_string($attributeName)) { + continue; + } + + if (in_array($attributeName, self::ALLOWED_ATTRIBUTES, true)) { + continue; + } + + $ruleError = RuleErrorBuilder::message(sprintf(self::ERROR_MESSAGE, $attributeName)) + ->identifier(RectorRuleIdentifier::AVOID_FEATURE_SET_ATTRIBUTE_IN_RECTOR) + ->build(); + + $ruleErrors[] = $ruleError; + } + + return $ruleErrors; + } + + private function resolveAttributeKeyValue(MethodCall $methodCall, Scope $scope): ?string + { + $firstArg = $methodCall->getArgs()[0]; + $attributeNameType = $scope->getType($firstArg->value); + + if (! $attributeNameType instanceof ConstantStringType) { + return null; + } + + return $attributeNameType->getValue(); + } +} diff --git a/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/AvoidFeatureSetAttributeInRectorRuleTest.php b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/AvoidFeatureSetAttributeInRectorRuleTest.php new file mode 100644 index 00000000..257c1b7f --- /dev/null +++ b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/AvoidFeatureSetAttributeInRectorRuleTest.php @@ -0,0 +1,34 @@ +analyse([$filePath], $expectedErrorsWithLines); + } + + public static function provideData(): Iterator + { + yield [__DIR__ . '/Fixture/SetLocalAttribute.php', [[ + sprintf(AvoidFeatureSetAttributeInRectorRule::ERROR_MESSAGE, 'some_attribute'), 11, + ]]]; + + yield [__DIR__ . '/Fixture/SkipAllowedSetAttributesNode.php', []]; + } + + protected function getRule(): Rule + { + return new AvoidFeatureSetAttributeInRectorRule(); + } +} diff --git a/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SetLocalAttribute.php b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SetLocalAttribute.php new file mode 100644 index 00000000..0056ede0 --- /dev/null +++ b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SetLocalAttribute.php @@ -0,0 +1,24 @@ +setAttribute('some_attribute', 'some_value'); + + return null; + } +} diff --git a/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SkipAllowedSetAttributesNode.php b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SkipAllowedSetAttributesNode.php new file mode 100644 index 00000000..ef62b65a --- /dev/null +++ b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/Fixture/SkipAllowedSetAttributesNode.php @@ -0,0 +1,26 @@ +setAttribute(AttributeKey::ORIGINAL_NODE, null); + $node->setAttribute(AttributeKey::KIND, 1); + + return null; + } +} diff --git a/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/config/configured_rule.neon b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/config/configured_rule.neon new file mode 100644 index 00000000..ff2fab05 --- /dev/null +++ b/tests/Rules/Rector/AvoidFeatureSetAttributeInRectorRule/config/configured_rule.neon @@ -0,0 +1,2 @@ +rules: + - Symplify\PHPStanRules\Rules\Rector\AvoidFeatureSetAttributeInRectorRule From e0efcf8f21d53ab8d730f2775808d5773a763591 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 15:38:52 +0100 Subject: [PATCH 2/2] restore interface --- .../NoDoctrineListenerWithoutContractRuleTest.php | 3 ++- .../NoGetRepositoryOnServiceRepositoryEntityRuleTest.php | 3 ++- .../NoGetRepositoryOutsideServiceRuleTest.php | 3 ++- .../NoParentRepositoryRule/NoParentRepositoryRuleTest.php | 3 ++- .../NoRepositoryCallInDataFixtureRuleTest.php | 3 ++- .../RequireQueryBuilderOnRepositoryRuleTest.php | 3 ++- .../RequireServiceRepositoryParentRuleTest.php | 3 ++- .../NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php | 3 ++- .../NoAssertFuncCallInTestsRuleTest.php | 3 ++- .../NoDoubleConsecutiveTestMockRuleTest.php | 3 ++- .../NoMockObjectAndRealObjectPropertyRuleTest.php | 3 ++- .../PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php | 3 ++- .../PublicStaticDataProviderRuleTest.php | 3 ++- .../NoIntegerRefactorReturnRuleTest.php | 3 ++- .../NoOnlyNullReturnInRefactorRuleTest.php | 3 ++- .../NoPropertyNodeAssignRule/NoPropertyNodeAssignRuleTest.php | 3 ++- .../PhpUpgradeDowngradeRegisteredInSetRuleTest.php | 3 ++- .../PreferDirectIsNameRule/PreferDirectIsNameRuleTest.php | 3 ++- .../StringFileAbsolutePathExistsRuleTest.php | 3 ++- .../FileNameMatchesExtensionRuleTest.php | 3 ++- .../NoSetClassServiceDuplicationRuleTest.php | 3 ++- .../ServicesExcludedDirectoryMustExistRuleTest.php | 3 ++- .../TaggedIteratorOverRepeatedServiceCallRuleTest.php | 3 ++- .../FormTypeClassNameRule/FormTypeClassNameRuleTest.php | 3 ++- .../NoAbstractControllerConstructorRuleTest.php | 3 ++- .../NoBareAndSecurityIsGrantedContentsRuleTest.php | 3 ++- .../NoClassLevelRouteRule/NoClassLevelRouteRuleTest.php | 3 ++- .../NoConstructorAndRequiredTogetherRuleTest.php | 3 ++- .../NoControllerMethodInjectionRuleTest.php | 3 ++- .../Symfony/NoGetInCommandRule/NoGetInCommandRuleTest.php | 3 ++- .../NoListenerWithoutContractRuleTest.php | 3 ++- .../NoRequiredOutsideClassRuleTest.php | 3 ++- .../NoRouteTrailingSlashPathRuleTest.php | 3 ++- .../Symfony/NoRoutingPrefixRule/NoRoutingPrefixRuleTest.php | 3 ++- .../NoServiceAutowireDuplicateRuleTest.php | 3 ++- .../RequireInvokableControllerRuleTest.php | 3 ++- .../RequireIsGrantedEnumRule/RequireIsGrantedEnumRuleTest.php | 3 ++- .../RequireRouteNameToGenerateControllerRouteRuleTest.php | 3 ++- .../RequiredOnlyInAbstractRuleTest.php | 3 ++- .../SingleArgEventDispatchRuleTest.php | 3 ++- .../SingleRequiredMethodRule/SingleRequiredMethodRuleTest.php | 3 ++- 41 files changed, 82 insertions(+), 41 deletions(-) diff --git a/tests/Rules/Doctrine/NoDoctrineListenerWithoutContractRule/NoDoctrineListenerWithoutContractRuleTest.php b/tests/Rules/Doctrine/NoDoctrineListenerWithoutContractRule/NoDoctrineListenerWithoutContractRuleTest.php index f2e4e98b..3c4d1ea3 100644 --- a/tests/Rules/Doctrine/NoDoctrineListenerWithoutContractRule/NoDoctrineListenerWithoutContractRuleTest.php +++ b/tests/Rules/Doctrine/NoDoctrineListenerWithoutContractRule/NoDoctrineListenerWithoutContractRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\NoDoctrineListenerWithoutContractRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\NoDoctrineListenerWithoutContractRule; @@ -31,7 +32,7 @@ public static function provideData(): Iterator ]]]; } - protected function getRule(): NoDoctrineListenerWithoutContractRule + protected function getRule(): Rule { return new NoDoctrineListenerWithoutContractRule(); } diff --git a/tests/Rules/Doctrine/NoGetRepositoryOnServiceRepositoryEntityRule/NoGetRepositoryOnServiceRepositoryEntityRuleTest.php b/tests/Rules/Doctrine/NoGetRepositoryOnServiceRepositoryEntityRule/NoGetRepositoryOnServiceRepositoryEntityRuleTest.php index dd990e08..cf56700d 100644 --- a/tests/Rules/Doctrine/NoGetRepositoryOnServiceRepositoryEntityRule/NoGetRepositoryOnServiceRepositoryEntityRuleTest.php +++ b/tests/Rules/Doctrine/NoGetRepositoryOnServiceRepositoryEntityRule/NoGetRepositoryOnServiceRepositoryEntityRuleTest.php @@ -6,6 +6,7 @@ use Iterator; use PHPStan\Reflection\ReflectionProvider; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\NoGetRepositoryOnServiceRepositoryEntityRule; @@ -39,7 +40,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipGetRepositoryOnNormalRepository.php', []]; } - protected function getRule(): NoGetRepositoryOnServiceRepositoryEntityRule + protected function getRule(): Rule { $reflectionProvider = self::getContainer()->getByType(ReflectionProvider::class); diff --git a/tests/Rules/Doctrine/NoGetRepositoryOutsideServiceRule/NoGetRepositoryOutsideServiceRuleTest.php b/tests/Rules/Doctrine/NoGetRepositoryOutsideServiceRule/NoGetRepositoryOutsideServiceRuleTest.php index 66b0f0d2..ef58b63d 100644 --- a/tests/Rules/Doctrine/NoGetRepositoryOutsideServiceRule/NoGetRepositoryOutsideServiceRuleTest.php +++ b/tests/Rules/Doctrine/NoGetRepositoryOutsideServiceRule/NoGetRepositoryOutsideServiceRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\NoGetRepositoryOutsideServiceRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\NoGetRepositoryOutsideServiceRule; @@ -37,7 +38,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipDynamicClassConstFetch.php', []]; } - protected function getRule(): NoGetRepositoryOutsideServiceRule + protected function getRule(): Rule { return new NoGetRepositoryOutsideServiceRule(); } diff --git a/tests/Rules/Doctrine/NoParentRepositoryRule/NoParentRepositoryRuleTest.php b/tests/Rules/Doctrine/NoParentRepositoryRule/NoParentRepositoryRuleTest.php index a2429d4c..a35ca252 100644 --- a/tests/Rules/Doctrine/NoParentRepositoryRule/NoParentRepositoryRuleTest.php +++ b/tests/Rules/Doctrine/NoParentRepositoryRule/NoParentRepositoryRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\NoParentRepositoryRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\NoParentRepositoryRule; @@ -22,7 +23,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SomeRepository.php', [[NoParentRepositoryRule::ERROR_MESSAGE, 9]]]; } - protected function getRule(): NoParentRepositoryRule + protected function getRule(): Rule { return new NoParentRepositoryRule(); } diff --git a/tests/Rules/Doctrine/NoRepositoryCallInDataFixtureRule/NoRepositoryCallInDataFixtureRuleTest.php b/tests/Rules/Doctrine/NoRepositoryCallInDataFixtureRule/NoRepositoryCallInDataFixtureRuleTest.php index 30a39e33..07b4a66c 100644 --- a/tests/Rules/Doctrine/NoRepositoryCallInDataFixtureRule/NoRepositoryCallInDataFixtureRuleTest.php +++ b/tests/Rules/Doctrine/NoRepositoryCallInDataFixtureRule/NoRepositoryCallInDataFixtureRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\NoRepositoryCallInDataFixtureRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\NoRepositoryCallInDataFixtureRule; @@ -30,7 +31,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipNonFixtureClass.php', []]; } - protected function getRule(): NoRepositoryCallInDataFixtureRule + protected function getRule(): Rule { return new NoRepositoryCallInDataFixtureRule(); } diff --git a/tests/Rules/Doctrine/RequireQueryBuilderOnRepositoryRule/RequireQueryBuilderOnRepositoryRuleTest.php b/tests/Rules/Doctrine/RequireQueryBuilderOnRepositoryRule/RequireQueryBuilderOnRepositoryRuleTest.php index b8fff510..72d0e8de 100644 --- a/tests/Rules/Doctrine/RequireQueryBuilderOnRepositoryRule/RequireQueryBuilderOnRepositoryRuleTest.php +++ b/tests/Rules/Doctrine/RequireQueryBuilderOnRepositoryRule/RequireQueryBuilderOnRepositoryRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\RequireQueryBuilderOnRepositoryRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Doctrine\RequireQueryBuilderOnRepositoryRule; @@ -32,7 +33,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): RequireQueryBuilderOnRepositoryRule + protected function getRule(): Rule { return new RequireQueryBuilderOnRepositoryRule(); } diff --git a/tests/Rules/Doctrine/RequireServiceRepositoryParentRule/RequireServiceRepositoryParentRuleTest.php b/tests/Rules/Doctrine/RequireServiceRepositoryParentRule/RequireServiceRepositoryParentRuleTest.php index 373d6929..3ee2baf5 100644 --- a/tests/Rules/Doctrine/RequireServiceRepositoryParentRule/RequireServiceRepositoryParentRuleTest.php +++ b/tests/Rules/Doctrine/RequireServiceRepositoryParentRule/RequireServiceRepositoryParentRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Doctrine\RequireServiceRepositoryParentRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Enum\DoctrineClass; @@ -28,7 +29,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipContractImplementingRepository.php', []]; } - protected function getRule(): RequireServiceRepositoryParentRule + protected function getRule(): Rule { return new RequireServiceRepositoryParentRule(); } diff --git a/tests/Rules/Explicit/NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php b/tests/Rules/Explicit/NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php index 07777067..f4a5f6bc 100644 --- a/tests/Rules/Explicit/NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php +++ b/tests/Rules/Explicit/NoProtectedClassStmtRule/NoProtectedClassStmtRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Explicit\NoProtectedClassStmtRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Explicit\NoProtectedClassStmtRule; @@ -28,7 +29,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipAbstractWithProtected.php', []]; } - protected function getRule(): NoProtectedClassStmtRule + protected function getRule(): Rule { return new NoProtectedClassStmtRule(); } diff --git a/tests/Rules/PHPUnit/NoAssertFuncCallInTestsRule/NoAssertFuncCallInTestsRuleTest.php b/tests/Rules/PHPUnit/NoAssertFuncCallInTestsRule/NoAssertFuncCallInTestsRuleTest.php index 4ac2e4ff..5684c13d 100644 --- a/tests/Rules/PHPUnit/NoAssertFuncCallInTestsRule/NoAssertFuncCallInTestsRuleTest.php +++ b/tests/Rules/PHPUnit/NoAssertFuncCallInTestsRule/NoAssertFuncCallInTestsRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\NoAssertFuncCallInTestsRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\PHPUnit\NoAssertFuncCallInTestsRule; @@ -24,7 +25,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipTestOutside.php', []]; } - protected function getRule(): NoAssertFuncCallInTestsRule + protected function getRule(): Rule { return new NoAssertFuncCallInTestsRule(); } diff --git a/tests/Rules/PHPUnit/NoDoubleConsecutiveTestMockRule/NoDoubleConsecutiveTestMockRuleTest.php b/tests/Rules/PHPUnit/NoDoubleConsecutiveTestMockRule/NoDoubleConsecutiveTestMockRuleTest.php index 79e662d7..5f344021 100644 --- a/tests/Rules/PHPUnit/NoDoubleConsecutiveTestMockRule/NoDoubleConsecutiveTestMockRuleTest.php +++ b/tests/Rules/PHPUnit/NoDoubleConsecutiveTestMockRule/NoDoubleConsecutiveTestMockRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\NoDoubleConsecutiveTestMockRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\PHPUnit\NoDoubleConsecutiveTestMockRule; @@ -24,7 +25,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipWillReturnCallback.php', []]; } - protected function getRule(): NoDoubleConsecutiveTestMockRule + protected function getRule(): Rule { return new NoDoubleConsecutiveTestMockRule(); } diff --git a/tests/Rules/PHPUnit/NoMockObjectAndRealObjectPropertyRule/NoMockObjectAndRealObjectPropertyRuleTest.php b/tests/Rules/PHPUnit/NoMockObjectAndRealObjectPropertyRule/NoMockObjectAndRealObjectPropertyRuleTest.php index 2e8d14d4..ba4eb711 100644 --- a/tests/Rules/PHPUnit/NoMockObjectAndRealObjectPropertyRule/NoMockObjectAndRealObjectPropertyRuleTest.php +++ b/tests/Rules/PHPUnit/NoMockObjectAndRealObjectPropertyRule/NoMockObjectAndRealObjectPropertyRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\NoMockObjectAndRealObjectPropertyRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\PHPUnit\NoMockObjectAndRealObjectPropertyRule; @@ -26,7 +27,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipNullableObject.php', []]; } - protected function getRule(): NoMockObjectAndRealObjectPropertyRule + protected function getRule(): Rule { return new NoMockObjectAndRealObjectPropertyRule(); } diff --git a/tests/Rules/PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php b/tests/Rules/PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php index e70bb32e..f0197271 100644 --- a/tests/Rules/PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php +++ b/tests/Rules/PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\NoMockOnlyTestRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\PHPUnit\NoMockOnlyTestRule; @@ -30,7 +31,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipConstraintValidatorTest.php', []]; } - protected function getRule(): NoMockOnlyTestRule + protected function getRule(): Rule { return new NoMockOnlyTestRule(); } diff --git a/tests/Rules/PHPUnit/PublicStaticDataProviderRule/PublicStaticDataProviderRuleTest.php b/tests/Rules/PHPUnit/PublicStaticDataProviderRule/PublicStaticDataProviderRuleTest.php index 82d75423..6860299b 100644 --- a/tests/Rules/PHPUnit/PublicStaticDataProviderRule/PublicStaticDataProviderRuleTest.php +++ b/tests/Rules/PHPUnit/PublicStaticDataProviderRule/PublicStaticDataProviderRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\PublicStaticDataProviderRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\PHPUnit\PublicStaticDataProviderRule; @@ -30,7 +31,7 @@ public static function provideData(): Iterator yield [[__DIR__ . '/Fixture/SkipStaticTest.php'], []]; } - protected function getRule(): PublicStaticDataProviderRule + protected function getRule(): Rule { return new PublicStaticDataProviderRule(); } diff --git a/tests/Rules/Rector/NoIntegerRefactorReturnRule/NoIntegerRefactorReturnRuleTest.php b/tests/Rules/Rector/NoIntegerRefactorReturnRule/NoIntegerRefactorReturnRuleTest.php index 2445e57b..b89525f8 100644 --- a/tests/Rules/Rector/NoIntegerRefactorReturnRule/NoIntegerRefactorReturnRuleTest.php +++ b/tests/Rules/Rector/NoIntegerRefactorReturnRule/NoIntegerRefactorReturnRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Rector\NoIntegerRefactorReturnRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Rector\NoIntegerRefactorReturnRule; @@ -30,7 +31,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/AllowNestedClosure.php', []]; } - protected function getRule(): NoIntegerRefactorReturnRule + protected function getRule(): Rule { return new NoIntegerRefactorReturnRule(); } diff --git a/tests/Rules/Rector/NoOnlyNullReturnInRefactorRule/NoOnlyNullReturnInRefactorRuleTest.php b/tests/Rules/Rector/NoOnlyNullReturnInRefactorRule/NoOnlyNullReturnInRefactorRuleTest.php index 732147fb..9293b5b7 100644 --- a/tests/Rules/Rector/NoOnlyNullReturnInRefactorRule/NoOnlyNullReturnInRefactorRuleTest.php +++ b/tests/Rules/Rector/NoOnlyNullReturnInRefactorRule/NoOnlyNullReturnInRefactorRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Rector\NoOnlyNullReturnInRefactorRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Rector\NoOnlyNullReturnInRefactorRule; @@ -24,7 +25,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipOtherReturnThanNull.php', []]; } - protected function getRule(): NoOnlyNullReturnInRefactorRule + protected function getRule(): Rule { return new NoOnlyNullReturnInRefactorRule(); } diff --git a/tests/Rules/Rector/NoPropertyNodeAssignRule/NoPropertyNodeAssignRuleTest.php b/tests/Rules/Rector/NoPropertyNodeAssignRule/NoPropertyNodeAssignRuleTest.php index 2590ba0e..665bf6e6 100644 --- a/tests/Rules/Rector/NoPropertyNodeAssignRule/NoPropertyNodeAssignRuleTest.php +++ b/tests/Rules/Rector/NoPropertyNodeAssignRule/NoPropertyNodeAssignRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Rector\NoPropertyNodeAssignRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Rector\NoPropertyNodeAssignRule; @@ -26,7 +27,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipNoRectorAssign.php', []]; } - protected function getRule(): NoPropertyNodeAssignRule + protected function getRule(): Rule { return new NoPropertyNodeAssignRule(); } diff --git a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/PhpUpgradeDowngradeRegisteredInSetRuleTest.php b/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/PhpUpgradeDowngradeRegisteredInSetRuleTest.php index 8e9edb32..fdec8a2d 100644 --- a/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/PhpUpgradeDowngradeRegisteredInSetRuleTest.php +++ b/tests/Rules/Rector/PhpUpgradeDowngradeRegisteredInSetRule/PhpUpgradeDowngradeRegisteredInSetRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Rector\PhpUpgradeDowngradeRegisteredInSetRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Rector\PhpUpgradeDowngradeRegisteredInSetRule; @@ -39,7 +40,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/DowngradePhp80/SomePhpFeature2Rector.php', [[$errorMessage, 10]]]; } - protected function getRule(): PhpUpgradeDowngradeRegisteredInSetRule + protected function getRule(): Rule { return new PhpUpgradeDowngradeRegisteredInSetRule(); } diff --git a/tests/Rules/Rector/PreferDirectIsNameRule/PreferDirectIsNameRuleTest.php b/tests/Rules/Rector/PreferDirectIsNameRule/PreferDirectIsNameRuleTest.php index ac1e8b9a..bfe44c94 100644 --- a/tests/Rules/Rector/PreferDirectIsNameRule/PreferDirectIsNameRuleTest.php +++ b/tests/Rules/Rector/PreferDirectIsNameRule/PreferDirectIsNameRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Rector\PreferDirectIsNameRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Rector\PreferDirectIsNameRule; @@ -29,7 +30,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): PreferDirectIsNameRule + protected function getRule(): Rule { return new PreferDirectIsNameRule(); } diff --git a/tests/Rules/StringFileAbsolutePathExistsRule/StringFileAbsolutePathExistsRuleTest.php b/tests/Rules/StringFileAbsolutePathExistsRule/StringFileAbsolutePathExistsRuleTest.php index 0b5ae4de..1519bba1 100644 --- a/tests/Rules/StringFileAbsolutePathExistsRule/StringFileAbsolutePathExistsRuleTest.php +++ b/tests/Rules/StringFileAbsolutePathExistsRule/StringFileAbsolutePathExistsRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\StringFileAbsolutePathExistsRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\StringFileAbsolutePathExistsRule; @@ -31,7 +32,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipClosure.php', []]; } - protected function getRule(): StringFileAbsolutePathExistsRule + protected function getRule(): Rule { return new StringFileAbsolutePathExistsRule(); } diff --git a/tests/Rules/Symfony/ConfigClosure/FileNameMatchesExtensionRule/FileNameMatchesExtensionRuleTest.php b/tests/Rules/Symfony/ConfigClosure/FileNameMatchesExtensionRule/FileNameMatchesExtensionRuleTest.php index e680e7fc..9ed7a9d8 100644 --- a/tests/Rules/Symfony/ConfigClosure/FileNameMatchesExtensionRule/FileNameMatchesExtensionRuleTest.php +++ b/tests/Rules/Symfony/ConfigClosure/FileNameMatchesExtensionRule/FileNameMatchesExtensionRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\ConfigClosure\FileNameMatchesExtensionRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\ConfigClosure\FileNameMatchesExtensionRule; @@ -31,7 +32,7 @@ public static function provideData(): Iterator ]]]; } - protected function getRule(): FileNameMatchesExtensionRule + protected function getRule(): Rule { return new FileNameMatchesExtensionRule(); } diff --git a/tests/Rules/Symfony/ConfigClosure/NoSetClassServiceDuplicationRule/NoSetClassServiceDuplicationRuleTest.php b/tests/Rules/Symfony/ConfigClosure/NoSetClassServiceDuplicationRule/NoSetClassServiceDuplicationRuleTest.php index e85fc244..a914c915 100644 --- a/tests/Rules/Symfony/ConfigClosure/NoSetClassServiceDuplicationRule/NoSetClassServiceDuplicationRuleTest.php +++ b/tests/Rules/Symfony/ConfigClosure/NoSetClassServiceDuplicationRule/NoSetClassServiceDuplicationRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\ConfigClosure\NoSetClassServiceDuplicationRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\ConfigClosure\NoSetClassServiceDuplicationRule; @@ -33,7 +34,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipSoleSet.php', []]; } - protected function getRule(): NoSetClassServiceDuplicationRule + protected function getRule(): Rule { return new NoSetClassServiceDuplicationRule(); } diff --git a/tests/Rules/Symfony/ConfigClosure/ServicesExcludedDirectoryMustExistRule/ServicesExcludedDirectoryMustExistRuleTest.php b/tests/Rules/Symfony/ConfigClosure/ServicesExcludedDirectoryMustExistRule/ServicesExcludedDirectoryMustExistRuleTest.php index 55a5ce64..4aab0e2d 100644 --- a/tests/Rules/Symfony/ConfigClosure/ServicesExcludedDirectoryMustExistRule/ServicesExcludedDirectoryMustExistRuleTest.php +++ b/tests/Rules/Symfony/ConfigClosure/ServicesExcludedDirectoryMustExistRule/ServicesExcludedDirectoryMustExistRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\ConfigClosure\ServicesExcludedDirectoryMustExistRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\ConfigClosure\ServicesExcludedDirectoryMustExistRule; @@ -33,7 +34,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): ServicesExcludedDirectoryMustExistRule + protected function getRule(): Rule { return new ServicesExcludedDirectoryMustExistRule(); } diff --git a/tests/Rules/Symfony/ConfigClosure/TaggedIteratorOverRepeatedServiceCallRule/TaggedIteratorOverRepeatedServiceCallRuleTest.php b/tests/Rules/Symfony/ConfigClosure/TaggedIteratorOverRepeatedServiceCallRule/TaggedIteratorOverRepeatedServiceCallRuleTest.php index fab97604..82720f74 100644 --- a/tests/Rules/Symfony/ConfigClosure/TaggedIteratorOverRepeatedServiceCallRule/TaggedIteratorOverRepeatedServiceCallRuleTest.php +++ b/tests/Rules/Symfony/ConfigClosure/TaggedIteratorOverRepeatedServiceCallRule/TaggedIteratorOverRepeatedServiceCallRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\ConfigClosure\TaggedIteratorOverRepeatedServiceCallRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\ConfigClosure\TaggedIteratorOverRepeatedServiceCallRule; @@ -33,7 +34,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipNonServiceCalls.php', []]; } - protected function getRule(): TaggedIteratorOverRepeatedServiceCallRule + protected function getRule(): Rule { return new TaggedIteratorOverRepeatedServiceCallRule(); } diff --git a/tests/Rules/Symfony/FormTypeClassNameRule/FormTypeClassNameRuleTest.php b/tests/Rules/Symfony/FormTypeClassNameRule/FormTypeClassNameRuleTest.php index 20702bd6..e6059270 100644 --- a/tests/Rules/Symfony/FormTypeClassNameRule/FormTypeClassNameRuleTest.php +++ b/tests/Rules/Symfony/FormTypeClassNameRule/FormTypeClassNameRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\FormTypeClassNameRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Form\AbstractType; @@ -34,7 +35,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): FormTypeClassNameRule + protected function getRule(): Rule { return new FormTypeClassNameRule(); } diff --git a/tests/Rules/Symfony/NoAbstractControllerConstructorRule/NoAbstractControllerConstructorRuleTest.php b/tests/Rules/Symfony/NoAbstractControllerConstructorRule/NoAbstractControllerConstructorRuleTest.php index 9e2f4de4..8639a1a8 100644 --- a/tests/Rules/Symfony/NoAbstractControllerConstructorRule/NoAbstractControllerConstructorRuleTest.php +++ b/tests/Rules/Symfony/NoAbstractControllerConstructorRule/NoAbstractControllerConstructorRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoAbstractControllerConstructorRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoAbstractControllerConstructorRule; @@ -30,7 +31,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipNonAbstractController.php', []]; } - protected function getRule(): NoAbstractControllerConstructorRule + protected function getRule(): Rule { return new NoAbstractControllerConstructorRule(); } diff --git a/tests/Rules/Symfony/NoBareAndSecurityIsGrantedContentsRule/NoBareAndSecurityIsGrantedContentsRuleTest.php b/tests/Rules/Symfony/NoBareAndSecurityIsGrantedContentsRule/NoBareAndSecurityIsGrantedContentsRuleTest.php index 62d75490..d973ad29 100644 --- a/tests/Rules/Symfony/NoBareAndSecurityIsGrantedContentsRule/NoBareAndSecurityIsGrantedContentsRuleTest.php +++ b/tests/Rules/Symfony/NoBareAndSecurityIsGrantedContentsRule/NoBareAndSecurityIsGrantedContentsRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoBareAndSecurityIsGrantedContentsRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoBareAndSecurityIsGrantedContentsRule; @@ -35,7 +36,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipSplitOne.php', []]; } - protected function getRule(): NoBareAndSecurityIsGrantedContentsRule + protected function getRule(): Rule { return new NoBareAndSecurityIsGrantedContentsRule(); } diff --git a/tests/Rules/Symfony/NoClassLevelRouteRule/NoClassLevelRouteRuleTest.php b/tests/Rules/Symfony/NoClassLevelRouteRule/NoClassLevelRouteRuleTest.php index af3c6e79..d5ff98a2 100644 --- a/tests/Rules/Symfony/NoClassLevelRouteRule/NoClassLevelRouteRuleTest.php +++ b/tests/Rules/Symfony/NoClassLevelRouteRule/NoClassLevelRouteRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoClassLevelRouteRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoClassLevelRouteRule; @@ -35,7 +36,7 @@ public static function provideData(): Iterator ], [[NoClassLevelRouteRule::ERROR_MESSAGE, 11]]]; } - protected function getRule(): NoClassLevelRouteRule + protected function getRule(): Rule { return new NoClassLevelRouteRule(); } diff --git a/tests/Rules/Symfony/NoConstructorAndRequiredTogetherRule/NoConstructorAndRequiredTogetherRuleTest.php b/tests/Rules/Symfony/NoConstructorAndRequiredTogetherRule/NoConstructorAndRequiredTogetherRuleTest.php index ee1ec32f..2301aafa 100644 --- a/tests/Rules/Symfony/NoConstructorAndRequiredTogetherRule/NoConstructorAndRequiredTogetherRuleTest.php +++ b/tests/Rules/Symfony/NoConstructorAndRequiredTogetherRule/NoConstructorAndRequiredTogetherRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoConstructorAndRequiredTogetherRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoConstructorAndRequiredTogetherRule; @@ -33,7 +34,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipCircularDependencyPrevention.php', []]; } - protected function getRule(): NoConstructorAndRequiredTogetherRule + protected function getRule(): Rule { return new NoConstructorAndRequiredTogetherRule(); } diff --git a/tests/Rules/Symfony/NoControllerMethodInjectionRule/NoControllerMethodInjectionRuleTest.php b/tests/Rules/Symfony/NoControllerMethodInjectionRule/NoControllerMethodInjectionRuleTest.php index f25760ea..811867cf 100644 --- a/tests/Rules/Symfony/NoControllerMethodInjectionRule/NoControllerMethodInjectionRuleTest.php +++ b/tests/Rules/Symfony/NoControllerMethodInjectionRule/NoControllerMethodInjectionRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoControllerMethodInjectionRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoControllerMethodInjectionRule; @@ -37,7 +38,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipScalarParameterController.php', []]; } - protected function getRule(): NoControllerMethodInjectionRule + protected function getRule(): Rule { return new NoControllerMethodInjectionRule(); } diff --git a/tests/Rules/Symfony/NoGetInCommandRule/NoGetInCommandRuleTest.php b/tests/Rules/Symfony/NoGetInCommandRule/NoGetInCommandRuleTest.php index b38781c7..aea9c469 100644 --- a/tests/Rules/Symfony/NoGetInCommandRule/NoGetInCommandRuleTest.php +++ b/tests/Rules/Symfony/NoGetInCommandRule/NoGetInCommandRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoGetInCommandRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoGetInCommandRule; @@ -25,7 +26,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SomeCommandWithGet.php', [[NoGetInCommandRule::ERROR_MESSAGE, 14]]]; } - protected function getRule(): NoGetInCommandRule + protected function getRule(): Rule { return new NoGetInCommandRule(); } diff --git a/tests/Rules/Symfony/NoListenerWithoutContractRule/NoListenerWithoutContractRuleTest.php b/tests/Rules/Symfony/NoListenerWithoutContractRule/NoListenerWithoutContractRuleTest.php index 6360471c..1e5423fd 100644 --- a/tests/Rules/Symfony/NoListenerWithoutContractRule/NoListenerWithoutContractRuleTest.php +++ b/tests/Rules/Symfony/NoListenerWithoutContractRule/NoListenerWithoutContractRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoListenerWithoutContractRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoListenerWithoutContractRule; @@ -39,7 +40,7 @@ public static function provideData(): Iterator ]]]; } - protected function getRule(): NoListenerWithoutContractRule + protected function getRule(): Rule { return new NoListenerWithoutContractRule(); } diff --git a/tests/Rules/Symfony/NoRequiredOutsideClassRule/NoRequiredOutsideClassRuleTest.php b/tests/Rules/Symfony/NoRequiredOutsideClassRule/NoRequiredOutsideClassRuleTest.php index 289fbb3f..18cab064 100644 --- a/tests/Rules/Symfony/NoRequiredOutsideClassRule/NoRequiredOutsideClassRuleTest.php +++ b/tests/Rules/Symfony/NoRequiredOutsideClassRule/NoRequiredOutsideClassRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoRequiredOutsideClassRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoRequiredOutsideClassRule; @@ -29,7 +30,7 @@ public static function provideData(): Iterator ], [[NoRequiredOutsideClassRule::ERROR_MESSAGE, 9], [NoRequiredOutsideClassRule::ERROR_MESSAGE, 10]]]; } - protected function getRule(): NoRequiredOutsideClassRule + protected function getRule(): Rule { return new NoRequiredOutsideClassRule(); } diff --git a/tests/Rules/Symfony/NoRouteTrailingSlashPathRule/NoRouteTrailingSlashPathRuleTest.php b/tests/Rules/Symfony/NoRouteTrailingSlashPathRule/NoRouteTrailingSlashPathRuleTest.php index 3c191ccb..d697d3e8 100644 --- a/tests/Rules/Symfony/NoRouteTrailingSlashPathRule/NoRouteTrailingSlashPathRuleTest.php +++ b/tests/Rules/Symfony/NoRouteTrailingSlashPathRule/NoRouteTrailingSlashPathRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoRouteTrailingSlashPathRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoRouteTrailingSlashPathRule; @@ -41,7 +42,7 @@ public static function provideData(): Iterator ]; } - protected function getRule(): NoRouteTrailingSlashPathRule + protected function getRule(): Rule { return new NoRouteTrailingSlashPathRule(); } diff --git a/tests/Rules/Symfony/NoRoutingPrefixRule/NoRoutingPrefixRuleTest.php b/tests/Rules/Symfony/NoRoutingPrefixRule/NoRoutingPrefixRuleTest.php index 414aa723..aaf7f015 100644 --- a/tests/Rules/Symfony/NoRoutingPrefixRule/NoRoutingPrefixRuleTest.php +++ b/tests/Rules/Symfony/NoRoutingPrefixRule/NoRoutingPrefixRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoRoutingPrefixRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoRoutingPrefixRule; @@ -35,7 +36,7 @@ public static function provideData(): Iterator ], [[NoRoutingPrefixRule::ERROR_MESSAGE, 8]]]; } - protected function getRule(): NoRoutingPrefixRule + protected function getRule(): Rule { return new NoRoutingPrefixRule(); } diff --git a/tests/Rules/Symfony/NoServiceAutowireDuplicateRule/NoServiceAutowireDuplicateRuleTest.php b/tests/Rules/Symfony/NoServiceAutowireDuplicateRule/NoServiceAutowireDuplicateRuleTest.php index 53fe1668..600d6237 100644 --- a/tests/Rules/Symfony/NoServiceAutowireDuplicateRule/NoServiceAutowireDuplicateRuleTest.php +++ b/tests/Rules/Symfony/NoServiceAutowireDuplicateRule/NoServiceAutowireDuplicateRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\NoServiceAutowireDuplicateRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\NoServiceAutowireDuplicateRule; @@ -28,7 +29,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/AlsoNoDuplicate.php', []]; } - protected function getRule(): NoServiceAutowireDuplicateRule + protected function getRule(): Rule { return new NoServiceAutowireDuplicateRule(); } diff --git a/tests/Rules/Symfony/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php b/tests/Rules/Symfony/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php index 53b9ff04..b2a1c25b 100644 --- a/tests/Rules/Symfony/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php +++ b/tests/Rules/Symfony/RequireInvokableControllerRule/RequireInvokableControllerRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\RequireInvokableControllerRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\RequireInvokableControllerRule; @@ -32,7 +33,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): RequireInvokableControllerRule + protected function getRule(): Rule { return new RequireInvokableControllerRule(); } diff --git a/tests/Rules/Symfony/RequireIsGrantedEnumRule/RequireIsGrantedEnumRuleTest.php b/tests/Rules/Symfony/RequireIsGrantedEnumRule/RequireIsGrantedEnumRuleTest.php index f26adf8c..ebdd08a5 100644 --- a/tests/Rules/Symfony/RequireIsGrantedEnumRule/RequireIsGrantedEnumRuleTest.php +++ b/tests/Rules/Symfony/RequireIsGrantedEnumRule/RequireIsGrantedEnumRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\RequireIsGrantedEnumRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\RequireIsGrantedEnumRule; @@ -29,7 +30,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): RequireIsGrantedEnumRule + protected function getRule(): Rule { return new RequireIsGrantedEnumRule(); } diff --git a/tests/Rules/Symfony/RequireRouteNameToGenerateControllerRouteRule/RequireRouteNameToGenerateControllerRouteRuleTest.php b/tests/Rules/Symfony/RequireRouteNameToGenerateControllerRouteRule/RequireRouteNameToGenerateControllerRouteRuleTest.php index ef7544ac..acf321d7 100644 --- a/tests/Rules/Symfony/RequireRouteNameToGenerateControllerRouteRule/RequireRouteNameToGenerateControllerRouteRuleTest.php +++ b/tests/Rules/Symfony/RequireRouteNameToGenerateControllerRouteRule/RequireRouteNameToGenerateControllerRouteRuleTest.php @@ -6,6 +6,7 @@ use Iterator; use PHPStan\Reflection\ReflectionProvider; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\RequireRouteNameToGenerateControllerRouteRule; @@ -39,7 +40,7 @@ public static function provideData(): Iterator ]]; } - protected function getRule(): RequireRouteNameToGenerateControllerRouteRule + protected function getRule(): Rule { $reflectionProvider = self::getContainer()->getByType(ReflectionProvider::class); diff --git a/tests/Rules/Symfony/RequiredOnlyInAbstractRule/RequiredOnlyInAbstractRuleTest.php b/tests/Rules/Symfony/RequiredOnlyInAbstractRule/RequiredOnlyInAbstractRuleTest.php index 33edb7a2..283db7e4 100644 --- a/tests/Rules/Symfony/RequiredOnlyInAbstractRule/RequiredOnlyInAbstractRuleTest.php +++ b/tests/Rules/Symfony/RequiredOnlyInAbstractRule/RequiredOnlyInAbstractRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\RequiredOnlyInAbstractRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\RequiredOnlyInAbstractRule; @@ -29,7 +30,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipParentDocumentRepository.php', []]; } - protected function getRule(): RequiredOnlyInAbstractRule + protected function getRule(): Rule { return new RequiredOnlyInAbstractRule(); } diff --git a/tests/Rules/Symfony/SingleArgEventDispatchRule/SingleArgEventDispatchRuleTest.php b/tests/Rules/Symfony/SingleArgEventDispatchRule/SingleArgEventDispatchRuleTest.php index c8589e8b..485f7b9c 100644 --- a/tests/Rules/Symfony/SingleArgEventDispatchRule/SingleArgEventDispatchRuleTest.php +++ b/tests/Rules/Symfony/SingleArgEventDispatchRule/SingleArgEventDispatchRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\SingleArgEventDispatchRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\SingleArgEventDispatchRule; @@ -25,7 +26,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipUnrelatedDispatch.php', []]; } - protected function getRule(): SingleArgEventDispatchRule + protected function getRule(): Rule { return new SingleArgEventDispatchRule(); } diff --git a/tests/Rules/Symfony/SingleRequiredMethodRule/SingleRequiredMethodRuleTest.php b/tests/Rules/Symfony/SingleRequiredMethodRule/SingleRequiredMethodRuleTest.php index 4134af87..6bcb74c8 100644 --- a/tests/Rules/Symfony/SingleRequiredMethodRule/SingleRequiredMethodRuleTest.php +++ b/tests/Rules/Symfony/SingleRequiredMethodRule/SingleRequiredMethodRuleTest.php @@ -5,6 +5,7 @@ namespace Symplify\PHPStanRules\Tests\Rules\Symfony\SingleRequiredMethodRule; use Iterator; +use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symplify\PHPStanRules\Rules\Symfony\SingleRequiredMethodRule; @@ -27,7 +28,7 @@ public static function provideData(): Iterator yield [__DIR__ . '/Fixture/SkipSingleRequiredMethod.php', []]; } - protected function getRule(): SingleRequiredMethodRule + protected function getRule(): Rule { return new SingleRequiredMethodRule(); }