From 328512f2ceebb10419c3821deee6df9af3f7e9b0 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 18 Jan 2025 19:28:01 +0000 Subject: [PATCH] Updated Rector to commit 0c368224b325087933f286a8e19be972b1ac85ae https://github.com/rectorphp/rector-src/commit/0c368224b325087933f286a8e19be972b1ac85ae [AutoImport] Handle inner with sub namespace on auto import (#6679) --- rules/CodingStyle/Application/UseImportsAdder.php | 13 +++++++------ src/Application/VersionResolver.php | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/rules/CodingStyle/Application/UseImportsAdder.php b/rules/CodingStyle/Application/UseImportsAdder.php index 43630d02388..a0bf0c8c73e 100644 --- a/rules/CodingStyle/Application/UseImportsAdder.php +++ b/rules/CodingStyle/Application/UseImportsAdder.php @@ -3,7 +3,6 @@ declare (strict_types=1); namespace Rector\CodingStyle\Application; -use RectorPrefix202501\Nette\Utils\Strings; use PhpParser\Node\Name; use PhpParser\Node\Stmt; use PhpParser\Node\Stmt\Declare_; @@ -11,7 +10,6 @@ use PhpParser\Node\Stmt\GroupUse; use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Nop; use PhpParser\Node\Stmt\Use_; -use PHPStan\Type\ObjectType; use Rector\CodingStyle\ClassNameImport\UsedImportsResolver; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory; @@ -179,12 +177,15 @@ final class UseImportsAdder } return $namespace->name->toString(); } - private function isCurrentNamespace(string $namespaceName, ObjectType $objectType) : bool + /** + * @param \Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $objectType + */ + private function isCurrentNamespace(string $namespaceName, $objectType) : bool { - $afterCurrentNamespace = Strings::after($objectType->getClassName(), $namespaceName . '\\'); - if ($afterCurrentNamespace === null) { + $className = $objectType->getClassName(); + if (\strncmp($className, $namespaceName . '\\', \strlen($namespaceName . '\\')) !== 0) { return \false; } - return $namespaceName . '\\' . $afterCurrentNamespace === $objectType->getClassName(); + return $namespaceName . '\\' . $objectType->getShortName() === $className; } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index e8e8c7bf929..937f231fbaf 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '71534e3d67fec9421bab21cecff2385a4bfefc1b'; + public const PACKAGE_VERSION = '0c368224b325087933f286a8e19be972b1ac85ae'; /** * @api * @var string */ - public const RELEASE_DATE = '2025-01-18 16:44:19'; + public const RELEASE_DATE = '2025-01-19 02:25:31'; /** * @var int */