Skip to content

Commit

Permalink
NodeScopeResolver - future-compatible changes for PHP-Parser 5
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 1, 2024
1 parent 4020240 commit bf0b138
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bf0b138

Please sign in to comment.