12
12
use function sprintf ;
13
13
14
14
/**
15
- * @implements Rule<Node>
15
+ * @implements Rule<Node\FunctionLike >
16
16
*/
17
17
class InvalidPromotedPropertiesRule implements Rule
18
18
{
@@ -23,22 +23,14 @@ public function __construct(private PhpVersion $phpVersion)
23
23
24
24
public function getNodeType (): string
25
25
{
26
- return Node::class;
26
+ return Node \FunctionLike ::class;
27
27
}
28
28
29
29
public function processNode (Node $ node , Scope $ scope ): array
30
30
{
31
- if (
32
- !$ node instanceof Node \Expr \ArrowFunction
33
- && !$ node instanceof Node \Stmt \ClassMethod
34
- && !$ node instanceof Node \Expr \Closure
35
- && !$ node instanceof Node \Stmt \Function_
36
- ) {
37
- return [];
38
- }
39
-
40
31
$ hasPromotedProperties = false ;
41
- foreach ($ node ->params as $ param ) {
32
+
33
+ foreach ($ node ->getParams () as $ param ) {
42
34
if ($ param ->flags === 0 ) {
43
35
continue ;
44
36
}
@@ -72,7 +64,7 @@ public function processNode(Node $node, Scope $scope): array
72
64
];
73
65
}
74
66
75
- if ($ node ->stmts === null ) {
67
+ if ($ node ->getStmts () === null ) {
76
68
return [
77
69
RuleErrorBuilder::message (
78
70
'Promoted properties are not allowed in abstract constructors. ' ,
@@ -81,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array
81
73
}
82
74
83
75
$ errors = [];
84
- foreach ($ node ->params as $ param ) {
76
+ foreach ($ node ->getParams () as $ param ) {
85
77
if ($ param ->flags === 0 ) {
86
78
continue ;
87
79
}
0 commit comments