|
14 | 14 | use PhpParser\Node\UseItem; |
15 | 15 | use PhpParser\NodeVisitor; |
16 | 16 | use PHPStan\Type\ObjectType; |
17 | | -use Rector\Contract\PhpParser\Node\StmtsAwareInterface; |
| 17 | +use Rector\PhpParser\Enum\NodeGroup; |
18 | 18 | use Rector\PhpParser\Node\BetterNodeFinder; |
19 | 19 | use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace; |
20 | 20 | use Rector\PhpParser\Node\Value\ValueResolver; |
@@ -61,12 +61,9 @@ public function getRuleDefinition(): RuleDefinition |
61 | 61 | */ |
62 | 62 | public function getNodeTypes(): array |
63 | 63 | { |
64 | | - return [StmtsAwareInterface::class]; |
| 64 | + return NodeGroup::STMTS_AWARE; |
65 | 65 | } |
66 | 66 |
|
67 | | - /** |
68 | | - * @param \Rector\Contract\PhpParser\Node\StmtsAwareInterface $node |
69 | | - */ |
70 | 67 | public function refactor(Node $node): ?Node |
71 | 68 | { |
72 | 69 | if ($node->stmts === null) { |
@@ -102,14 +99,14 @@ public function refactor(Node $node): ?Node |
102 | 99 | * @param array<\PhpParser\Node\Stmt> $stmts |
103 | 100 | * @param array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls |
104 | 101 | */ |
105 | | - private function removeCallLikeStmts(StmtsAwareInterface $node, array $stmts, array $appUsesStaticCalls): void |
| 102 | + private function removeCallLikeStmts(Node $node, array $stmts, array $appUsesStaticCalls): void |
106 | 103 | { |
107 | 104 | $currentStmt = null; |
108 | 105 | $this->traverseNodesWithCallable( |
109 | 106 | $stmts, |
110 | 107 | function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) { |
111 | 108 | // only lookup each of current stmts, avoid too deep traversal |
112 | | - if ($subNode instanceof StmtsAwareInterface) { |
| 109 | + if (NodeGroup::isStmtAwareNode($subNode)) { |
113 | 110 | return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
114 | 111 | } |
115 | 112 |
|
@@ -143,7 +140,7 @@ function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) { |
143 | 140 | /** |
144 | 141 | * @return array<\PhpParser\Node\Expr\StaticCall> |
145 | 142 | */ |
146 | | - private function collectAppUseStaticCalls(StmtsAwareInterface $node): array |
| 143 | + private function collectAppUseStaticCalls(Node $node): array |
147 | 144 | { |
148 | 145 | /** @var array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls */ |
149 | 146 | $appUsesStaticCalls = $this->betterNodeFinder->find($node, function (Node $node): bool { |
|
0 commit comments