Skip to content

Commit 48c89e2

Browse files
committed
fix throw as expr on ArrowFunctionToAnonymousFunctionRector
1 parent 6a88e43 commit 48c89e2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

rules/DowngradePhp74/Rector/ArrowFunction/ArrowFunctionToAnonymousFunctionRector.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PhpParser\Node\Expr\Assign;
1212
use PhpParser\Node\Expr\Closure;
1313
use PhpParser\Node\Expr\Variable;
14+
use PhpParser\Node\Stmt\Expression;
1415
use PhpParser\Node\Stmt\Return_;
1516
use PhpParser\Node\Stmt\Throw_;
1617
use PHPStan\Analyser\Scope;
@@ -102,7 +103,7 @@ public function refactor(Node $node): Closure
102103
}
103104

104105
// downgrade "return throw"
105-
$this->traverseNodesWithCallable($anonymousFunctionFactory, static function (Node $node): ?Throw_ {
106+
$this->traverseNodesWithCallable($anonymousFunctionFactory, static function (Node $node): ?Expression {
106107
if (! $node instanceof Return_) {
107108
return null;
108109
}
@@ -111,10 +112,8 @@ public function refactor(Node $node): Closure
111112
return null;
112113
}
113114

114-
$throw = $node->expr;
115-
116115
// throw expr to throw stmts
117-
return new Throw_($throw->expr);
116+
return new Expression($node->expr);
118117
});
119118

120119
$this->appendUsesFromInsertedVariable($node->expr, $anonymousFunctionFactory);

0 commit comments

Comments
 (0)