Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jan 2, 2025
1 parent 3dd6b90 commit 7d093da
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function processNodes(
// early check here as UnreachableStatementNode is special VirtualNode
// so node to be checked inside
if ($node instanceof UnreachableStatementNode) {
$this->processUnreachableStatementNode($node, $filePath, $mutatingScope);
$this->processUnreachableStatementNode($node, $mutatingScope, $nodeCallback);
return;
}

Expand Down Expand Up @@ -573,16 +573,26 @@ private function processTryCatch(TryCatch $tryCatch, MutatingScope $mutatingScop
}
}

/**
* @param callable(Node $node, MutatingScope $scope): void $nodeCallback
*/
private function processUnreachableStatementNode(
UnreachableStatementNode $unreachableStatementNode,
string $filePath,
MutatingScope $mutatingScope
MutatingScope $mutatingScope,
callable $nodeCallback
): void {
$originalStmt = $unreachableStatementNode->getOriginalStatement();
$originalStmt->setAttribute(AttributeKey::IS_UNREACHABLE, true);
$originalStmt->setAttribute(AttributeKey::SCOPE, $mutatingScope);

$this->processNodes(array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()), $filePath, $mutatingScope);
foreach ($unreachableStatementNode->getNextStatements() as $nextStatement) {
$nextStatement->setAttribute(AttributeKey::IS_UNREACHABLE, true);
}

$this->nodeScopeResolverProcessNodes(
array_merge([$originalStmt], $unreachableStatementNode->getNextStatements()),
$mutatingScope,
$nodeCallback
);
}

/**
Expand Down

0 comments on commit 7d093da

Please sign in to comment.