Skip to content

Commit

Permalink
Cherry-pick StmtKeyNodeVisitor check not Node (#3883)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed May 17, 2023
1 parent ae78ef1 commit 9e8880b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function enterNode(Node $node): ?Node

$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);

// parent node of Stmt must be StmtsAwareInterface, except on top level namespace or file without namespace
if (! $parentNode instanceof StmtsAwareInterface) {
// parent node of Stmt must be Node, except on top level namespace or file without namespace
if (! $parentNode instanceof Node) {
// on __construct(), $file not yet a File object
$file = $this->currentFileProvider->getFile();
if ($file instanceof File) {
Expand All @@ -69,6 +69,10 @@ public function enterNode(Node $node): ?Node
return null;
}

if (! $parentNode instanceof StmtsAwareInterface) {
return null;
}

// re-index stmt key under parent node
$this->setStmtKeyAttribute($parentNode);
return null;
Expand Down

0 comments on commit 9e8880b

Please sign in to comment.