Skip to content

Commit

Permalink
Cleanup scope check on UnreachableStatementNodeVisitor (#5648)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 21, 2024
1 parent 3b44873 commit a4445df
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PHPStan/NodeVisitor/UnreachableStatementNodeVisitor.php
Expand Up @@ -38,7 +38,9 @@ public function enterNode(Node $node): ?Node
$mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE));

foreach ($node->stmts as $stmt) {
if (! $stmt->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope) {
$hasMutatingScope = $stmt->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope;
if (! $hasMutatingScope) {
$stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope);
$this->phpStanNodeScopeResolver->processNodes([$stmt], $this->filePath, $mutatingScope);
}

Expand All @@ -49,7 +51,6 @@ public function enterNode(Node $node): ?Node

if ($isPassedUnreachableStmt) {
$stmt->setAttribute(AttributeKey::IS_UNREACHABLE, true);
$stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope);
}
}

Expand Down

0 comments on commit a4445df

Please sign in to comment.