Skip to content

Commit

Permalink
Updated Rector to commit bcfb5981444172d8ccf82e783b5a217385ea83c7
Browse files Browse the repository at this point in the history
rectorphp/rector-src@bcfb598 Add ClassNameFromObjectTypeResolver to cover TypeWithClassName instance checks (#6420)
  • Loading branch information
TomasVotruba committed Nov 12, 2024
1 parent e1780f6 commit 1d4e2fd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
17 changes: 17 additions & 0 deletions src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare (strict_types=1);
namespace Rector\StaticTypeMapper\Resolver;

use PHPStan\Type\Type;
final class ClassNameFromObjectTypeResolver
{
public static function resolve(Type $type) : ?string
{
$objectClassNames = $type->getObjectClassNames();
if (\count($objectClassNames) !== 1) {
return null;
}
return $objectClassNames[0];
}
}
7 changes: 4 additions & 3 deletions src/StaticTypeMapper/ValueObject/Type/AliasedObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
}
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 1d4e2fd

Please sign in to comment.