$types sorted, at least 2 values always present */ private readonly array $types; /** * @param non-empty-list $types at least 2 values needed */ public function __construct(array $types) { usort( $types, static fn(AtomicType|IntersectionType $a, AtomicType|IntersectionType $b): int => [ $a instanceof IntersectionType ? -1 : $a->sortIndex, $a->toString(), ] <=> [ $b instanceof IntersectionType ? -1 : $b->sortIndex, $b->toString(), ] ); foreach ($types as $index => $type) { foreach (array_diff_key($types, array_flip([$index])) as $otherType) { $type->assertCanUnionWith($otherType); } } $this->types = $types; } /** * @return non-empty-string */ public function toString(): string { return implode( '|', array_map( static fn(AtomicType|IntersectionType $type): string => $type instanceof IntersectionType ? '(' . $type->toString() . ')' : $type->toString(), $this->types ) ); } /** * @return non-empty-string */ public function fullyQualifiedName(): string { return implode( '|', array_map( static fn(AtomicType|IntersectionType $type): string => $type instanceof IntersectionType ? '(' . $type->fullyQualifiedName() . ')' : $type->fullyQualifiedName(), $this->types ) ); } } __halt_compiler();----SIGNATURE:----uEKul+bmOZ/xgKa4Lpn+udEl+UhRJ2cft9UH2yonxAy8cPSJ2TLQVdeCk/vKQKgZBDGBVlTk11ZzyvG2b6QoUB5dPJTDOS04H5wvqVk9uFYLhQCYo+/igxOkwcRyHmbZ8HL3WEPpzADooi6VEE77o7pP5F95hjvT2gjBunEkf5cSDwWxHZuGtqqK/z5Cw01eg8FgucICwW+yAHFsZhjeY8No5Yg+HwYW+rvZTou33KFaXyC4vCJ8Hw3M/SyxiZayAdpAO+sGvj9gTEuImcDLUq8FIYL2vDZ4yCCqLiqg0eoD77pFx0AYVN/jMlvPk3qI30NglJICDP2zKcA+sh3tYh3hAJ4RTbIABxU2A2+PTL12zW+bV6wH/oo9xZQd2485G19VepZ3lAiskwdDZOJl2XRxDfcO4NTGA8o11KGT7azr1Wn8h3o4HD3AM5F7PIIFDvHHCZ1xf3dBFzAI23lwIDVYQJTBU+lCo02sjkHQ3slliiP7AHrdTcpZqmlsIj+BL4CMWORTCerLBlK83xBccBnkCuOMOo0MMtJO3NFlFmxZeWT2S5IQBaycx85k1kfC8DkVO7ZhFtQRATFqWpMQUpOyw2nF4d53mh7A/WIxb/OqBKAgE+KtL5wMcvuQBIi9H7e6BzZqJAB1rAPU5Jk8ay7bC5qVPlIv0jc7laJs9Ik=----ATTACHMENT:----NTY5NzY5NDY2MjM5ODc0NyA1NzU5OTA5OTI0NzY0ODQxIDQ3Njk5MjYwMjM3OTIxMjQ=