mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-16 21:08:19 +01:00
Updated Rector to commit 4cafa91255c4137074b7ea9aa05754f934e99ab9
4cafa91255
Rollback reindex node attributes before refactor (#6603)
This commit is contained in:
parent
6b6579135c
commit
2ed8be5c45
51
src/Application/NodeAttributeReIndexer.php
Normal file
51
src/Application/NodeAttributeReIndexer.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'bdb40258944adef73378fa5fc15cc26bded7431f';
|
||||
public const PACKAGE_VERSION = '4cafa91255c4137074b7ea9aa05754f934e99ab9';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-12-18 03:54:39';
|
||||
public const RELEASE_DATE = '2024-12-18 13:14:03';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -4,54 +4,12 @@ declare (strict_types=1);
|
||||
namespace Rector\PHPStan\NodeVisitor;
|
||||
|
||||
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;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
use Rector\Application\NodeAttributeReIndexer;
|
||||
final class ReIndexNodeAttributeVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
public function enterNode(Node $node) : ?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);
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof If_) {
|
||||
$node->elseifs = \array_values($node->elseifs);
|
||||
return $node;
|
||||
}
|
||||
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);
|
||||
return $node;
|
||||
}
|
||||
return null;
|
||||
return NodeAttributeReIndexer::reIndexNodeAttributes($node);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ use PHPStan\Analyser\MutatingScope;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Application\ChangedNodeScopeRefresher;
|
||||
use Rector\Application\NodeAttributeReIndexer;
|
||||
use Rector\Application\Provider\CurrentFileProvider;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
|
||||
@ -107,6 +108,7 @@ CODE_SAMPLE;
|
||||
}
|
||||
// ensure origNode pulled before refactor to avoid changed during refactor, ref https://3v4l.org/YMEGN
|
||||
$originalNode = $node->getAttribute(AttributeKey::ORIGINAL_NODE) ?? $node;
|
||||
NodeAttributeReIndexer::reIndexNodeAttributes($node);
|
||||
$refactoredNode = $this->refactor($node);
|
||||
// @see NodeTraverser::* codes, e.g. removal of node of stopping the traversing
|
||||
if ($refactoredNode === NodeVisitor::REMOVE_NODE) {
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -996,6 +996,7 @@ return array(
|
||||
'Rector\\Application\\ApplicationFileProcessor' => $baseDir . '/src/Application/ApplicationFileProcessor.php',
|
||||
'Rector\\Application\\ChangedNodeScopeRefresher' => $baseDir . '/src/Application/ChangedNodeScopeRefresher.php',
|
||||
'Rector\\Application\\FileProcessor' => $baseDir . '/src/Application/FileProcessor.php',
|
||||
'Rector\\Application\\NodeAttributeReIndexer' => $baseDir . '/src/Application/NodeAttributeReIndexer.php',
|
||||
'Rector\\Application\\Provider\\CurrentFileProvider' => $baseDir . '/src/Application/Provider/CurrentFileProvider.php',
|
||||
'Rector\\Application\\VersionResolver' => $baseDir . '/src/Application/VersionResolver.php',
|
||||
'Rector\\Arguments\\ArgumentDefaultValueReplacer' => $baseDir . '/rules/Arguments/ArgumentDefaultValueReplacer.php',
|
||||
|
1
vendor/composer/autoload_static.php
vendored
1
vendor/composer/autoload_static.php
vendored
@ -1215,6 +1215,7 @@ class ComposerStaticInite1459f150f08d0eee2804dfc37f818db
|
||||
'Rector\\Application\\ApplicationFileProcessor' => __DIR__ . '/../..' . '/src/Application/ApplicationFileProcessor.php',
|
||||
'Rector\\Application\\ChangedNodeScopeRefresher' => __DIR__ . '/../..' . '/src/Application/ChangedNodeScopeRefresher.php',
|
||||
'Rector\\Application\\FileProcessor' => __DIR__ . '/../..' . '/src/Application/FileProcessor.php',
|
||||
'Rector\\Application\\NodeAttributeReIndexer' => __DIR__ . '/../..' . '/src/Application/NodeAttributeReIndexer.php',
|
||||
'Rector\\Application\\Provider\\CurrentFileProvider' => __DIR__ . '/../..' . '/src/Application/Provider/CurrentFileProvider.php',
|
||||
'Rector\\Application\\VersionResolver' => __DIR__ . '/../..' . '/src/Application/VersionResolver.php',
|
||||
'Rector\\Arguments\\ArgumentDefaultValueReplacer' => __DIR__ . '/../..' . '/rules/Arguments/ArgumentDefaultValueReplacer.php',
|
||||
|
Loading…
x
Reference in New Issue
Block a user