Skip to content

Commit 0803f82

Browse files
committed
Fix NullsafePropertyFetch and NullsafeMethodCall with FiberScope
1 parent dae5a6c commit 0803f82

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,9 +3189,22 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
31893189
$impurePoints = array_merge($impurePoints, $result->getImpurePoints());
31903190
$isAlwaysTerminating = $isAlwaysTerminating || $result->isAlwaysTerminating();
31913191
} elseif ($expr instanceof Expr\NullsafeMethodCall) {
3192+
$this->processExprNode($stmt, new MethodCall(
3193+
$expr->var,
3194+
$expr->name,
3195+
$expr->args,
3196+
), $scope, $storage, new NoopNodeCallback(), $context);
3197+
31923198
$beforeScope = $scope;
31933199
$nonNullabilityResult = $this->ensureShallowNonNullability($scope, $scope, $expr->var);
3194-
$exprResult = $this->processExprNode($stmt, new MethodCall($expr->var, $expr->name, $expr->args, array_merge($expr->getAttributes(), ['virtualNullsafeMethodCall' => true])), $nonNullabilityResult->getScope(), $storage, $nodeCallback, $context);
3200+
$exprResult = $this->processExprNode(
3201+
$stmt,
3202+
new MethodCall(
3203+
$this->deepNodeCloner->cloneNode($expr->var),
3204+
$this->deepNodeCloner->cloneNode($expr->name),
3205+
array_map(fn ($node) => $this->deepNodeCloner->cloneNode($node), $expr->args),
3206+
array_merge($expr->getAttributes(), ['virtualNullsafeMethodCall' => true]),
3207+
), $nonNullabilityResult->getScope(), $storage, $nodeCallback, $context);
31953208
$scope = $this->revertNonNullability($exprResult->getScope(), $nonNullabilityResult->getSpecifiedExpressions());
31963209

31973210
$result = new ExpressionResult(
@@ -3405,9 +3418,18 @@ function (MutatingScope $scope) use ($stmt, $expr, $nodeCallback, $context, $sto
34053418
}
34063419
}
34073420
} elseif ($expr instanceof Expr\NullsafePropertyFetch) {
3421+
$this->processExprNode($stmt, new PropertyFetch(
3422+
$expr->var,
3423+
$expr->name,
3424+
), $scope, $storage, new NoopNodeCallback(), $context);
3425+
34083426
$beforeScope = $scope;
34093427
$nonNullabilityResult = $this->ensureShallowNonNullability($scope, $scope, $expr->var);
3410-
$exprResult = $this->processExprNode($stmt, new PropertyFetch($expr->var, $expr->name, array_merge($expr->getAttributes(), ['virtualNullsafePropertyFetch' => true])), $nonNullabilityResult->getScope(), $storage, $nodeCallback, $context);
3428+
$exprResult = $this->processExprNode($stmt, new PropertyFetch(
3429+
$this->deepNodeCloner->cloneNode($expr->var),
3430+
$this->deepNodeCloner->cloneNode($expr->name),
3431+
array_merge($expr->getAttributes(), ['virtualNullsafePropertyFetch' => true])
3432+
), $nonNullabilityResult->getScope(), $storage, $nodeCallback, $context);
34113433
$scope = $this->revertNonNullability($exprResult->getScope(), $nonNullabilityResult->getSpecifiedExpressions());
34123434

34133435
$result = new ExpressionResult(

0 commit comments

Comments
 (0)