diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index e2397577d..2e7dedee3 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -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( diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index 1f46d3f92..51daf56f0 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -1056,6 +1056,18 @@ class UnusedCodeTest extends TestCase `$used`; ', ], + 'notUnevaluatedFunction' => [ + '