Skip to content

Commit 5679c36

Browse files
authored
DateFunctionReturnTypeHelper: prevent unnecessary TypeCombinator::union() (#5629)
1 parent 37da709 commit 5679c36

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Type/Php/DateFunctionReturnTypeHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public function getTypeFromFormatType(Type $formatType, bool $useMicrosec): Type
3030
}
3131

3232
if (count($types) === 0) {
33-
$types[] = $formatType->isNonEmptyString()->yes()
33+
$type = $formatType->isNonEmptyString()->yes()
3434
? new IntersectionType([new StringType(), new AccessoryNonEmptyStringType()])
3535
: new StringType();
36+
} else {
37+
$type = TypeCombinator::union(...$types);
3638
}
3739

38-
$type = TypeCombinator::union(...$types);
39-
4040
if ($type->isNumericString()->no() && $formatType->isNonEmptyString()->yes()) {
4141
$type = TypeCombinator::union($type, new IntersectionType([
4242
new StringType(), new AccessoryNonEmptyStringType(),

0 commit comments

Comments
 (0)