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:----0e2ynSJMY8aI1g9QPlkTyVPeyLvnqwWqIJ8bXYLTmCWPFSdpZTkJPrk16Z0z9NATKOSkPhvbo3Ug4/BLPYYAprQS4vSfRsDRZLf/6hgtHXhRRymiw3iI8M8mWdGhHPT248iNm86e45DpNbcUeM+CIb5Z5RU9DB6THCpQJsTHuIFVqtWWAoJZDUe9h5Xv7wYm9e189hGGnQyKKkdW2xmbQ8yimzSdDngzpFL4cFiE9EIGXzM3R2RC7q8isaZVjSKhxFHk2xb9RnqYPGbg/XaUMeh2hKjUsg8Z+r5z7k1hLv6IfExxSN6LASkjA+EdT87zJ+YEQuSVGqtvglSgw8IBz1WiU80THPFngwglJ0//gHBtqjpVHmzSu54dyuEqJ/KCLqX8MP7gkHBZ4QhKsALvzakMgL//BpbK9EhqiRCcjYaUX000nsDF/pLxIIuJmrtqNmeAg/AJ12Dcs0EPXqtOkZSzlS16uQRKLw62Bg+OTNy9TkMjRhNJ4KMfLZJCwwdKgqnuokzCTWCcF2FX7ManS81P0OBhK41Q8Mah4fFgvBDC4Chc8CuGsMAzetYFUVycpj36q2L2bb+DnB1T+V1lk1kCY4geQ6M5fM/s/UbWwV1L7MWoF2dg9C4+JwCkvxoC+DSrtk2RkIFoOtsBJSNYdUVJHA6+SLNEQ02MqKKCmu4=----ATTACHMENT:----NDQ5ODQ3NzQxNjUwODcyMSA5MTkyMjE2NTU0NjcyMjk4IDY0OTg4NTgzODEwOTU2MA==