diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 94cc3460e3..5ac3e98ee7 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -2800,7 +2800,7 @@ static function (): void { $result = $this->processExprNode($stmt, $expr->expr, $scope, $nodeCallback, $context->enterDeep()); $hasYield = $result->hasYield(); $throwPoints = $result->getThrowPoints(); - $impurePoints = $result->getImpurePoints(); + $impurePoints = array_merge($impurePoints, $result->getImpurePoints()); $scope = $result->getScope(); } } elseif ($expr instanceof Node\Scalar\Encapsed) { diff --git a/tests/PHPStan/Rules/DeadCode/data/noop-impure-points.php b/tests/PHPStan/Rules/DeadCode/data/noop-impure-points.php index c44c018d36..9cac3b795b 100644 --- a/tests/PHPStan/Rules/DeadCode/data/noop-impure-points.php +++ b/tests/PHPStan/Rules/DeadCode/data/noop-impure-points.php @@ -33,4 +33,9 @@ public function doLorem(): bool return true; } + public function doExit(): void + { + exit(1); + } + }