mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit 037cf6576b7c8d17a82c00fa14e1975e3e485bf4
037cf6576b
Add early return on NodeAttributeReIndexer (#6604)
This commit is contained in:
parent
2ed8be5c45
commit
0ec46855b0
@ -13,34 +13,46 @@ use PhpParser\Node\Expr\NullsafeMethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\MatchArm;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Declare_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\If_;
|
||||
use PhpParser\Node\Stmt\Switch_;
|
||||
use PhpParser\Node\Stmt\TryCatch;
|
||||
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
|
||||
final class NodeAttributeReIndexer
|
||||
{
|
||||
public static function reIndexNodeAttributes(Node $node) : ?Node
|
||||
{
|
||||
if (($node instanceof StmtsAwareInterface || $node instanceof ClassLike || $node instanceof Declare_) && $node->stmts !== null) {
|
||||
$node->stmts = \array_values($node->stmts);
|
||||
if ($node instanceof If_) {
|
||||
$node->elseifs = \array_values($node->elseifs);
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof TryCatch) {
|
||||
$node->catches = \array_values($node->catches);
|
||||
return $node;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof CallLike) {
|
||||
/** @var FuncCall|MethodCall|New_|NullsafeMethodCall|StaticCall $node */
|
||||
$node->args = \array_values($node->args);
|
||||
return $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);
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof Switch_) {
|
||||
$node->cases = \array_values($node->cases);
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof MatchArm && \is_array($node->conds)) {
|
||||
$node->conds = \array_values($node->conds);
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '4cafa91255c4137074b7ea9aa05754f934e99ab9';
|
||||
public const PACKAGE_VERSION = '037cf6576b7c8d17a82c00fa14e1975e3e485bf4';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-18 13:14:03';
|
||||
public const RELEASE_DATE = '2024-12-18 13:38:49';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -20,7 +20,6 @@ final class StmtKeyNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
if ($node->stmts === null) {
|
||||
return null;
|
||||
}
|
||||
$node->stmts = \array_values($node->stmts);
|
||||
// re-index stmt key under current node
|
||||
foreach ($node->stmts as $key => $childStmt) {
|
||||
$childStmt->setAttribute(AttributeKey::STMT_KEY, $key);
|
||||
|
Loading…
x
Reference in New Issue
Block a user