From f407ac846ae25f337c94bd4d2bb85fd837482555 Mon Sep 17 00:00:00 2001 From: Philip Hofstetter Date: Wed, 10 Nov 2021 12:45:12 +0100 Subject: [PATCH] do not treat __halt_compiler() as an expression being executed this fixes #6875 --- src/Psalm/Internal/Analyzer/StatementsAnalyzer.php | 1 + tests/UnusedCodeTest.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index 2e7dedee3..2c3943bfb 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -348,6 +348,7 @@ class StatementsAnalyzer extends SourceAnalyzer && !($stmt instanceof PhpParser\Node\Stmt\Class_) && !($stmt instanceof PhpParser\Node\Stmt\Interface_) && !($stmt instanceof PhpParser\Node\Stmt\Trait_) + && !($stmt instanceof PhpParser\Node\Stmt\HaltCompiler) ) { if ($codebase->find_unused_variables) { if (IssueBuffer::accepts( diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index e7367ed41..52f12e174 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -1093,6 +1093,13 @@ class UnusedCodeTest extends TestCase $a = new A(); echo $a->getVal(null);', ], + '__halt_compiler_no_usage_check' => [ + '