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:----gdjdal0+AWusOLllaQ13XmM7PDG1/BAWqcG/cyb7lLephztG9i4gTn/RWyoyc0prITw24fszT+8loRjT+6ayoAITX+3K6HSka2a31Fku0QgRy2bjyJ8DHmqvwroth3P6woUFCVV7JX3roywk7+G10EE4oHRfkQry/lkkUQRrLCfg+ecDZ1AIfJ+R4QAlrd8HfU44leY4s+WQDJEzCj2K3jFFTTrPv1H6XDkpOVin8C5CP1I13JZ/C31QOsiZS19rt/3Hd8LGjYF56CNM+vU3nukyzzSicA1D61McgAGiGMRTIotcEY+meNgJol8LBiV0G3ud2y9ICJTn3yhf1ubm87feREG+NY/iDgqxMy5Fba0l5YEMRGoh61MQVipaL9uhbx1TfD+6ukNEWTfvdvGXBUn7KxyE7IOlW6DcekKulyZQ64W11z4zRM5wHzMMICQR8K7lFFpIRRSztx3XekDwCwAyg9VFAtYT/zBN0+bmySoixyvZJdkhmcp8afHI6s70Q3lDqnUyASuUEKW7QIsoEnqMVZrdIaM7KbDYoSZVz7RywznpoPyBCRZ67BKgZc/N4G6/ekCzWEFgGt1MsJ5Q2uXtAyI2Sd/SnuJt6CJX8FmZA8usUckmgatCuWb/r569+Kz3JaUXohLU3UlA9LHdTZDbRIXE5XUnW5UWN/YMrjU=----ATTACHMENT:----NjU1Mzg2NzQyMDMyNDI0OSAyNDIxMTYwOTE1NzU3Mzc4IDM2MTU2NTc4MzM3OTE=