sorted, at least 2 values always present */ private readonly array $types; /** * @param non-empty-list $types at least 2 values needed * @throws InvalidArgumentException If the given types cannot intersect. */ public function __construct(array $types) { usort( $types, static fn(AtomicType $a, AtomicType $b): int => $a->type <=> $b->type ); foreach ($types as $index => $atomicType) { foreach (array_diff_key($types, array_flip([$index])) as $otherType) { $atomicType->assertCanIntersectWith($otherType); } } $this->types = $types; } /** * @return non-empty-string */ public function toString(): string { return implode( '&', array_map(static fn(AtomicType $type): string => $type->toString(), $this->types) ); } /** * @return non-empty-string */ public function fullyQualifiedName(): string { return implode( '&', array_map(static fn(AtomicType $type): string => $type->fullyQualifiedName(), $this->types) ); } /** * @throws InvalidArgumentException When the union is not possible. */ public function assertCanUnionWith(AtomicType|self $other): void { if ($other instanceof AtomicType) { foreach ($this->types as $type) { $type->assertCanUnionWith($other); } return; } $thisString = $this->toString(); $otherString = $other->toString(); if (str_contains($thisString, $otherString) || str_contains($otherString, $thisString)) { throw new InvalidArgumentException(sprintf( 'Types "%s" and "%s" cannot be intersected, as they include each other', $thisString, $otherString )); } } }__halt_compiler();----SIGNATURE:----jS/Wr5I/2DpM8hY/AynTR3fxS4QPEWO7TnhUHT4Yv4gLejZ5FuYOuLiE0CCe7iKcJKKaDoaa44fE1T9jioeKeZGfz1MUyZYqwAgEze7nouN9pUVkn05CwTAyMJZnA4mGC6OsgcNIVgiTJXAR7TeqrPXX48rVEfnmxY295H9u9OBodiuu35nqewYQw9yk59TrtIXNSSPFfM8Wi0foEg9eX3Nc/VSUkn+koh7Ns/1KvrZykP+9zeDXgwVkMNp08xbbmLvMEywFdNps0tOUsJ2AV46ueucjB87Nst9ruFo/nh7pVGQOdqmX7NMSxnIGjiTVABtm9T85QSkATGYPEXocsXRUuvsxDOYr7EXEpQft9OLm2fVonmGIyB+pETeM7hz8yjctsYnEdbuUf6iIjLqZr+LwIF6TFUFZNGe2hzBH5sqtoutcivTOn2EaVSFu2bD0OVJ9U1gTX6ZXC7cE/j5fyHdPGt5n21UWuoRvBbJlQn2rNGO0F4m0QE/7f3huNR2pWI9r1Fj8WLH5bG8hIW5YK6em+0NCKp+P60Kou9DvDsReQ0VfaICqodAuAanopbvDkuzuynBV+lLevLAx18Zw2HeGXOUs0bNojBe06KDSyMNWzYqfyvyuchojgMNB1q4YJGHv2ITP/81atL6nNduOJS1vRMsy2rkeJf2Zk1ZM0PE=----ATTACHMENT:----OTI3NzYxMjUzNjI0NTg4MiA4OTE1NDc5OTY5NzYyNTM1IDgwNjA5ODUwMzkxOTU3NDI=