From bf0b138fbed6fb0960ca696869cc9f5f787d4261 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 1 Jan 2024 14:19:41 +0100 Subject: [PATCH] NodeScopeResolver - future-compatible changes for PHP-Parser 5 --- src/Analyser/NodeScopeResolver.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 4b16b484a6..3da1136580 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -737,7 +737,9 @@ private function processStmtNode( $this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $nodeCallback); foreach ($stmt->props as $prop) { - $this->processStmtNode($prop, $scope, $nodeCallback, $context); + if ($prop->default !== null) { + $this->processExprNode($stmt, $prop->default, $scope, $nodeCallback, ExpressionContext::createDeep()); + } [,,,,,,,,,,$isReadOnly, $docComment, ,,,$varTags, $isAllowedPrivateMutation] = $this->getPhpDocs($scope, $stmt); if (!$scope->isInClass()) { throw new ShouldNotHappenException(); @@ -773,12 +775,6 @@ private function processStmtNode( if ($stmt->type !== null) { $nodeCallback($stmt->type, $scope); } - } elseif ($stmt instanceof Node\Stmt\PropertyProperty) { - $hasYield = false; - $throwPoints = []; - if ($stmt->default !== null) { - $this->processExprNode($stmt, $stmt->default, $scope, $nodeCallback, ExpressionContext::createDeep()); - } } elseif ($stmt instanceof Throw_) { $result = $this->processExprNode($stmt, $stmt->expr, $scope, $nodeCallback, ExpressionContext::createDeep()); $throwPoints = $result->getThrowPoints(); @@ -1520,7 +1516,7 @@ private function processStmtNode( $hasYield = false; $throwPoints = []; foreach ($stmt->uses as $use) { - $this->processStmtNode($use, $scope, $nodeCallback, $context); + $nodeCallback($use, $scope); } } elseif ($stmt instanceof Node\Stmt\Global_) { $hasYield = false; @@ -1604,14 +1600,11 @@ private function processStmtNode( } elseif ($stmt instanceof Node\Stmt\Nop) { $hasYield = false; $throwPoints = $overridingThrowPoints ?? []; - } elseif ($stmt instanceof Node\Stmt\UseUse) { - $hasYield = false; - $throwPoints = []; } elseif ($stmt instanceof Node\Stmt\GroupUse) { $hasYield = false; $throwPoints = []; foreach ($stmt->uses as $use) { - $this->processStmtNode($use, $scope, $nodeCallback, $context); + $nodeCallback($use, $scope); } } else { $hasYield = false;