Skip to content

Commit

Permalink
fix flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan committed Dec 21, 2022
1 parent ab25776 commit 095fe1d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Type/TypeCombinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,11 @@ public static function union(Type ...$types): Type
}

if ($scalarTypes !== []) {
if (count($scalarTypes) === 1) {
$types[] = $scalarTypes[array_key_first($scalarTypes)][0];
$flattenTypes = array_merge(...array_values($scalarTypes));
if (count($flattenTypes) === 1) {
$types[] = $flattenTypes[0];
} else {
$types[] = new UnionType(array_merge(...array_values($scalarTypes)), true);
$types[] = new UnionType($flattenTypes, true);
}
}

Expand Down

0 comments on commit 095fe1d

Please sign in to comment.