|
45 | 45 | use PhpParser\Node\Stmt\If_; |
46 | 46 | use PhpParser\Node\Stmt\Return_; |
47 | 47 | use PhpParser\Node\Stmt\Static_; |
48 | | -use PhpParser\Node\Stmt\StaticVar; |
49 | 48 | use PhpParser\Node\Stmt\Switch_; |
50 | 49 | use PhpParser\Node\Stmt\Throw_; |
51 | 50 | use PhpParser\Node\Stmt\TryCatch; |
@@ -1549,28 +1548,23 @@ private function processStmtNode( |
1549 | 1548 |
|
1550 | 1549 | $vars = []; |
1551 | 1550 | foreach ($stmt->vars as $var) { |
1552 | | - $scope = $this->processStmtNode($var, $scope, $nodeCallback, $context)->getScope(); |
1553 | 1551 | if (!is_string($var->var->name)) { |
1554 | | - continue; |
| 1552 | + throw new ShouldNotHappenException(); |
1555 | 1553 | } |
1556 | 1554 |
|
| 1555 | + if ($var->default !== null) { |
| 1556 | + $this->processExprNode($var->default, $scope, $nodeCallback, ExpressionContext::createDeep()); |
| 1557 | + } |
| 1558 | + |
| 1559 | + $scope = $scope->enterExpressionAssign($var->var); |
| 1560 | + $this->processExprNode($var->var, $scope, $nodeCallback, ExpressionContext::createDeep()); |
| 1561 | + $scope = $scope->exitExpressionAssign($var->var); |
| 1562 | + |
| 1563 | + $scope = $scope->assignVariable($var->var->name, new MixedType(), new MixedType()); |
1557 | 1564 | $vars[] = $var->var->name; |
1558 | 1565 | } |
1559 | 1566 |
|
1560 | 1567 | $scope = $this->processVarAnnotation($scope, $vars, $stmt); |
1561 | | - } elseif ($stmt instanceof StaticVar) { |
1562 | | - $hasYield = false; |
1563 | | - $throwPoints = []; |
1564 | | - if (!is_string($stmt->var->name)) { |
1565 | | - throw new ShouldNotHappenException(); |
1566 | | - } |
1567 | | - if ($stmt->default !== null) { |
1568 | | - $this->processExprNode($stmt->default, $scope, $nodeCallback, ExpressionContext::createDeep()); |
1569 | | - } |
1570 | | - $scope = $scope->enterExpressionAssign($stmt->var); |
1571 | | - $this->processExprNode($stmt->var, $scope, $nodeCallback, ExpressionContext::createDeep()); |
1572 | | - $scope = $scope->exitExpressionAssign($stmt->var); |
1573 | | - $scope = $scope->assignVariable($stmt->var->name, new MixedType(), new MixedType()); |
1574 | 1568 | } elseif ($stmt instanceof Node\Stmt\Const_) { |
1575 | 1569 | $hasYield = false; |
1576 | 1570 | $throwPoints = []; |
@@ -2462,10 +2456,6 @@ static function (): void { |
2462 | 2456 | } |
2463 | 2457 | } elseif ($expr instanceof Expr\Closure) { |
2464 | 2458 | return $this->processClosureNode($expr, $scope, $nodeCallback, $context, null); |
2465 | | - } elseif ($expr instanceof Expr\ClosureUse) { |
2466 | | - $this->processExprNode($expr->var, $scope, $nodeCallback, $context); |
2467 | | - $hasYield = false; |
2468 | | - $throwPoints = []; |
2469 | 2459 | } elseif ($expr instanceof Expr\ArrowFunction) { |
2470 | 2460 | return $this->processArrowFunctionNode($expr, $scope, $nodeCallback, $context, null); |
2471 | 2461 | } elseif ($expr instanceof ErrorSuppress) { |
@@ -2514,25 +2504,20 @@ static function (): void { |
2514 | 2504 | if ($arrayItem === null) { |
2515 | 2505 | continue; |
2516 | 2506 | } |
2517 | | - $result = $this->processExprNode($arrayItem, $scope, $nodeCallback, $context->enterDeep()); |
2518 | | - $hasYield = $hasYield || $result->hasYield(); |
2519 | | - $throwPoints = array_merge($throwPoints, $result->getThrowPoints()); |
2520 | | - $scope = $result->getScope(); |
| 2507 | + $nodeCallback($arrayItem, $scope); |
| 2508 | + if ($arrayItem->key !== null) { |
| 2509 | + $keyResult = $this->processExprNode($arrayItem->key, $scope, $nodeCallback, $context->enterDeep()); |
| 2510 | + $hasYield = $hasYield || $keyResult->hasYield(); |
| 2511 | + $throwPoints = array_merge($throwPoints, $keyResult->getThrowPoints()); |
| 2512 | + $scope = $keyResult->getScope(); |
| 2513 | + } |
| 2514 | + |
| 2515 | + $valueResult = $this->processExprNode($arrayItem->value, $scope, $nodeCallback, $context->enterDeep()); |
| 2516 | + $hasYield = $hasYield || $valueResult->hasYield(); |
| 2517 | + $throwPoints = array_merge($throwPoints, $valueResult->getThrowPoints()); |
| 2518 | + $scope = $valueResult->getScope(); |
2521 | 2519 | } |
2522 | 2520 | $nodeCallback(new LiteralArrayNode($expr, $itemNodes), $scope); |
2523 | | - } elseif ($expr instanceof ArrayItem) { |
2524 | | - $hasYield = false; |
2525 | | - $throwPoints = []; |
2526 | | - if ($expr->key !== null) { |
2527 | | - $result = $this->processExprNode($expr->key, $scope, $nodeCallback, $context->enterDeep()); |
2528 | | - $hasYield = $result->hasYield(); |
2529 | | - $throwPoints = $result->getThrowPoints(); |
2530 | | - $scope = $result->getScope(); |
2531 | | - } |
2532 | | - $result = $this->processExprNode($expr->value, $scope, $nodeCallback, $context->enterDeep()); |
2533 | | - $hasYield = $hasYield || $result->hasYield(); |
2534 | | - $throwPoints = array_merge($throwPoints, $result->getThrowPoints()); |
2535 | | - $scope = $result->getScope(); |
2536 | 2521 | } elseif ($expr instanceof BooleanAnd || $expr instanceof BinaryOp\LogicalAnd) { |
2537 | 2522 | $leftResult = $this->processExprNode($expr->left, $scope, $nodeCallback, $context->enterDeep()); |
2538 | 2523 | $rightResult = $this->processExprNode($expr->right, $leftResult->getTruthyScope(), $nodeCallback, $context); |
@@ -3409,7 +3394,7 @@ private function processClosureNode( |
3409 | 3394 | $scope = $scope->assignVariable($inAssignRightSideVariableName, $variableType, $variableNativeType); |
3410 | 3395 | } |
3411 | 3396 | } |
3412 | | - $this->processExprNode($use, $useScope, $nodeCallback, $context); |
| 3397 | + $this->processExprNode($use->var, $useScope, $nodeCallback, $context); |
3413 | 3398 | if (!$use->byRef) { |
3414 | 3399 | continue; |
3415 | 3400 | } |
@@ -4116,9 +4101,17 @@ static function (): void { |
4116 | 4101 | $itemScope = $itemScope->enterExpressionAssign($arrayItem->value); |
4117 | 4102 | } |
4118 | 4103 | $itemScope = $this->lookForSetAllowedUndefinedExpressions($itemScope, $arrayItem->value); |
4119 | | - $itemResult = $this->processExprNode($arrayItem, $itemScope, $nodeCallback, $context->enterDeep()); |
4120 | | - $hasYield = $hasYield || $itemResult->hasYield(); |
4121 | | - $throwPoints = array_merge($throwPoints, $itemResult->getThrowPoints()); |
| 4104 | + $nodeCallback($arrayItem, $itemScope); |
| 4105 | + if ($arrayItem->key !== null) { |
| 4106 | + $keyResult = $this->processExprNode($arrayItem->key, $itemScope, $nodeCallback, $context->enterDeep()); |
| 4107 | + $hasYield = $hasYield || $keyResult->hasYield(); |
| 4108 | + $throwPoints = array_merge($throwPoints, $keyResult->getThrowPoints()); |
| 4109 | + $itemScope = $keyResult->getScope(); |
| 4110 | + } |
| 4111 | + |
| 4112 | + $valueResult = $this->processExprNode($arrayItem->value, $itemScope, $nodeCallback, $context->enterDeep()); |
| 4113 | + $hasYield = $hasYield || $valueResult->hasYield(); |
| 4114 | + $throwPoints = array_merge($throwPoints, $valueResult->getThrowPoints()); |
4122 | 4115 |
|
4123 | 4116 | if ($arrayItem->key === null) { |
4124 | 4117 | $dimExpr = new Node\Scalar\LNumber($i); |
|
0 commit comments