mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
Updated Rector to commit 919f5d4ababb95e3cf9167926e81c65939d70bf3
919f5d4aba
[Renaming] Remove parent attribute on ClassRenamer (#4446)
This commit is contained in:
parent
c7f7cb60df
commit
b0309e26cf
@ -248,6 +248,14 @@ final class AttributeKey
|
||||
* @var string
|
||||
*/
|
||||
public const IS_PARAM_VAR = 'IS_PARAM_VAR';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const IS_CLASS_EXTENDS = 'is_class_extends';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const IS_CLASS_IMPLEMENT = 'is_class_implement';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@ use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Isset_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
@ -71,8 +72,20 @@ final class ContextNodeVisitor extends NodeVisitorAbstract implements ScopeResol
|
||||
if ($node instanceof Param) {
|
||||
$node->var->setAttribute(AttributeKey::IS_PARAM_VAR, \true);
|
||||
}
|
||||
$this->processContextInClass($node);
|
||||
return null;
|
||||
}
|
||||
private function processContextInClass(Node $node) : void
|
||||
{
|
||||
if ($node instanceof Class_) {
|
||||
if ($node->extends instanceof FullyQualified) {
|
||||
$node->extends->setAttribute(AttributeKey::IS_CLASS_EXTENDS, \true);
|
||||
}
|
||||
foreach ($node->implements as $implement) {
|
||||
$implement->setAttribute(AttributeKey::IS_CLASS_IMPLEMENT, \true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private function processContextInAttribute(Attribute $attribute) : void
|
||||
{
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($attribute->args, static function (Node $subNode) {
|
||||
|
@ -253,14 +253,13 @@ final class ClassRenamer
|
||||
}
|
||||
$classReflection = $this->reflectionProvider->getClass($newClassName);
|
||||
// ensure new is not with interface
|
||||
if ($name->getAttribute(AttributeKey::IS_NEW_INSTANCE_NAME) === \true && $classReflection->isInterface()) {
|
||||
return \false;
|
||||
if ($name->getAttribute(AttributeKey::IS_NEW_INSTANCE_NAME) !== \true) {
|
||||
return $this->isValidClassNameChange($name, $classReflection);
|
||||
}
|
||||
$parentNode = $name->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if ($parentNode instanceof Class_) {
|
||||
return $this->isValidClassNameChange($name, $parentNode, $classReflection);
|
||||
if (!$classReflection->isInterface()) {
|
||||
return $this->isValidClassNameChange($name, $classReflection);
|
||||
}
|
||||
return \true;
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
@ -313,9 +312,9 @@ final class ClassRenamer
|
||||
$node->setAttribute(AttributeKey::ORIGINAL_NODE, null);
|
||||
});
|
||||
}
|
||||
private function isValidClassNameChange(Name $name, Class_ $class, ClassReflection $classReflection) : bool
|
||||
private function isValidClassNameChange(Name $name, ClassReflection $classReflection) : bool
|
||||
{
|
||||
if ($class->extends === $name) {
|
||||
if ($name->getAttribute(AttributeKey::IS_CLASS_EXTENDS) === \true) {
|
||||
// is class to interface?
|
||||
if ($classReflection->isInterface()) {
|
||||
return \false;
|
||||
@ -324,8 +323,11 @@ final class ClassRenamer
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
// is interface to class?
|
||||
return !(\in_array($name, $class->implements, \true) && $classReflection->isClass());
|
||||
if ($name->getAttribute(AttributeKey::IS_CLASS_IMPLEMENT) === \true) {
|
||||
// is interface to class?
|
||||
return !$classReflection->isClass();
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c8da7a564d3d5719b475e93e8c7d30b5db73aa75';
|
||||
public const PACKAGE_VERSION = '919f5d4ababb95e3cf9167926e81c65939d70bf3';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-07-09 09:04:58';
|
||||
public const RELEASE_DATE = '2023-07-09 02:45:49';
|
||||
/**
|
||||
* @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 ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997::getLoader();
|
||||
return ComposerAutoloaderInit1477a7c32fa2d182de5e68e06213fa7b::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 ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
class ComposerAutoloaderInit1477a7c32fa2d182de5e68e06213fa7b
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1477a7c32fa2d182de5e68e06213fa7b', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9dd325719adaf6ed04d4b9b62f70d997', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1477a7c32fa2d182de5e68e06213fa7b', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b::$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 ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
class ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -3077,9 +3077,9 @@ class ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9dd325719adaf6ed04d4b9b62f70d997::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1477a7c32fa2d182de5e68e06213fa7b::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user