From caae7195704b074663ca76737780d589f11c23a3 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 10 May 2026 12:28:09 +0200 Subject: [PATCH] DateFunctionReturnTypeHelper: prevent unnecessary TypeCombinator::union() --- src/Type/Php/DateFunctionReturnTypeHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Type/Php/DateFunctionReturnTypeHelper.php b/src/Type/Php/DateFunctionReturnTypeHelper.php index 3126efe41b0..3cce51593b2 100644 --- a/src/Type/Php/DateFunctionReturnTypeHelper.php +++ b/src/Type/Php/DateFunctionReturnTypeHelper.php @@ -30,13 +30,13 @@ public function getTypeFromFormatType(Type $formatType, bool $useMicrosec): Type } if (count($types) === 0) { - $types[] = $formatType->isNonEmptyString()->yes() + $type = $formatType->isNonEmptyString()->yes() ? new IntersectionType([new StringType(), new AccessoryNonEmptyStringType()]) : new StringType(); + } else { + $type = TypeCombinator::union(...$types); } - $type = TypeCombinator::union(...$types); - if ($type->isNumericString()->no() && $formatType->isNonEmptyString()->yes()) { $type = TypeCombinator::union($type, new IntersectionType([ new StringType(), new AccessoryNonEmptyStringType(),