-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollback reindex node attributes before refactor (#6603)
* Rollback reindex node attributes before refactor * Rollback reindex node attributes before refactor * Rollback reindex node attributes before refactor * Rollback reindex node attributes before refactor * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
bdb4025
commit 4cafa91
Showing
3 changed files
with
65 additions
and
52 deletions.
There are no files selected for viewing
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,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Application; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Expr\CallLike; | ||
use PhpParser\Node\Expr\Closure; | ||
use PhpParser\Node\Expr\FuncCall; | ||
use PhpParser\Node\Expr\MethodCall; | ||
use PhpParser\Node\Expr\New_; | ||
use PhpParser\Node\Expr\NullsafeMethodCall; | ||
use PhpParser\Node\Expr\StaticCall; | ||
use PhpParser\Node\FunctionLike; | ||
use PhpParser\Node\MatchArm; | ||
use PhpParser\Node\Stmt\ClassMethod; | ||
use PhpParser\Node\Stmt\Function_; | ||
use PhpParser\Node\Stmt\If_; | ||
use PhpParser\Node\Stmt\Switch_; | ||
use PhpParser\Node\Stmt\TryCatch; | ||
|
||
final class NodeAttributeReIndexer | ||
{ | ||
public static function reIndexNodeAttributes(Node $node): ?Node | ||
{ | ||
if ($node instanceof FunctionLike) { | ||
/** @var ClassMethod|Function_|Closure $node */ | ||
$node->params = array_values($node->params); | ||
|
||
if ($node instanceof Closure) { | ||
$node->uses = array_values($node->uses); | ||
} | ||
} | ||
|
||
if ($node instanceof CallLike) { | ||
/** @var FuncCall|MethodCall|New_|NullsafeMethodCall|StaticCall $node */ | ||
$node->args = array_values($node->args); | ||
} | ||
|
||
if ($node instanceof If_) { | ||
$node->elseifs = array_values($node->elseifs); | ||
} | ||
|
||
if ($node instanceof TryCatch) { | ||
$node->catches = array_values($node->catches); | ||
} | ||
|
||
if ($node instanceof Switch_) { | ||
$node->cases = array_values($node->cases); | ||
} | ||
|
||
if ($node instanceof MatchArm && is_array($node->conds)) { | ||
$node->conds = array_values($node->conds); | ||
return $node; | ||
} | ||
|
||
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
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