mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-05 16:12:31 +02:00
Updated Rector to commit c8da7a564d3d5719b475e93e8c7d30b5db73aa75
c8da7a564d
[Renaming] Remove check exists in Use_ on ClassRenamer (#4445)
This commit is contained in:
parent
0e1f48fb00
commit
c7f7cb60df
@ -11,7 +11,6 @@ use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
@ -22,7 +21,6 @@ use Rector\BetterPhpDocParser\ValueObject\NodeTypes;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\FileHasher;
|
||||
use Rector\Naming\Naming\UseImportsResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockClassRenamer;
|
||||
@ -72,11 +70,6 @@ final class ClassRenamer
|
||||
* @var \PHPStan\Reflection\ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Naming\Naming\UseImportsResolver
|
||||
*/
|
||||
private $useImportsResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Renaming\Helper\RenameClassCallbackHandler
|
||||
@ -95,7 +88,7 @@ final class ClassRenamer
|
||||
* @var array<string, OldToNewType[]>
|
||||
*/
|
||||
private $oldToNewTypesByCacheKey = [];
|
||||
public function __construct(BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassNaming $classNaming, NodeNameResolver $nodeNameResolver, PhpDocClassRenamer $phpDocClassRenamer, PhpDocInfoFactory $phpDocInfoFactory, DocBlockClassRenamer $docBlockClassRenamer, ReflectionProvider $reflectionProvider, UseImportsResolver $useImportsResolver, RenameClassCallbackHandler $renameClassCallbackHandler, FileHasher $fileHasher)
|
||||
public function __construct(BetterNodeFinder $betterNodeFinder, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, ClassNaming $classNaming, NodeNameResolver $nodeNameResolver, PhpDocClassRenamer $phpDocClassRenamer, PhpDocInfoFactory $phpDocInfoFactory, DocBlockClassRenamer $docBlockClassRenamer, ReflectionProvider $reflectionProvider, RenameClassCallbackHandler $renameClassCallbackHandler, FileHasher $fileHasher)
|
||||
{
|
||||
$this->betterNodeFinder = $betterNodeFinder;
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
@ -105,7 +98,6 @@ final class ClassRenamer
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->docBlockClassRenamer = $docBlockClassRenamer;
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
$this->useImportsResolver = $useImportsResolver;
|
||||
$this->renameClassCallbackHandler = $renameClassCallbackHandler;
|
||||
$this->fileHasher = $fileHasher;
|
||||
}
|
||||
@ -268,10 +260,6 @@ final class ClassRenamer
|
||||
if ($parentNode instanceof Class_) {
|
||||
return $this->isValidClassNameChange($name, $parentNode, $classReflection);
|
||||
}
|
||||
// prevent to change to import, that already exists
|
||||
if ($parentNode instanceof UseUse) {
|
||||
return $this->isValidUseImportChange($newClassName, $parentNode);
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
@ -339,23 +327,6 @@ final class ClassRenamer
|
||||
// is interface to class?
|
||||
return !(\in_array($name, $class->implements, \true) && $classReflection->isClass());
|
||||
}
|
||||
private function isValidUseImportChange(string $newName, UseUse $useUse) : bool
|
||||
{
|
||||
$uses = $this->useImportsResolver->resolve();
|
||||
if ($uses === []) {
|
||||
return \true;
|
||||
}
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $this->useImportsResolver->resolvePrefix($use);
|
||||
foreach ($use->uses as $useUse) {
|
||||
if ($prefix . $useUse->name->toString() === $newName) {
|
||||
// name already exists
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
* @return OldToNewType[]
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '3b6084dec770faeb7fca657b6f1ab6898a0801d5';
|
||||
public const PACKAGE_VERSION = 'c8da7a564d3d5719b475e93e8c7d30b5db73aa75';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-09 08:41:16';
|
||||
public const RELEASE_DATE = '2023-07-09 09:04:58';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit15c88e4ebae2c19fc397915fb68d3e7c::getLoader();
|
||||
return ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit15c88e4ebae2c19fc397915fb68d3e7c
|
||||
class ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit15c88e4ebae2c19fc397915fb68d3e7c
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit15c88e4ebae2c19fc397915fb68d3e7c', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit15c88e4ebae2c19fc397915fb68d3e7c', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c
|
||||
class ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3077,9 +3077,9 @@ class ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit15c88e4ebae2c19fc397915fb68d3e7c::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user