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:----L+J0O0Q8g9ArbM9OvfX+/MBZ+zGbmvrkVEsh3sD/ADCy2KnTRUJXCAnQBeqPUf3ql54RT5s8WRMWxH42l5CCuPni1PL1Zr6OSRnsCI0r8pnk2DluqXDcSAyXMPLJVDwzloMHQRhUeW0gc1yQscPf4ZfpaXroQOo2ULVunOzqbhrtH8R/ZmtaoF4s0pV9sv4Kvvjb09UW/xz9BcjyPXZ7E2kiTVuFl5rz8IoC5L4tCneiYwyIFBjJnEmVJtVnZDzhhIkDz4yKwTDWlpnlU0OtpHv5mqlN91hFmjViidX3qJoSkPaRUHI5SD8NkAOwYMdxDeLiopDzpo+8i81jxyrAkEepvb0QsXZvzo7sY1vZZmN7n+vtCSK9bGA2R/fiKf74WDI0uuX2wWfG6Sc1jxP1B3s7cz9pIm6uuAPLXrwg0k/uIZzkGRJNPNyC2BwhJxGCNMBuFTOPneGlkr/RNRq5ifCMstDBLHb0wIx3NwlFtda6H0P8KiLAdB2wJ2RETuZu9ewNoQ20as7aHfMhZC3MqJOjjcDm0aKnPdv3v4bOKIO0yEyNb+NPt8eW5PPvaP9robF+HMAAXV/6JnoYZRR+Tg1KSePm6qRPYiVDn95i6X0DZobpiGIq/YV7ZL9P7TMVjrI20whWdFOacllFCqWQsjzK0/QxYMKhDYebnZR8DxI=----ATTACHMENT:----MjA5NDE4MzU2ODg0NzU2NyA0MjIzMzEzMzUyNzMxMDE2IDkyMTEyNjA5MzM4MjYyMzg=