|
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;
|
|
48 | 48 | use PhpParser\Node\Stmt\Return_;
|
49 | 49 | use PhpParser\Node\Stmt\Static_;
|
50 | 50 | use PhpParser\Node\Stmt\Switch_;
|
51 |
| -use PhpParser\Node\Stmt\Throw_; |
52 | 51 | use PhpParser\Node\Stmt\TryCatch;
|
53 | 52 | use PhpParser\Node\Stmt\Unset_;
|
54 | 53 | use PhpParser\Node\Stmt\While_;
|
@@ -474,7 +473,10 @@ private function processStmtNode(
|
474 | 473 | }
|
475 | 474 |
|
476 | 475 | $stmtScope = $scope;
|
477 |
| - if ($stmt instanceof Throw_ || $stmt instanceof Return_) { |
| 476 | + if ($stmt instanceof Node\Stmt\Expression && $stmt->expr instanceof Expr\Throw_) { |
| 477 | + $stmtScope = $this->processStmtVarAnnotation($scope, $stmt, $stmt->expr->expr, $nodeCallback); |
| 478 | + } |
| 479 | + if ($stmt instanceof Return_) { |
478 | 480 | $stmtScope = $this->processStmtVarAnnotation($scope, $stmt, $stmt->expr, $nodeCallback);
|
479 | 481 | }
|
480 | 482 |
|
@@ -922,14 +924,6 @@ private function processStmtNode(
|
922 | 924 | if ($stmt->type !== null) {
|
923 | 925 | $nodeCallback($stmt->type, $scope);
|
924 | 926 | }
|
925 |
| - } elseif ($stmt instanceof Throw_) { |
926 |
| - $result = $this->processExprNode($stmt, $stmt->expr, $scope, $nodeCallback, ExpressionContext::createDeep()); |
927 |
| - $throwPoints = $result->getThrowPoints(); |
928 |
| - $throwPoints[] = ThrowPoint::createExplicit($result->getScope(), $scope->getType($stmt->expr), $stmt, false); |
929 |
| - $impurePoints = $result->getImpurePoints(); |
930 |
| - return new StatementResult($result->getScope(), $result->hasYield(), true, [ |
931 |
| - new StatementExitPoint($stmt, $scope), |
932 |
| - ], $throwPoints, $impurePoints); |
933 | 927 | } elseif ($stmt instanceof If_) {
|
934 | 928 | $conditionType = ($this->treatPhpDocTypesAsCertain ? $scope->getType($stmt->cond) : $scope->getNativeType($stmt->cond))->toBoolean();
|
935 | 929 | $ifAlwaysTrue = $conditionType->isTrue()->yes();
|
@@ -1506,7 +1500,7 @@ private function processStmtNode(
|
1506 | 1500 | }
|
1507 | 1501 | foreach ($branchScopeResult->getExitPoints() as $exitPoint) {
|
1508 | 1502 | $finallyExitPoints[] = $exitPoint;
|
1509 |
| - if ($exitPoint->getStatement() instanceof Throw_) { |
| 1503 | + if ($exitPoint->getStatement() instanceof Node\Stmt\Expression && $exitPoint->getStatement()->expr instanceof Expr\Throw_) { |
1510 | 1504 | continue;
|
1511 | 1505 | }
|
1512 | 1506 | if ($finallyScope !== null) {
|
@@ -1668,7 +1662,7 @@ private function processStmtNode(
|
1668 | 1662 | }
|
1669 | 1663 | foreach ($catchScopeResult->getExitPoints() as $exitPoint) {
|
1670 | 1664 | $finallyExitPoints[] = $exitPoint;
|
1671 |
| - if ($exitPoint->getStatement() instanceof Throw_) { |
| 1665 | + if ($exitPoint->getStatement() instanceof Node\Stmt\Expression && $exitPoint->getStatement()->expr instanceof Expr\Throw_) { |
1672 | 1666 | continue;
|
1673 | 1667 | }
|
1674 | 1668 | if ($finallyScope !== null) {
|
@@ -2037,7 +2031,7 @@ private function lookForExpressionCallback(MutatingScope $scope, Expr $expr, Clo
|
2037 | 2031 | $scope = $this->lookForExpressionCallback($scope, $expr->var, $callback);
|
2038 | 2032 | } elseif ($expr instanceof StaticPropertyFetch && $expr->class instanceof Expr) {
|
2039 | 2033 | $scope = $this->lookForExpressionCallback($scope, $expr->class, $callback);
|
2040 |
| - } elseif ($expr instanceof Array_ || $expr instanceof List_) { |
| 2034 | + } elseif ($expr instanceof List_) { |
2041 | 2035 | foreach ($expr->items as $item) {
|
2042 | 2036 | if ($item === null) {
|
2043 | 2037 | continue;
|
@@ -2942,11 +2936,14 @@ static function (): void {
|
2942 | 2936 | $impurePoints = array_merge($impurePoints, $result->getImpurePoints());
|
2943 | 2937 | $scope = $result->getScope();
|
2944 | 2938 | }
|
2945 |
| - } elseif ($expr instanceof Node\Scalar\Encapsed) { |
| 2939 | + } elseif ($expr instanceof Node\Scalar\InterpolatedString) { |
2946 | 2940 | $hasYield = false;
|
2947 | 2941 | $throwPoints = [];
|
2948 | 2942 | $impurePoints = [];
|
2949 | 2943 | foreach ($expr->parts as $part) {
|
| 2944 | + if (!$part instanceof Expr) { |
| 2945 | + continue; |
| 2946 | + } |
2950 | 2947 | $result = $this->processExprNode($stmt, $part, $scope, $nodeCallback, $context->enterDeep());
|
2951 | 2948 | $hasYield = $hasYield || $result->hasYield();
|
2952 | 2949 | $throwPoints = array_merge($throwPoints, $result->getThrowPoints());
|
@@ -3630,7 +3627,7 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
|
3630 | 3627 | } else {
|
3631 | 3628 | $items = [];
|
3632 | 3629 | foreach ($filteringExprs as $filteringExpr) {
|
3633 |
| - $items[] = new ArrayItem($filteringExpr); |
| 3630 | + $items[] = new Node\ArrayItem($filteringExpr); |
3634 | 3631 | }
|
3635 | 3632 | $filteringExpr = new FuncCall(
|
3636 | 3633 | new Name\FullyQualified('in_array'),
|
@@ -4113,7 +4110,7 @@ private function getAssignedVariables(Expr $expr): array
|
4113 | 4110 | return [];
|
4114 | 4111 | }
|
4115 | 4112 |
|
4116 |
| - if ($expr instanceof Expr\List_ || $expr instanceof Expr\Array_) { |
| 4113 | + if ($expr instanceof Expr\List_) { |
4117 | 4114 | $names = [];
|
4118 | 4115 | foreach ($expr->items as $item) {
|
4119 | 4116 | if ($item === null) {
|
@@ -5271,7 +5268,7 @@ static function (): void {
|
5271 | 5268 | $nodeCallback(new PropertyAssignNode($var, $assignedExpr, $isAssignOp), $scope);
|
5272 | 5269 | $scope = $scope->assignExpression($var, $assignedExprType, $scope->getNativeType($assignedExpr));
|
5273 | 5270 | }
|
5274 |
| - } elseif ($var instanceof List_ || $var instanceof Array_) { |
| 5271 | + } elseif ($var instanceof List_) { |
5275 | 5272 | $result = $processExprCallback($scope);
|
5276 | 5273 | $hasYield = $result->hasYield();
|
5277 | 5274 | $throwPoints = array_merge($throwPoints, $result->getThrowPoints());
|
@@ -5778,7 +5775,7 @@ private function processNodesForTraitUse($node, ClassReflection $traitReflection
|
5778 | 5775 | $methodAst = clone $stmt;
|
5779 | 5776 | $stmts[$i] = $methodAst;
|
5780 | 5777 | if (array_key_exists($methodName, $methodModifiers)) {
|
5781 |
| - $methodAst->flags = ($methodAst->flags & ~ Node\Stmt\Class_::VISIBILITY_MODIFIER_MASK) | $methodModifiers[$methodName]; |
| 5778 | + $methodAst->flags = ($methodAst->flags & ~ Modifiers::VISIBILITY_MASK) | $methodModifiers[$methodName]; |
5782 | 5779 | }
|
5783 | 5780 |
|
5784 | 5781 | if (!array_key_exists($methodName, $methodNames)) {
|
@@ -5867,9 +5864,6 @@ private function processCalledMethod(MethodReflection $methodReflection): ?Mutat
|
5867 | 5864 | foreach ($returnStatement->getExecutionEnds() as $executionEnd) {
|
5868 | 5865 | $statementResult = $executionEnd->getStatementResult();
|
5869 | 5866 | $endNode = $executionEnd->getNode();
|
5870 |
| - if ($endNode instanceof Node\Stmt\Throw_) { |
5871 |
| - continue; |
5872 |
| - } |
5873 | 5867 | if ($endNode instanceof Node\Stmt\Expression) {
|
5874 | 5868 | $exprType = $statementResult->getScope()->getType($endNode->expr);
|
5875 | 5869 | if ($exprType instanceof NeverType && $exprType->isExplicit()) {
|
|
0 commit comments