diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 5b8fcaff361..954725fa7a2 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 = '06adce3c1a50de37f64eb9afe9635834540402f4'; + public const PACKAGE_VERSION = 'bcfb5981444172d8ccf82e783b5a217385ea83c7'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-11-12 14:56:01'; + public const RELEASE_DATE = '2024-11-12 11:15:36'; /** * @var int */ diff --git a/src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php b/src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php new file mode 100644 index 00000000000..86f883e7b3a --- /dev/null +++ b/src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php @@ -0,0 +1,17 @@ +getObjectClassNames(); + if (\count($objectClassNames) !== 1) { + return null; + } + return $objectClassNames[0]; + } +} diff --git a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php index 08a26102042..af9f44076a8 100644 --- a/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php +++ b/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php @@ -8,7 +8,7 @@ use PhpParser\Node\Stmt\UseUse; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; -use PHPStan\Type\TypeWithClassName; +use Rector\StaticTypeMapper\Resolver\ClassNameFromObjectTypeResolver; /** * @api */ @@ -52,12 +52,13 @@ public function areShortNamesEqual($comparedObjectType) : bool } public function equals(Type $type) : bool { + $className = ClassNameFromObjectTypeResolver::resolve($type); // compare with FQN classes - if ($type instanceof TypeWithClassName) { + if ($className !== null) { if ($type instanceof self && $this->fullyQualifiedClass === $type->getFullyQualifiedName()) { return \true; } - if ($this->fullyQualifiedClass === $type->getClassName()) { + if ($this->fullyQualifiedClass === $className) { return \true; } } diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 27bca79626a..b53d185cb6b 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2166,6 +2166,7 @@ 'Rector\\StaticTypeMapper\\PhpParser\\NullableTypeNodeMapper' => $baseDir . '/src/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php', 'Rector\\StaticTypeMapper\\PhpParser\\StringNodeMapper' => $baseDir . '/src/StaticTypeMapper/PhpParser/StringNodeMapper.php', 'Rector\\StaticTypeMapper\\PhpParser\\UnionTypeNodeMapper' => $baseDir . '/src/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php', + 'Rector\\StaticTypeMapper\\Resolver\\ClassNameFromObjectTypeResolver' => $baseDir . '/src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php', 'Rector\\StaticTypeMapper\\StaticTypeMapper' => $baseDir . '/src/StaticTypeMapper/StaticTypeMapper.php', 'Rector\\StaticTypeMapper\\ValueObject\\Type\\AliasedObjectType' => $baseDir . '/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php', 'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedGenericObjectType' => $baseDir . '/src/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 0d57c33dfc5..6060ce3514e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -2385,6 +2385,7 @@ class ComposerStaticInit4d4c37b878ce01a3ff505ba7def6aac7 'Rector\\StaticTypeMapper\\PhpParser\\NullableTypeNodeMapper' => __DIR__ . '/../..' . '/src/StaticTypeMapper/PhpParser/NullableTypeNodeMapper.php', 'Rector\\StaticTypeMapper\\PhpParser\\StringNodeMapper' => __DIR__ . '/../..' . '/src/StaticTypeMapper/PhpParser/StringNodeMapper.php', 'Rector\\StaticTypeMapper\\PhpParser\\UnionTypeNodeMapper' => __DIR__ . '/../..' . '/src/StaticTypeMapper/PhpParser/UnionTypeNodeMapper.php', + 'Rector\\StaticTypeMapper\\Resolver\\ClassNameFromObjectTypeResolver' => __DIR__ . '/../..' . '/src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php', 'Rector\\StaticTypeMapper\\StaticTypeMapper' => __DIR__ . '/../..' . '/src/StaticTypeMapper/StaticTypeMapper.php', 'Rector\\StaticTypeMapper\\ValueObject\\Type\\AliasedObjectType' => __DIR__ . '/../..' . '/src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php', 'Rector\\StaticTypeMapper\\ValueObject\\Type\\FullyQualifiedGenericObjectType' => __DIR__ . '/../..' . '/src/StaticTypeMapper/ValueObject/Type/FullyQualifiedGenericObjectType.php',