Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update NodeScopeResolver.php
  • Loading branch information
staabm committed Jul 21, 2025
commit cc65f3bd09ad13febfdc58c84ea627f6779b342e
14 changes: 12 additions & 2 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2934,7 +2934,7 @@ static function (): void {
return new ExpressionResult(
$scope,
$exprResult->hasYield(),
false,
$exprResult->isAlwaysTerminating(),
$exprResult->getThrowPoints(),
$exprResult->getImpurePoints(),
static fn (): MutatingScope => $scope->filterByTruthyValue($expr),
Expand Down Expand Up @@ -3115,6 +3115,7 @@ static function (): void {
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $result->isAlwaysTerminating();
$scope = $result->getScope();
if ($this->phpVersion->supportsPropertyHooks()) {
$throwPoints[] = ThrowPoint::createImplicit($scope, $expr);
Expand All @@ -3139,7 +3140,7 @@ static function (): void {
return new ExpressionResult(
$scope,
$exprResult->hasYield(),
false,
$exprResult->isAlwaysTerminating(),
$exprResult->getThrowPoints(),
$exprResult->getImpurePoints(),
static fn (): MutatingScope => $scope->filterByTruthyValue($expr),
Expand All @@ -3163,13 +3164,15 @@ static function (): void {
$hasYield = $result->hasYield();
$throwPoints = $result->getThrowPoints();
$impurePoints = $result->getImpurePoints();
$isAlwaysTerminating = $result->isAlwaysTerminating();
$scope = $result->getScope();
}
if ($expr->name instanceof Expr) {
$result = $this->processExprNode($stmt, $expr->name, $scope, $nodeCallback, $context->enterDeep());
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
$scope = $result->getScope();
}
} elseif ($expr instanceof Expr\Closure) {
Expand Down Expand Up @@ -3240,13 +3243,15 @@ static function (): void {
$hasYield = $result->hasYield();
$throwPoints = $result->getThrowPoints();
$impurePoints = $result->getImpurePoints();
$isAlwaysTerminating = $result->isAlwaysTerminating();
$scope = $result->getScope();
}

$result = $this->processExprNode($stmt, $expr->var, $scope, $nodeCallback, $context->enterDeep());
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
$scope = $result->getScope();
} elseif ($expr instanceof Array_) {
$itemNodes = [];
Expand Down Expand Up @@ -3457,6 +3462,7 @@ static function (): void {
$hasYield = $result->hasYield();
$throwPoints = $result->getThrowPoints();
$impurePoints = $result->getImpurePoints();
$isAlwaysTerminating = $result->isAlwaysTerminating();
} else {
$hasYield = false;
$throwPoints = [];
Expand All @@ -3470,6 +3476,7 @@ static function (): void {
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
} else {
$nodeCallback($expr->name, $scope);
}
Expand Down Expand Up @@ -3520,6 +3527,7 @@ static function (): void {
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
}
} elseif ($expr instanceof List_) {
// only in assign and foreach, processed elsewhere
Expand Down Expand Up @@ -3549,6 +3557,7 @@ static function (): void {
$hasYield = $result->hasYield();
$throwPoints = $result->getThrowPoints();
$impurePoints = $result->getImpurePoints();
$isAlwaysTerminating = $result->isAlwaysTerminating();
foreach ($additionalThrowPoints as $throwPoint) {
$throwPoints[] = $throwPoint;
}
Expand Down Expand Up @@ -3644,6 +3653,7 @@ static function (): void {
$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
} elseif (
$expr instanceof Expr\PreInc
|| $expr instanceof Expr\PostInc
Expand Down