From f253bfe0597619d5f751f0082c5932213920bcb1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 6 Aug 2024 13:28:43 +0000 Subject: [PATCH] Updated Rector to commit 6a4d7178cc23656fabc4ea31a8d1673cdfde6e37 https://github.com/rectorphp/rector-src/commit/6a4d7178cc23656fabc4ea31a8d1673cdfde6e37 [PHPStanStaticTypeMapper] Clean up TypeUnwrapper::removeNullTypeFromUnionType() (#6220) --- src/Application/VersionResolver.php | 4 ++-- src/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index d796ba11395..12762e7f514 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 = '147c96190e99909c71c2d920a83ae96cc9b3bd57'; + public const PACKAGE_VERSION = '6a4d7178cc23656fabc4ea31a8d1673cdfde6e37'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-08-06 12:31:33'; + public const RELEASE_DATE = '2024-08-06 20:26:09'; /** * @var int */ diff --git a/src/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php b/src/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php index 858b6e0b855..cea3977d620 100644 --- a/src/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php +++ b/src/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php @@ -4,6 +4,7 @@ namespace Rector\PHPStanStaticTypeMapper\Utils; use PHPStan\Type\Type; +use PHPStan\Type\TypeCombinator; use PHPStan\Type\TypeWithClassName; use PHPStan\Type\UnionType; final class TypeUnwrapper @@ -23,16 +24,6 @@ public function unwrapFirstObjectTypeFromUnionType(Type $type) : Type } public function removeNullTypeFromUnionType(UnionType $unionType) : Type { - $unionedTypesWithoutNullType = []; - foreach ($unionType->getTypes() as $type) { - if ($type instanceof UnionType) { - continue; - } - $unionedTypesWithoutNullType[] = $type; - } - if ($unionedTypesWithoutNullType !== []) { - return $unionedTypesWithoutNullType[0]; - } - return new UnionType($unionedTypesWithoutNullType); + return TypeCombinator::removeNull($unionType); } }