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:----V35m9mqi7t/MteGUfjvPbasja11nLnAFRW0W0Dq6rARQwFTENRwcz+9mNUIiRaaw35gHaxAn/uuga94EK+DzPayTLLkZgqlOtLNmWtnw9cFJKmTVO7261sYRwGgjKplBGODwum96K6vtl6jtO280nJG94tBMjU1OImcBtpsjULYVbN/ZGxPF8So1wngbuSPS3T7XR7ECLh1v0rgcmO6bT36iI/Z9JoAxWqvbFSdC01B6ol93ZuNcw9cH7yBIZFNvsM2wQUHAHoLgjlpXkmyNss3yN7WBFwManDqGGKMBkQ0QEVfV3CNAEX2F5oyq1cTk51VMNzSkGbcneKL6pIgnN7gODhvZyOsaD6SP4KidmjAUxkefyL4nxQhQ4B/4zSB6pDXYXU/JCLL46N7TANhUtiXObpCRBEfV+jb4lfk8iUXC2qtILXca4X5+x6uYAbPb0e/p9IEgeN1/ddXwhiWsrz1bQEZG/m6mols3Jje92iB/Bb4WfWU/C3kytMM9J6NVv1I0OCTDJBjFarJ/CFClAM0kxGvlIVm07jO8/xstY/9A5TflF3kNlknLguxQ1IzZaNOmru12XL7sPYCnYkSacuEXT6bQC03imctLnYsVta2c0mt1pn2qYpz7zYDxxWgwvwWvitfwCX3IDFl4C+SW4/pv2vJmtN+QQ26i1MS0CWs=----ATTACHMENT:----OTc1MTc1MTY4ODQ3MDQ5MyA2MjIzOTU3NDA4NzIyODk2IDc1NjExODIyNjM5MDE5ODA=