1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

allow declaring functions and classLikes after a never-returning call

This commit is contained in:
orklah 2021-11-05 18:09:40 +01:00
parent 670c740255
commit 33aab6cc40
2 changed files with 16 additions and 0 deletions

View File

@ -344,6 +344,10 @@ class StatementsAnalyzer extends SourceAnalyzer
&& !$context->collect_mutations
&& !($stmt instanceof PhpParser\Node\Stmt\Nop)
&& !($stmt instanceof PhpParser\Node\Stmt\InlineHTML)
&& !($stmt instanceof PhpParser\Node\Stmt\Function_)
&& !($stmt instanceof PhpParser\Node\Stmt\Class_)
&& !($stmt instanceof PhpParser\Node\Stmt\Interface_)
&& !($stmt instanceof PhpParser\Node\Stmt\Trait_)
) {
if ($codebase->find_unused_variables) {
if (IssueBuffer::accepts(

View File

@ -1056,6 +1056,18 @@ class UnusedCodeTest extends TestCase
`$used`;
',
],
'notUnevaluatedFunction' => [
'<?php
function neverReturns(): never{
die();
}
unrelated();
neverReturns();
function unrelated(){
echo "hello";
}',
],
];
}