1212use function sprintf ;
1313
1414/**
15- * @implements Rule<Node>
15+ * @implements Rule<Node\FunctionLike >
1616 */
1717class InvalidPromotedPropertiesRule implements Rule
1818{
@@ -23,22 +23,14 @@ public function __construct(private PhpVersion $phpVersion)
2323
2424 public function getNodeType (): string
2525 {
26- return Node::class;
26+ return Node \FunctionLike ::class;
2727 }
2828
2929 public function processNode (Node $ node , Scope $ scope ): array
3030 {
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-
4031 $ hasPromotedProperties = false ;
41- foreach ($ node ->params as $ param ) {
32+
33+ foreach ($ node ->getParams () as $ param ) {
4234 if ($ param ->flags === 0 ) {
4335 continue ;
4436 }
@@ -72,7 +64,7 @@ public function processNode(Node $node, Scope $scope): array
7264 ];
7365 }
7466
75- if ($ node ->stmts === null ) {
67+ if ($ node ->getStmts () === null ) {
7668 return [
7769 RuleErrorBuilder::message (
7870 'Promoted properties are not allowed in abstract constructors. ' ,
@@ -81,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array
8173 }
8274
8375 $ errors = [];
84- foreach ($ node ->params as $ param ) {
76+ foreach ($ node ->getParams () as $ param ) {
8577 if ($ param ->flags === 0 ) {
8678 continue ;
8779 }
0 commit comments