mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit e3e741edd3ca55fc2c24c040f43c8974bda7e953
e3e741edd3
[AutoImport] Allow auto import same namespace with sub use with docblock short name (#5763)
This commit is contained in:
parent
0e57251e46
commit
bb8b99d70c
|
@ -5,12 +5,9 @@ namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
|
|||
|
||||
use RectorPrefix202403\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
|
||||
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
|
||||
use Rector\Configuration\RenamedClassesDataCollector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
use Rector\ValueObject\Application\File;
|
||||
/**
|
||||
|
@ -47,11 +44,6 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
|
|||
$fullyQualifiedObjectTypeShortName = $fullyQualifiedObjectType->getShortName();
|
||||
$className = $fullyQualifiedObjectType->getClassName();
|
||||
$removedUses = $this->renamedClassesDataCollector->getOldClasses();
|
||||
$originalName = $node->getAttribute(AttributeKey::ORIGINAL_NAME);
|
||||
$originalNameToAttribute = null;
|
||||
if ($originalName instanceof Name && !$originalName instanceof FullyQualified && $originalName->hasAttribute(AttributeKey::PHP_ATTRIBUTE_NAME)) {
|
||||
$originalNameToAttribute = $originalName->getAttribute(AttributeKey::PHP_ATTRIBUTE_NAME);
|
||||
}
|
||||
foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) {
|
||||
if ($fullyQualifiedObjectTypeShortName !== $shortName) {
|
||||
$shortName = $this->cleanShortName($shortName);
|
||||
|
@ -63,10 +55,7 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
|
|||
if ($className === $fullyQualifiedName) {
|
||||
return \false;
|
||||
}
|
||||
if (!\in_array($fullyQualifiedName, $removedUses, \true)) {
|
||||
return $originalNameToAttribute == null || !\in_array($originalNameToAttribute, $removedUses, \true);
|
||||
}
|
||||
return \false;
|
||||
return !\in_array($fullyQualifiedName, $removedUses, \true);
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
|
|
|
@ -177,8 +177,10 @@ final class ShortNameResolver
|
|||
$shortNamesToFullyQualifiedNames = [];
|
||||
foreach ($shortNames as $shortName) {
|
||||
$stmtsMatchedName = $this->useImportNameMatcher->matchNameWithStmts($shortName, $stmts);
|
||||
$fullyQualifiedName = \is_string($stmtsMatchedName) ? $stmtsMatchedName : $shortName;
|
||||
$shortNamesToFullyQualifiedNames[$shortName] = $fullyQualifiedName;
|
||||
if ($stmtsMatchedName == null) {
|
||||
continue;
|
||||
}
|
||||
$shortNamesToFullyQualifiedNames[$shortName] = $stmtsMatchedName;
|
||||
}
|
||||
return $shortNamesToFullyQualifiedNames;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'c45f0e2cef30cb0b3090d51fd14dc6ffaa1fc095';
|
||||
public const PACKAGE_VERSION = 'e3e741edd3ca55fc2c24c040f43c8974bda7e953';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-03-23 13:36:05';
|
||||
public const RELEASE_DATE = '2024-03-23 21:34:02';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -110,11 +110,7 @@ final class ClassRenamingPostRector extends \Rector\PostRector\Rector\AbstractPo
|
|||
{
|
||||
$phpAttributeName = $name->getAttribute(AttributeKey::PHP_ATTRIBUTE_NAME);
|
||||
if (\is_string($phpAttributeName)) {
|
||||
$result = $this->classRenamer->renameNode(new FullyQualified($phpAttributeName, $name->getAttributes()), $oldToNewClasses, $scope);
|
||||
if ($result instanceof FullyQualified) {
|
||||
$result->setAttribute(AttributeKey::ORIGINAL_NAME, $name);
|
||||
}
|
||||
return $result;
|
||||
return $this->classRenamer->renameNode(new FullyQualified($phpAttributeName, $name->getAttributes()), $oldToNewClasses, $scope);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue