File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public function __construct(
2828
2929 /**
3030 * @param AttributeGroup[] $attrGroups
31- * @param Attribute::TARGET_* $requiredTarget
31+ * @param int-mask-of< Attribute::TARGET_*> $requiredTarget
3232 * @return RuleError[]
3333 */
3434 public function check (
Original file line number Diff line number Diff line change 77use PHPStan \Analyser \Scope ;
88use PHPStan \Rules \AttributesCheck ;
99use PHPStan \Rules \Rule ;
10- use function count ;
1110
1211/**
1312 * @implements Rule<Node\Param>
@@ -27,25 +26,16 @@ public function getNodeType(): string
2726 public function processNode (Node $ node , Scope $ scope ): array
2827 {
2928 $ targetName = 'parameter ' ;
29+ $ targetType = Attribute::TARGET_PARAMETER ;
3030 if ($ node ->flags !== 0 ) {
3131 $ targetName = 'parameter or property ' ;
32-
33- $ propertyTargetErrors = $ this ->attributesCheck ->check (
34- $ scope ,
35- $ node ->attrGroups ,
36- Attribute::TARGET_PROPERTY ,
37- $ targetName ,
38- );
39-
40- if (count ($ propertyTargetErrors ) === 0 ) {
41- return $ propertyTargetErrors ;
42- }
32+ $ targetType |= Attribute::TARGET_PROPERTY ;
4333 }
4434
4535 return $ this ->attributesCheck ->check (
4636 $ scope ,
4737 $ node ->attrGroups ,
48- Attribute:: TARGET_PARAMETER ,
38+ $ targetType ,
4939 $ targetName ,
5040 );
5141 }
Original file line number Diff line number Diff line change @@ -66,4 +66,9 @@ public function testSensitiveParameterAttribute(): void
6666 $ this ->analyse ([__DIR__ . '/data/sensitive-parameter.php ' ], []);
6767 }
6868
69+ public function testBug10298 (): void
70+ {
71+ $ this ->analyse ([__DIR__ . '/data/bug-10298.php ' ], []);
72+ }
73+
6974}
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug10298 ;
4+
5+ #[\Attribute(\Attribute::TARGET_PROPERTY )]
6+ class PropAttr {}
7+
8+ #[\Attribute(\Attribute::TARGET_PARAMETER )]
9+ class ParamAttr {}
10+
11+ class Test
12+ {
13+ public function __construct (
14+ #[PropAttr]
15+ #[ParamAttr]
16+ public string $ test
17+ ) {}
18+ }
You can’t perform that action at this time.
0 commit comments