File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
tests/PHPStan/Rules/Classes Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -97,4 +97,18 @@ public function testRule(): void
9797 ]);
9898 }
9999
100+ public function testRuleForEnums (): void
101+ {
102+ if (!self ::$ useStaticReflectionProvider && PHP_VERSION_ID < 80100 ) {
103+ $ this ->markTestSkipped ('Test requires PHP 8.1. ' );
104+ }
105+
106+ $ this ->analyse ([__DIR__ . '/data/enum-attributes.php ' ], [
107+ [
108+ 'Attribute class EnumAttributes\AttributeWithPropertyTarget does not have the class target. ' ,
109+ 23 ,
110+ ],
111+ ]);
112+ }
113+
100114}
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.1
2+
3+ namespace EnumAttributes ;
4+
5+ #[\Attribute]
6+ class AttributeWithoutSpecificTarget
7+ {
8+
9+ }
10+
11+ #[\Attribute(\Attribute::TARGET_PROPERTY )]
12+ class AttributeWithPropertyTarget
13+ {
14+
15+ }
16+
17+ #[AttributeWithoutSpecificTarget]
18+ enum EnumWithValidClassAttribute
19+ {
20+
21+ }
22+
23+ #[AttributeWithPropertyTarget]
24+ enum EnumWithInvalidClassAttribute
25+ {
26+
27+ }
You can’t perform that action at this time.
0 commit comments