diff --git a/conf/bleedingEdge.neon b/conf/bleedingEdge.neon index dab2046772..12fbf675a6 100644 --- a/conf/bleedingEdge.neon +++ b/conf/bleedingEdge.neon @@ -26,7 +26,6 @@ parameters: missingMagicSerializationRule: true nullContextForVoidReturningFunctions: true unescapeStrings: true - promotedPropertyAttribute: true alwaysCheckTooWideReturnTypeFinalMethods: true duplicateStubs: true logicalXor: true diff --git a/conf/config.level0.neon b/conf/config.level0.neon index 96c574acb0..58aa28e2af 100644 --- a/conf/config.level0.neon +++ b/conf/config.level0.neon @@ -75,6 +75,7 @@ rules: - PHPStan\Rules\Functions\FunctionAttributesRule - PHPStan\Rules\Functions\InnerFunctionRule - PHPStan\Rules\Functions\InvalidLexicalVariablesInClosureUseRule + - PHPStan\Rules\Functions\ParamAttributesRule - PHPStan\Rules\Functions\PrintfParametersRule - PHPStan\Rules\Functions\RedefinedParametersRule - PHPStan\Rules\Functions\ReturnNullsafeByRefRule @@ -152,13 +153,6 @@ services: arguments: checkFunctionNameCase: %checkFunctionNameCase% - - - class: PHPStan\Rules\Functions\ParamAttributesRule - tags: - - phpstan.rules.rule - arguments: - checkPromotedPropertyAttribute: %featureToggles.promotedPropertyAttribute% - - class: PHPStan\Rules\Constants\OverridingConstantRule arguments: diff --git a/conf/config.neon b/conf/config.neon index 6d63106da7..32daf47f61 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -61,7 +61,6 @@ parameters: missingMagicSerializationRule: false nullContextForVoidReturningFunctions: false unescapeStrings: false - promotedPropertyAttribute: false alwaysCheckTooWideReturnTypeFinalMethods: false duplicateStubs: false logicalXor: false diff --git a/conf/parametersSchema.neon b/conf/parametersSchema.neon index a929614b64..33169343a6 100644 --- a/conf/parametersSchema.neon +++ b/conf/parametersSchema.neon @@ -56,7 +56,6 @@ parametersSchema: missingMagicSerializationRule: bool() nullContextForVoidReturningFunctions: bool() unescapeStrings: bool() - promotedPropertyAttribute: bool() alwaysCheckTooWideReturnTypeFinalMethods: bool() duplicateStubs: bool() logicalXor: bool() diff --git a/src/Rules/Functions/ParamAttributesRule.php b/src/Rules/Functions/ParamAttributesRule.php index 7222f33939..aeadb1cfb6 100644 --- a/src/Rules/Functions/ParamAttributesRule.php +++ b/src/Rules/Functions/ParamAttributesRule.php @@ -15,7 +15,7 @@ class ParamAttributesRule implements Rule { - public function __construct(private AttributesCheck $attributesCheck, private bool $checkPromotedPropertyAttribute) + public function __construct(private AttributesCheck $attributesCheck) { } @@ -28,30 +28,17 @@ public function processNode(Node $node, Scope $scope): array { $targetName = 'parameter'; if ($node->flags !== 0) { - if ($this->checkPromotedPropertyAttribute) { - $propertyTargetErrors = $this->attributesCheck->check( - $scope, - $node->attrGroups, - Attribute::TARGET_PROPERTY, - 'property', - ); + $targetName = 'parameter or property'; - if (count($propertyTargetErrors) > 0) { - return $propertyTargetErrors; - } - } else { - $targetName = 'parameter or property'; + $propertyTargetErrors = $this->attributesCheck->check( + $scope, + $node->attrGroups, + Attribute::TARGET_PROPERTY, + $targetName, + ); - $propertyTargetErrors = $this->attributesCheck->check( - $scope, - $node->attrGroups, - Attribute::TARGET_PROPERTY, - $targetName, - ); - - if (count($propertyTargetErrors) === 0) { - return $propertyTargetErrors; - } + if (count($propertyTargetErrors) === 0) { + return $propertyTargetErrors; } } diff --git a/tests/PHPStan/Rules/Functions/ParamAttributesRuleTest.php b/tests/PHPStan/Rules/Functions/ParamAttributesRuleTest.php index 326993f669..ee517d6e74 100644 --- a/tests/PHPStan/Rules/Functions/ParamAttributesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ParamAttributesRuleTest.php @@ -19,8 +19,6 @@ class ParamAttributesRuleTest extends RuleTestCase { - private bool $checkPromotedPropertyAttribute; - protected function getRule(): Rule { $reflectionProvider = $this->createReflectionProvider(); @@ -42,13 +40,11 @@ protected function getRule(): Rule new ClassCaseSensitivityCheck($reflectionProvider, false), true, ), - $this->checkPromotedPropertyAttribute, ); } public function testRule(): void { - $this->checkPromotedPropertyAttribute = false; $this->analyse([__DIR__ . '/data/param-attributes.php'], [ [ 'Attribute class ParamAttributes\Foo does not have the parameter target.', @@ -65,44 +61,8 @@ public function testRule(): void ]); } - public function testRuleCheckPromotedPropertyAttribute(): void - { - $this->checkPromotedPropertyAttribute = true; - $this->analyse([__DIR__ . '/data/param-attributes.php'], [ - [ - 'Attribute class ParamAttributes\Foo does not have the parameter target.', - 33, - ], - [ - 'Attribute class ParamAttributes\Foo does not have the property target.', - 72, - ], - [ - 'Attribute class ParamAttributes\Bar does not have the property target.', - 74, - ], - [ - 'Attribute class ParamAttributes\Qux does not have the parameter target.', - 76, - ], - [ - 'Attribute class ParamAttributes\Qux does not have the parameter target.', - 78, - ], - [ - 'Attribute class ParamAttributes\Qux does not have the parameter target.', - 80, - ], - [ - 'Attribute class ParamAttributes\Qux does not have the parameter target.', - 82, - ], - ]); - } - public function testSensitiveParameterAttribute(): void { - $this->checkPromotedPropertyAttribute = false; $this->analyse([__DIR__ . '/data/sensitive-parameter.php'], []); }