mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 2fac959116e4f50471422e5e5c9eaca3163e6667
2fac959116
[AutoImport] Allow auto import just renamed @var only docblock on RenameClassRector without removeUnusedImports() enabled (#5220)
This commit is contained in:
parent
6999c349a8
commit
394c30d8ba
|
@ -14,8 +14,6 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Naming\Naming\UseImportsResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
|
@ -80,12 +78,6 @@ final class ClassRenamePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
|||
$identifier = clone $node;
|
||||
$identifier->name = $this->resolveNamespacedName($identifier, $currentPhpNode, $node->name);
|
||||
$staticType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($identifier, $currentPhpNode);
|
||||
$shouldImport = SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_NAMES);
|
||||
$isNoNamespacedName = \strncmp($identifier->name, '\\', \strlen('\\')) !== 0 && \substr_count($identifier->name, '\\') === 0;
|
||||
// tweak overlapped import + rename
|
||||
if ($shouldImport && $isNoNamespacedName) {
|
||||
return null;
|
||||
}
|
||||
// make sure to compare FQNs
|
||||
$objectType = $this->expandShortenedObjectType($staticType);
|
||||
foreach ($this->oldToNewTypes as $oldToNewType) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
|
||||
|
||||
use RectorPrefix202311\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
|
||||
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
|
||||
|
@ -41,14 +42,23 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements ClassNameImpor
|
|||
/** @var array<string, string> $shortNamesToFullyQualifiedNames */
|
||||
$shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveFromFile($file);
|
||||
$removedUses = $this->renamedClassesDataCollector->getOldClasses();
|
||||
$fullyQualifiedObjectTypeShortName = $fullyQualifiedObjectType->getShortName();
|
||||
$className = $fullyQualifiedObjectType->getClassName();
|
||||
foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) {
|
||||
if ($fullyQualifiedObjectType->getShortName() !== $shortName) {
|
||||
if ($fullyQualifiedObjectTypeShortName !== $shortName) {
|
||||
$shortName = \strncmp($shortName, '\\', \strlen('\\')) === 0 ? \ltrim((string) Strings::after($shortName, '\\', -1)) : $shortName;
|
||||
}
|
||||
if ($fullyQualifiedObjectTypeShortName !== $shortName) {
|
||||
continue;
|
||||
}
|
||||
$fullyQualifiedName = \ltrim($fullyQualifiedName, '\\');
|
||||
if ($className === $fullyQualifiedName) {
|
||||
return \false;
|
||||
}
|
||||
if (\in_array($fullyQualifiedName, $removedUses, \true)) {
|
||||
continue;
|
||||
return \false;
|
||||
}
|
||||
return $fullyQualifiedObjectType->getClassName() !== $fullyQualifiedName;
|
||||
return \strpos($fullyQualifiedName, '\\') !== \false;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f9de5d311e7e69d1ad2cb5f3087970d8b9335920';
|
||||
public const PACKAGE_VERSION = '2fac959116e4f50471422e5e5c9eaca3163e6667';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-11-02 10:16:59';
|
||||
public const RELEASE_DATE = '2023-11-03 15:36:34';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue