diff --git a/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php b/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php index 57006e61c96..9ed961b3cc0 100644 --- a/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php +++ b/packages/PHPStanStaticTypeMapper/TypeMapper/StaticTypeMapper.php @@ -12,6 +12,7 @@ use Rector\Core\Enum\ObjectReference; use Rector\Core\Php\PhpVersionProvider; use Rector\Core\ValueObject\PhpVersionFeature; use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; +use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType; use Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType; /** @@ -45,20 +46,19 @@ final class StaticTypeMapper implements TypeMapperInterface return $type->toPhpDocNode(); } /** - * @param StaticType $type + * @param SimpleStaticType|StaticType $type */ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { - // special case, for autocomplete of return type - if ($type instanceof SimpleStaticType) { - return new Name(ObjectReference::STATIC); - } if ($type instanceof SelfStaticType) { return new Name(ObjectReference::SELF); } - if ($this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::STATIC_RETURN_TYPE)) { - return new Name(ObjectReference::STATIC); + if ($typeKind !== TypeKind::RETURN) { + return new Name(ObjectReference::SELF); } - return new Name(ObjectReference::SELF); + if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::STATIC_RETURN_TYPE)) { + return new Name(ObjectReference::SELF); + } + return new Name(ObjectReference::STATIC); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 86d78508a6a..0e509006a2f 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 = '043d43cd0347b4c2a73e896674a1f22ab1ce6d62'; + public const PACKAGE_VERSION = '79c57f019e1c94c72ef79cb6cbdda864bdc2e1c1'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-06 14:26:04'; + public const RELEASE_DATE = '2023-12-06 21:22:55'; /** * @var int */