Skip to content

Commit a532baf

Browse files
paulbalandanondrejmirtes
authored andcommitted
InvalidPromotedPropertiesRule - use FunctionLike as node type
1 parent 24f92cc commit a532baf

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/Rules/Classes/InvalidPromotedPropertiesRule.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function sprintf;
1313

1414
/**
15-
* @implements Rule<Node>
15+
* @implements Rule<Node\FunctionLike>
1616
*/
1717
class 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

Comments
 (0)