1919class ParamAttributesRuleTest extends RuleTestCase
2020{
2121
22+ private bool $ checkPromotedPropertyAttribute ;
23+
2224 protected function getRule (): Rule
2325 {
2426 $ reflectionProvider = $ this ->createReflectionProvider ();
@@ -40,11 +42,13 @@ protected function getRule(): Rule
4042 new ClassCaseSensitivityCheck ($ reflectionProvider , false ),
4143 true ,
4244 ),
45+ $ this ->checkPromotedPropertyAttribute ,
4346 );
4447 }
4548
4649 public function testRule (): void
4750 {
51+ $ this ->checkPromotedPropertyAttribute = false ;
4852 $ this ->analyse ([__DIR__ . '/data/param-attributes.php ' ], [
4953 [
5054 'Attribute class ParamAttributes\Foo does not have the parameter target. ' ,
@@ -61,8 +65,44 @@ public function testRule(): void
6165 ]);
6266 }
6367
68+ public function testRuleCheckPromotedPropertyAttribute (): void
69+ {
70+ $ this ->checkPromotedPropertyAttribute = true ;
71+ $ this ->analyse ([__DIR__ . '/data/param-attributes.php ' ], [
72+ [
73+ 'Attribute class ParamAttributes\Foo does not have the parameter target. ' ,
74+ 33 ,
75+ ],
76+ [
77+ 'Attribute class ParamAttributes\Foo does not have the property target. ' ,
78+ 72 ,
79+ ],
80+ [
81+ 'Attribute class ParamAttributes\Bar does not have the property target. ' ,
82+ 74 ,
83+ ],
84+ [
85+ 'Attribute class ParamAttributes\Qux does not have the parameter target. ' ,
86+ 76 ,
87+ ],
88+ [
89+ 'Attribute class ParamAttributes\Qux does not have the parameter target. ' ,
90+ 78 ,
91+ ],
92+ [
93+ 'Attribute class ParamAttributes\Qux does not have the parameter target. ' ,
94+ 80 ,
95+ ],
96+ [
97+ 'Attribute class ParamAttributes\Qux does not have the parameter target. ' ,
98+ 82 ,
99+ ],
100+ ]);
101+ }
102+
64103 public function testSensitiveParameterAttribute (): void
65104 {
105+ $ this ->checkPromotedPropertyAttribute = false ;
66106 $ this ->analyse ([__DIR__ . '/data/sensitive-parameter.php ' ], []);
67107 }
68108
0 commit comments