Skip to content

Commit fde2667

Browse files
authored
Remove NodeAttributeReIndexer::reIndexNodeAttributes() on AbstractRector (#7652)
1 parent fff99ae commit fde2667

3 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/Application/ChangedNodeScopeRefresher.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ public function refresh(Node $node, string $filePath, ?MutatingScope $mutatingSc
5858
throw new ShouldNotHappenException($errorMessage);
5959
}
6060

61-
// reindex stmt_key already covered on StmtKeyNodeVisitor on next processNodes()
62-
// so set flag $reIndexStmtKey to false to avoid double loop
63-
NodeAttributeReIndexer::reIndexNodeAttributes($node, false);
61+
NodeAttributeReIndexer::reIndexNodeAttributes($node);
6462

6563
$stmts = $this->resolveStmts($node);
6664
$this->phpStanNodeScopeResolver->processNodes($stmts, $filePath, $mutatingScope);

src/Application/NodeAttributeReIndexer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
final class NodeAttributeReIndexer
2727
{
28-
public static function reIndexStmtsKeys(Node $node): ?Node
28+
private static function reIndexStmtsKeys(Node $node): ?Node
2929
{
3030
if (! $node instanceof StmtsAwareInterface && ! $node instanceof ClassLike && ! $node instanceof Declare_ && ! $node instanceof Block) {
3131
return null;
@@ -40,11 +40,9 @@ public static function reIndexStmtsKeys(Node $node): ?Node
4040
return $node;
4141
}
4242

43-
public static function reIndexNodeAttributes(Node $node, bool $reIndexStmtsKeys = true): ?Node
43+
public static function reIndexNodeAttributes(Node $node): ?Node
4444
{
45-
if ($reIndexStmtsKeys) {
46-
self::reIndexStmtsKeys($node);
47-
}
45+
self::reIndexStmtsKeys($node);
4846

4947
if ($node instanceof If_) {
5048
$node->elseifs = array_values($node->elseifs);

src/Rector/AbstractRector.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use PHPStan\Type\ObjectType;
2121
use PHPStan\Type\Type;
2222
use Rector\Application\ChangedNodeScopeRefresher;
23-
use Rector\Application\NodeAttributeReIndexer;
2423
use Rector\Application\Provider\CurrentFileProvider;
2524
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
2625
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
@@ -151,8 +150,6 @@ final public function enterNode(Node $node): int|Node|null
151150
throw new ShouldNotHappenException($errorMessage);
152151
}
153152

154-
NodeAttributeReIndexer::reIndexNodeAttributes($node);
155-
156153
$isIntRefactoredNode = is_int($refactoredNode);
157154

158155
/**

0 commit comments

Comments
 (0)