From c16e4917828472563471e4a601f58ab12b2cd024 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 3 Apr 2024 14:39:40 +0200 Subject: [PATCH] Fix `exit()` impure points --- src/Analyser/NodeScopeResolver.php | 2 +- tests/PHPStan/Rules/DeadCode/data/noop-impure-points.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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); + } + }