1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

do not treat __halt_compiler() as an expression being executed

this fixes #6875
This commit is contained in:
Philip Hofstetter 2021-11-10 12:45:12 +01:00
parent a193ec4573
commit f407ac846a
No known key found for this signature in database
GPG Key ID: 68CE37E7CB4964AF
2 changed files with 8 additions and 0 deletions

View File

@ -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(

View File

@ -1093,6 +1093,13 @@ class UnusedCodeTest extends TestCase
$a = new A();
echo $a->getVal(null);',
],
'__halt_compiler_no_usage_check' => [
'<?php
exit(0);
__halt_compiler();
foobar
',
],
];
}