|
6 | 6 | use Closure;
|
7 | 7 | use DivisionByZeroError;
|
8 | 8 | use PhpParser\Comment\Doc;
|
| 9 | +use PhpParser\Modifiers; |
9 | 10 | use PhpParser\Node;
|
10 | 11 | use PhpParser\Node\Arg;
|
11 | 12 | use PhpParser\Node\AttributeGroup;
|
12 | 13 | use PhpParser\Node\Expr;
|
13 | 14 | use PhpParser\Node\Expr\Array_;
|
14 | 15 | use PhpParser\Node\Expr\ArrayDimFetch;
|
15 |
| -use PhpParser\Node\Expr\ArrayItem; |
16 | 16 | use PhpParser\Node\Expr\Assign;
|
17 | 17 | use PhpParser\Node\Expr\AssignRef;
|
18 | 18 | use PhpParser\Node\Expr\BinaryOp;
|
|
46 | 46 | use PhpParser\Node\Stmt\Return_;
|
47 | 47 | use PhpParser\Node\Stmt\Static_;
|
48 | 48 | use PhpParser\Node\Stmt\Switch_;
|
49 |
| -use PhpParser\Node\Stmt\Throw_; |
50 | 49 | use PhpParser\Node\Stmt\TryCatch;
|
51 | 50 | use PhpParser\Node\Stmt\Unset_;
|
52 | 51 | use PhpParser\Node\Stmt\While_;
|
@@ -406,7 +405,10 @@ private function processStmtNode(
|
406 | 405 | }
|
407 | 406 |
|
408 | 407 | $stmtScope = $scope;
|
409 |
| - if ($stmt instanceof Throw_ || $stmt instanceof Return_) { |
| 408 | + if ($stmt instanceof Node\Stmt\Expression && $stmt->expr instanceof Expr\Throw_) { |
| 409 | + $stmtScope = $this->processStmtVarAnnotation($scope, $stmt, $stmt->expr->expr, $nodeCallback); |
| 410 | + } |
| 411 | + if ($stmt instanceof Return_) { |
410 | 412 | $stmtScope = $this->processStmtVarAnnotation($scope, $stmt, $stmt->expr, $nodeCallback);
|
411 | 413 | }
|
412 | 414 |
|
@@ -775,13 +777,6 @@ private function processStmtNode(
|
775 | 777 | if ($stmt->type !== null) {
|
776 | 778 | $nodeCallback($stmt->type, $scope);
|
777 | 779 | }
|
778 |
| - } elseif ($stmt instanceof Throw_) { |
779 |
| - $result = $this->processExprNode($stmt, $stmt->expr, $scope, $nodeCallback, ExpressionContext::createDeep()); |
780 |
| - $throwPoints = $result->getThrowPoints(); |
781 |
| - $throwPoints[] = ThrowPoint::createExplicit($result->getScope(), $scope->getType($stmt->expr), $stmt, false); |
782 |
| - return new StatementResult($result->getScope(), $result->hasYield(), true, [ |
783 |
| - new StatementExitPoint($stmt, $scope), |
784 |
| - ], $throwPoints); |
785 | 780 | } elseif ($stmt instanceof If_) {
|
786 | 781 | $conditionType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
|
787 | 782 | $ifAlwaysTrue = $conditionType->isTrue()->yes();
|
@@ -1309,7 +1304,7 @@ private function processStmtNode(
|
1309 | 1304 | }
|
1310 | 1305 | foreach ($branchScopeResult->getExitPoints() as $exitPoint) {
|
1311 | 1306 | $finallyExitPoints[] = $exitPoint;
|
1312 |
| - if ($exitPoint->getStatement() instanceof Throw_) { |
| 1307 | + if ($exitPoint->getStatement() instanceof Node\Stmt\Expression && $exitPoint->getStatement()->expr instanceof Expr\Throw_) { |
1313 | 1308 | continue;
|
1314 | 1309 | }
|
1315 | 1310 | if ($finallyScope !== null) {
|
@@ -1457,7 +1452,7 @@ private function processStmtNode(
|
1457 | 1452 | }
|
1458 | 1453 | foreach ($catchScopeResult->getExitPoints() as $exitPoint) {
|
1459 | 1454 | $finallyExitPoints[] = $exitPoint;
|
1460 |
| - if ($exitPoint->getStatement() instanceof Throw_) { |
| 1455 | + if ($exitPoint->getStatement() instanceof Node\Stmt\Expression && $exitPoint->getStatement()->expr instanceof Expr\Throw_) { |
1461 | 1456 | continue;
|
1462 | 1457 | }
|
1463 | 1458 | if ($finallyScope !== null) {
|
@@ -1727,7 +1722,7 @@ private function lookForExpressionCallback(MutatingScope $scope, Expr $expr, Clo
|
1727 | 1722 | $scope = $this->lookForExpressionCallback($scope, $expr->var, $callback);
|
1728 | 1723 | } elseif ($expr instanceof StaticPropertyFetch && $expr->class instanceof Expr) {
|
1729 | 1724 | $scope = $this->lookForExpressionCallback($scope, $expr->class, $callback);
|
1730 |
| - } elseif ($expr instanceof Array_ || $expr instanceof List_) { |
| 1725 | + } elseif ($expr instanceof List_) { |
1731 | 1726 | foreach ($expr->items as $item) {
|
1732 | 1727 | if ($item === null) {
|
1733 | 1728 | continue;
|
@@ -2466,10 +2461,13 @@ static function (): void {
|
2466 | 2461 | $throwPoints = $result->getThrowPoints();
|
2467 | 2462 | $scope = $result->getScope();
|
2468 | 2463 | }
|
2469 |
| - } elseif ($expr instanceof Node\Scalar\Encapsed) { |
| 2464 | + } elseif ($expr instanceof Node\Scalar\InterpolatedString) { |
2470 | 2465 | $hasYield = false;
|
2471 | 2466 | $throwPoints = [];
|
2472 | 2467 | foreach ($expr->parts as $part) {
|
| 2468 | + if (!$part instanceof Expr) { |
| 2469 | + continue; |
| 2470 | + } |
2473 | 2471 | $result = $this->processExprNode($stmt, $part, $scope, $nodeCallback, $context->enterDeep());
|
2474 | 2472 | $hasYield = $hasYield || $result->hasYield();
|
2475 | 2473 | $throwPoints = array_merge($throwPoints, $result->getThrowPoints());
|
@@ -2869,7 +2867,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
|
2869 | 2867 | } else {
|
2870 | 2868 | $items = [];
|
2871 | 2869 | foreach ($filteringExprs as $filteringExpr) {
|
2872 |
| - $items[] = new ArrayItem($filteringExpr); |
| 2870 | + $items[] = new Node\ArrayItem($filteringExpr); |
2873 | 2871 | }
|
2874 | 2872 | $filteringExpr = new FuncCall(
|
2875 | 2873 | new Name\FullyQualified('in_array'),
|
@@ -3262,7 +3260,7 @@ private function getAssignedVariables(Expr $expr): array
|
3262 | 3260 | return [];
|
3263 | 3261 | }
|
3264 | 3262 |
|
3265 |
| - if ($expr instanceof Expr\List_ || $expr instanceof Expr\Array_) { |
| 3263 | + if ($expr instanceof Expr\List_) { |
3266 | 3264 | $names = [];
|
3267 | 3265 | foreach ($expr->items as $item) {
|
3268 | 3266 | if ($item === null) {
|
@@ -4090,7 +4088,7 @@ static function (): void {
|
4090 | 4088 | $nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scope);
|
4091 | 4089 | $scope = $scope->assignExpression($var, $assignedExprType, $scope->getNativeType($assignedExpr));
|
4092 | 4090 | }
|
4093 |
| - } elseif ($var instanceof List_ || $var instanceof Array_) { |
| 4091 | + } elseif ($var instanceof List_) { |
4094 | 4092 | $result = $processExprCallback($scope);
|
4095 | 4093 | $hasYield = $result->hasYield();
|
4096 | 4094 | $throwPoints = array_merge($throwPoints, $result->getThrowPoints());
|
@@ -4514,7 +4512,7 @@ private function processNodesForTraitUse($node, ClassReflection $traitReflection
|
4514 | 4512 | $methodAst = clone $stmt;
|
4515 | 4513 | $stmts[$i] = $methodAst;
|
4516 | 4514 | if (array_key_exists($methodName, $methodModifiers)) {
|
4517 |
| - $methodAst->flags = ($methodAst->flags & ~ Node\Stmt\Class_::VISIBILITY_MODIFIER_MASK) | $methodModifiers[$methodName]; |
| 4515 | + $methodAst->flags = ($methodAst->flags & ~ Modifiers::VISIBILITY_MASK) | $methodModifiers[$methodName]; |
4518 | 4516 | }
|
4519 | 4517 |
|
4520 | 4518 | if (!array_key_exists($methodName, $methodNames)) {
|
@@ -4600,9 +4598,6 @@ private function processCalledMethod(MethodReflection $methodReflection): ?Mutat
|
4600 | 4598 | foreach ($returnStatement->getExecutionEnds() as $executionEnd) {
|
4601 | 4599 | $statementResult = $executionEnd->getStatementResult();
|
4602 | 4600 | $endNode = $executionEnd->getNode();
|
4603 |
| - if ($endNode instanceof Node\Stmt\Throw_) { |
4604 |
| - continue; |
4605 |
| - } |
4606 | 4601 | if ($endNode instanceof Node\Stmt\Expression) {
|
4607 | 4602 | $exprType = $statementResult->getScope()->getType($endNode->expr);
|
4608 | 4603 | if ($exprType instanceof NeverType && $exprType->isExplicit()) {
|
|
0 commit comments