-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove NEXT_NODE from RemoveDuplicatedIfReturnRector (#3858)
Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
7a86ac2
commit 3df70bd
Showing
3 changed files
with
47 additions
and
64 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
.../FunctionLike/RemoveDuplicatedIfReturnRector/Fixture/bool_var_if_cond_return_true.php.inc
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
...e/Rector/FunctionLike/RemoveDuplicatedIfReturnRector/Fixture/skip_param_reference.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector\Fixture; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\Class_; | ||
use PhpParser\Node\Stmt\Function_; | ||
use PhpParser\NodeTraverser; | ||
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser; | ||
|
||
final class SkipParamReference | ||
{ | ||
public function __construct( | ||
private readonly SimpleCallableNodeTraverser $simpleCallableNodeTraverser | ||
) { | ||
} | ||
|
||
public function run(Node\Stmt $stmt): void | ||
{ | ||
$isParamUsed = false; | ||
|
||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($stmt, function (Node $node) use ( | ||
&$isParamUsed, | ||
): ?int { | ||
if ($isParamUsed) { | ||
return NodeTraverser::STOP_TRAVERSAL; | ||
} | ||
|
||
// skip nested anonymous class | ||
if ($node instanceof Class_ || $node instanceof Function_) { | ||
$isParamUsed = true; | ||
|
||
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; | ||
} | ||
|
||
return null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters