|
11 | 11 | use PhpParser\Node\Expr\Cast\Int_; |
12 | 12 | use PhpParser\Node\Expr\Cast\String_; |
13 | 13 | use PhpParser\Node\Expr\Match_; |
14 | | -use PhpParser\Node\FunctionLike; |
15 | 14 | use PhpParser\Node\Stmt\Expression; |
16 | 15 | use PhpParser\Node\Stmt\Return_; |
17 | 16 | use PhpParser\Node\Stmt\Switch_; |
18 | | -use PhpParser\NodeVisitor; |
19 | 17 | use PHPStan\Type\ObjectType; |
20 | 18 | use Rector\NodeAnalyzer\ExprAnalyzer; |
| 19 | +use Rector\NodeTypeResolver\Node\AttributeKey; |
21 | 20 | use Rector\Php80\NodeAnalyzer\MatchSwitchAnalyzer; |
22 | 21 | use Rector\Php80\NodeFactory\MatchFactory; |
23 | 22 | use Rector\Php80\NodeResolver\SwitchExprsResolver; |
@@ -83,25 +82,25 @@ public function getNodeTypes(): array |
83 | 82 |
|
84 | 83 | /** |
85 | 84 | * @param StmtsAware $node |
86 | | - * @return null|Node|NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN |
87 | 85 | */ |
88 | | - public function refactor(Node $node): null|Node|int |
| 86 | + public function refactor(Node $node): null|Node |
89 | 87 | { |
90 | 88 | if (! is_array($node->stmts)) { |
91 | 89 | return null; |
92 | 90 | } |
93 | 91 |
|
94 | | - if ($node instanceof FunctionLike && $node->returnsByRef()) { |
95 | | - return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
96 | | - } |
97 | | - |
98 | 92 | $hasChanged = false; |
99 | 93 |
|
100 | 94 | foreach ($node->stmts as $key => $stmt) { |
101 | 95 | if (! $stmt instanceof Switch_) { |
102 | 96 | continue; |
103 | 97 | } |
104 | 98 |
|
| 99 | + // possible reference override, where match |
| 100 | + if ($stmt->getAttribute(AttributeKey::IS_INSIDE_BYREF_FUNCTION_LIKE)) { |
| 101 | + continue; |
| 102 | + } |
| 103 | + |
105 | 104 | $nextStmt = $node->stmts[$key + 1] ?? null; |
106 | 105 |
|
107 | 106 | $condAndExprs = $this->switchExprsResolver->resolve($stmt); |
|
0 commit comments