From 0b8fdd78cf549745cf8765347e82b8fa00084ab4 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Tue, 27 Jan 2026 19:57:55 +0100 Subject: [PATCH] Make sure function scope is set in closure in constant expression See https://github.com/phpstan/phpstan/discussions/14014#discussioncomment-15620096 --- src/Analyser/NodeScopeResolver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index bdc1d3b181..2c4d7d597c 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -716,13 +716,14 @@ private function processStmtNode( $hasYield = false; $throwPoints = []; $impurePoints = []; - $this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $storage, $nodeCallback); [$templateTypeMap, $phpDocParameterTypes, $phpDocImmediatelyInvokedCallableParameters, $phpDocClosureThisTypeParameters, $phpDocReturnType, $phpDocThrowType, $deprecatedDescription, $isDeprecated, $isInternal, $isFinal, $isPure, $acceptsNamedArguments, $isReadOnly, $phpDocComment, $asserts, $selfOutType, $phpDocParameterOutTypes] = $this->getPhpDocs($scope, $stmt); foreach ($stmt->params as $param) { $this->processParamNode($stmt, $param, $scope, $storage, $nodeCallback); } + $this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $storage, $nodeCallback); + if ($stmt->returnType !== null) { $this->callNodeCallback($nodeCallback, $stmt->returnType, $scope, $storage); }