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:----DCivvnEzGgNxXEquaOuJTT1f0vE+qwnBUukw65OTeaW8yis5J8f7L8EJ6qFVaZzUIdJVNfc5r185KvimJY6WILxpvHxeRxGto5pS5FKhs38MbJ2tKarAr/mEYyIy/mpRy4+jzk8+kJbeIGNOibt9z+2IbTpPotAE2b5qWRjyUpOWx4GlVAn+xIZPOAr62dA3DTz80O0gjRiyDgBoMB3E9oDU1TT+/JN7/jFMpKmkeby8VYdBd6xqEmG8eOfQabT4oaBQVUEwVzGxeKJtpm3jjDeIUeZZL0vEsjzL1egdsFMBNmnWB0rt3Zol1y4uZtOsSq8RZxFnBA7ulC6sb0R/hmthAVohsb9ruW+gxugiEn8PFzowCdsErWtgqA2XEdpTeU3epvJKUo5a+QT6VzzDs4PomVZ+Fpq3wJYxzJrpYzdO5FY1rWSTI7u3jnKPFdJKyfVHe+DiLOmeoxULnDEauD211wQYOxcmN4AIbHJgw2trQ49btp3bxtGTwWm+oCXlzKYxkD3li3RJGScIlkrqXVCI0RcJoWdAox18Hr/+fX7NR+YQmIIe8tzIbD3SosbF02LF00XhLb0ryK/hS0oy9HRhpNSRIQdC1p6xmTUbNXDAedY7eMe/fWgscsZdD9wu1eRwzyWK0doe6ZGgiqL7bVV6ZaTQaaroyjvjeO+FiG8=----ATTACHMENT:----MzM1ODE2NzAwNDU2MjY3NCAzMzYzNTE0MTM1MTgzNTMwIDU1NjA4NTg2MTEwMTY5NTQ=