diff --git a/src/Type/Php/DateFunctionReturnTypeHelper.php b/src/Type/Php/DateFunctionReturnTypeHelper.php index 3126efe41b..3cce51593b 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(),