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:----d2+V7fcR9J97fobCmqof4nO8JdDyzawyOlwE+Sr9ybyPq402kDzEO2rxpborh2QB2yI7TxDN2PPSnBXuteRG0EmVBbc06ThiQGnfXMp5h3gYrcXtfGgsW5FG/+bj3N7xuizbr07QREFLkBK3RN9PCbtmAXBam1MZyVnV1szz5Fk4Rlns5JEqeniXjT/28nXDwEISP6wU+0Hr8QtWDLFKgSxH8mOGZDQ5onkw5PRP7Q3WWe02TgbvAA/H2aJG5VgoPJJR4XQdA4XSB0tsQwqk1OVcLQDqQhct9URMmMHYl0MqiqUJ64Fpvu6lkormlgIsuBRd8dqlbURT3lsBdI/jhPTm249QneOr6429XzBcB26QXGIqk48XYmtx6LDmH6yYOOQN25p4ruxEadCwm2AfJQ/6Ykp5gqA7D6UdtPs15DSsQATASs44MjmEbxfBlGhTankCpI6NG2D41+l9RSRiym6y/Iks/AMlx3E4LfeRydbOdINf0tHJZj8Uq8vBWi8kmoXvsByt5LZQEHpBy8qUvF8GcWUi7lZVJiAqxroS4l6sBlA3J4rGF+g2YxUf/6sO9Sk2yD111KZ5VTEF+AT128uKJsQ4YFDlM5YHATfY4QHzCI7YUWGtkdcWAfvJt3hi86xecr26k2L/xNgJ/kmO3BbrCKcLssPcKESnr1gMJiE=----ATTACHMENT:----NTQ5MzAzOTE5OTYzNDg3OSA3MDQwNzUzNDgxOTMxNTE5IDI2MTYzNDUzMjkwMzY4MDI=