Skip to content

Commit 19e65a4

Browse files
authored
Merge pull request #369 from samsonasik/fix-dep
Bump to Rector ~2.2.9 and Fix deprecated StmtsAwareInterface
2 parents 45bc159 + fe800e1 commit 19e65a4

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"php": "^8.1",
99
"cakephp/console": "^5.0",
1010
"nette/utils": "^4.0",
11-
"rector/rector": "~2.2.3",
11+
"rector/rector": "~2.2.9",
1212
"symfony/string": "^6.0 || ^7.0"
1313
},
1414
"autoload": {

src/Rector/Rector/Namespace_/AppUsesStaticCallToUseStatementRector.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PhpParser\Node\UseItem;
1515
use PhpParser\NodeVisitor;
1616
use PHPStan\Type\ObjectType;
17-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
17+
use Rector\PhpParser\Enum\NodeGroup;
1818
use Rector\PhpParser\Node\BetterNodeFinder;
1919
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
2020
use Rector\PhpParser\Node\Value\ValueResolver;
@@ -61,12 +61,9 @@ public function getRuleDefinition(): RuleDefinition
6161
*/
6262
public function getNodeTypes(): array
6363
{
64-
return [StmtsAwareInterface::class];
64+
return NodeGroup::STMTS_AWARE;
6565
}
6666

67-
/**
68-
* @param \Rector\Contract\PhpParser\Node\StmtsAwareInterface $node
69-
*/
7067
public function refactor(Node $node): ?Node
7168
{
7269
if ($node->stmts === null) {
@@ -102,14 +99,14 @@ public function refactor(Node $node): ?Node
10299
* @param array<\PhpParser\Node\Stmt> $stmts
103100
* @param array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls
104101
*/
105-
private function removeCallLikeStmts(StmtsAwareInterface $node, array $stmts, array $appUsesStaticCalls): void
102+
private function removeCallLikeStmts(Node $node, array $stmts, array $appUsesStaticCalls): void
106103
{
107104
$currentStmt = null;
108105
$this->traverseNodesWithCallable(
109106
$stmts,
110107
function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) {
111108
// only lookup each of current stmts, avoid too deep traversal
112-
if ($subNode instanceof StmtsAwareInterface) {
109+
if (NodeGroup::isStmtAwareNode($subNode)) {
113110
return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
114111
}
115112

@@ -143,7 +140,7 @@ function (Node $subNode) use ($node, $appUsesStaticCalls, &$currentStmt) {
143140
/**
144141
* @return array<\PhpParser\Node\Expr\StaticCall>
145142
*/
146-
private function collectAppUseStaticCalls(StmtsAwareInterface $node): array
143+
private function collectAppUseStaticCalls(Node $node): array
147144
{
148145
/** @var array<\PhpParser\Node\Expr\StaticCall> $appUsesStaticCalls */
149146
$appUsesStaticCalls = $this->betterNodeFinder->find($node, function (Node $node): bool {

0 commit comments

Comments
 (0)