Skip to content

Commit 96e4443

Browse files
committed
UnionType - carry information that it's normalized
1 parent 1a59fe1 commit 96e4443

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Type/TypeCombinator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public static function union(Type ...$types): Type
371371
}
372372
}
373373

374-
return new UnionType($types);
374+
return new UnionType($types, true);
375375
}
376376

377377
/**

src/Type/UnionType.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UnionType implements CompoundType
4242
* @api
4343
* @param Type[] $types
4444
*/
45-
public function __construct(private array $types)
45+
public function __construct(private array $types, private bool $normalized = false)
4646
{
4747
$throwException = static function () use ($types): void {
4848
throw new ShouldNotHappenException(sprintf(
@@ -74,6 +74,11 @@ public function getTypes(): array
7474
return $this->types;
7575
}
7676

77+
public function isNormalized(): bool
78+
{
79+
return $this->normalized;
80+
}
81+
7782
/**
7883
* @return Type[]
7984
*/
@@ -836,7 +841,7 @@ public function tryRemove(Type $typeToRemove): ?Type
836841
*/
837842
public static function __set_state(array $properties): Type
838843
{
839-
return new self($properties['types']);
844+
return new self($properties['types'], $properties['normalized']);
840845
}
841846

842847
/**

0 commit comments

Comments
 (0)