Updated Rector to commit ae64ccd4e8ac4d3fbd956e8a60de1d27c598cb8f

ae64ccd4e8 [Traverser] Utilize statementDepth attribute on StmtKeyNodeVisitor to fill stmt_key in root of stmts (#4104)
This commit is contained in:
Tomas Votruba 2023-06-07 08:54:42 +00:00
parent 78750eb011
commit 6f867b1fcb
7 changed files with 39 additions and 19 deletions

View File

@ -180,4 +180,8 @@ final class AttributeKey
* @var string
*/
public const IS_MULTI_ASSIGN = 'is_multi_assign';
/**
* @var string
*/
public const STATEMENT_DEPTH = 'statementDepth';
}

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
use PhpParser\Node;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\Declare_;
use PhpParser\NodeVisitorAbstract;
@ -12,6 +13,28 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface;
final class StmtKeyNodeVisitor extends NodeVisitorAbstract implements ScopeResolverNodeVisitorInterface
{
/**
* @param Node[] $nodes
*/
public function beforeTraverse(array $nodes)
{
$currentNode = \current($nodes);
if (!$currentNode instanceof Stmt) {
return null;
}
$statementDepth = $currentNode->getAttribute(AttributeKey::STATEMENT_DEPTH);
if ($statementDepth > 0 || $statementDepth === null) {
return null;
}
// on target node or no other root stmt, eg: only namespace without declare, no need reindex
if (\count($nodes) === 1) {
return null;
}
foreach ($nodes as $key => $node) {
$node->setAttribute(AttributeKey::STMT_KEY, $key);
}
return $nodes;
}
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof StmtsAwareInterface && !$node instanceof ClassLike && !$node instanceof Declare_) {

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'a43321f493fe7772a427402c8bb15959fc24ca8b';
public const PACKAGE_VERSION = 'ae64ccd4e8ac4d3fbd956e8a60de1d27c598cb8f';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-07 14:58:12';
public const RELEASE_DATE = '2023-06-07 15:49:38';
/**
* @var int
*/

View File

@ -29,7 +29,6 @@ use Rector\Core\Logging\CurrentRectorProvider;
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\PhpParser\Node\NodeFactory;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\Core\PhpParser\NodeTraverser\NodeConnectingTraverser;
@ -188,12 +187,6 @@ CODE_SAMPLE;
throw new ShouldNotHappenException('File object is missing. Make sure you call $this->currentFileProvider->setFile(...) before traversing.');
}
$this->file = $file;
foreach ($nodes as $key => $childStmt) {
if (!$childStmt instanceof FileWithoutNamespace) {
$childStmt->setAttribute(AttributeKey::STMT_KEY, $key);
continue;
}
}
return parent::beforeTraverse($nodes);
}
public final function enterNode(Node $node)

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitda0c9fcd4851c492fdae8bdc5793fafa::getLoader();
return ComposerAutoloaderInit7c4d2c8edb8f8b085b66dc49e6d0a50a::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitda0c9fcd4851c492fdae8bdc5793fafa
class ComposerAutoloaderInit7c4d2c8edb8f8b085b66dc49e6d0a50a
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitda0c9fcd4851c492fdae8bdc5793fafa
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitda0c9fcd4851c492fdae8bdc5793fafa', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit7c4d2c8edb8f8b085b66dc49e6d0a50a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitda0c9fcd4851c492fdae8bdc5793fafa', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit7c4d2c8edb8f8b085b66dc49e6d0a50a', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa
class ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3040,9 +3040,9 @@ class ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitda0c9fcd4851c492fdae8bdc5793fafa::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7c4d2c8edb8f8b085b66dc49e6d0a50a::$classMap;
}, null, ClassLoader::class);
}