Updated Rector to commit 7b5102670f0a290038229f8e3bb690e2336920b9

7b5102670f [NodeTypeResolver] Remove parent lookup on ClassRenamePhpDocNodeVisitor (#4248)
This commit is contained in:
Tomas Votruba 2023-06-17 00:19:52 +00:00
parent 84c306dbf2
commit e3e6d2b7a1
5 changed files with 23 additions and 35 deletions

View File

@ -6,8 +6,8 @@ namespace Rector\NodeTypeResolver\PhpDocNodeVisitor;
use PhpParser\Node as PhpParserNode;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\GroupUse;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Use_;
use PHPStan\Analyser\Scope;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@ -17,9 +17,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\Core\Configuration\CurrentNodeProvider;
use Rector\Core\Configuration\RectorConfigProvider;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\ValueObject\OldToNewType;
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
@ -42,16 +40,6 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
* @var \Rector\Naming\Naming\UseImportsResolver
*/
private $useImportsResolver;
/**
* @readonly
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
/**
* @readonly
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\Core\Configuration\RectorConfigProvider
@ -61,13 +49,11 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
* @var OldToNewType[]
*/
private $oldToNewTypes = [];
public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver, RectorConfigProvider $rectorConfigProvider)
public function __construct(StaticTypeMapper $staticTypeMapper, CurrentNodeProvider $currentNodeProvider, UseImportsResolver $useImportsResolver, RectorConfigProvider $rectorConfigProvider)
{
$this->staticTypeMapper = $staticTypeMapper;
$this->currentNodeProvider = $currentNodeProvider;
$this->useImportsResolver = $useImportsResolver;
$this->betterNodeFinder = $betterNodeFinder;
$this->nodeNameResolver = $nodeNameResolver;
$this->rectorConfigProvider = $rectorConfigProvider;
}
public function beforeTraverse(Node $node) : void
@ -137,14 +123,16 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
return $name;
}
$uses = $this->useImportsResolver->resolveForNode($phpParserNode);
$namespace = $this->betterNodeFinder->findParentType($phpParserNode, Namespace_::class);
if (!$namespace instanceof Namespace_) {
return $this->resolveNamefromUse($uses, $name);
$scope = $phpParserNode->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
if (!$phpParserNode->hasAttribute(AttributeKey::ORIGINAL_NODE)) {
return $this->resolveNamefromUse($uses, $name);
}
return '';
}
$originalNode = $namespace->getAttribute(AttributeKey::ORIGINAL_NODE);
$namespaceName = (string) $this->nodeNameResolver->getName($namespace);
if ($originalNode instanceof Namespace_ && !$this->nodeNameResolver->isName($originalNode, $namespaceName)) {
return $name;
$namespaceName = $scope->getNamespace();
if ($namespaceName === null) {
return $this->resolveNamefromUse($uses, $name);
}
if ($uses === []) {
return $namespaceName . '\\' . $name;

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'a4096b224e7bed199991b87f4bdf88ccfbdb8cd9';
public const PACKAGE_VERSION = '7b5102670f0a290038229f8e3bb690e2336920b9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-16 22:49:20';
public const RELEASE_DATE = '2023-06-17 07:15:58';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd90d5141f1ffe09b7a7b39268406e1d4
class ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInitd90d5141f1ffe09b7a7b39268406e1d4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd90d5141f1ffe09b7a7b39268406e1d4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd90d5141f1ffe09b7a7b39268406e1d4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd34ecc3fb274e960cc0c65cf7508c84a', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$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 ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4
class ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3094,9 +3094,9 @@ class ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd90d5141f1ffe09b7a7b39268406e1d4::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd34ecc3fb274e960cc0c65cf7508c84a::$classMap;
}, null, ClassLoader::class);
}