From 621e16829817e412f948420f24640971ee84e667 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 9 Dec 2024 10:10:24 +0100 Subject: [PATCH] Optimization - do not enter anonymous classes during loop analysis --- src/Analyser/NodeScopeResolver.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 5c4d86526e..5f518077a2 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -846,6 +846,9 @@ private function processStmtNode( } elseif ($stmt instanceof Node\Stmt\Trait_) { return new StatementResult($scope, false, false, [], [], []); } elseif ($stmt instanceof Node\Stmt\ClassLike) { + if (!$context->isTopLevel()) { + return new StatementResult($scope, false, false, [], [], []); + } $hasYield = false; $throwPoints = []; $impurePoints = [];