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:----qvocMLregIlKW/RigqZir3OF2uLnXO/JYGKtuydnGvRfZSanBgQuqmfeU/OMLz9wCrPnr+GLBHDVpoWjnznmeeYy0hgbnNQ4wzelwzvoLMit3ow42rFzrn9lwup5OxFWUYnx/uKz7gdFC555mJ2joKu2pTbwQcZvObSSw11sv1p0xyIGbbMWQYN5vme3HPswOf14XY9IyisfPdRUPTYq4b+WCQr+3vIOgs7vimbqFSWuXQc4cTzODy9S90OHG9wFEh1Or9Rr1YnZCdfB26/BplAoLQZwV9ewsVsuHRt1JVX5xtIlu1hnlRhqNEnYPBHprvllS2+eJ+zouDWH3QzSMz7K0t1F/GrMbOCSBzK9GkyFnSRqFz4YiKpppMmbq5mFLOAzfiy8+hx4/ifUFgKqtLCp+z1Qqwhsd825jvs+Bn3v5vRYIHij551MSgY2RfFC2S7c1FaCuco+MRRnFcjJclSCcwTaKgKGbwEy7EHwcThIfVHYxhCBFoVyXYtjaZmGy8v90IwBn2IuYH4mSHFGkXBeVcUWIUgxymx5D7lDT+D6TQiVFehqMbw97Gt5VhmGQJ5U4jA8520ub95wxMd0ZnPvpHKFNOVzVSCImGi9JkYJYGiXWjnGngpRoWCIyFv/OMumAzzf/S2bW/F4KKzZJFBaWPulLj8/alHa863iWzA=----ATTACHMENT:----NDE4MDAyMTYxMzIzOTc0MCA5MjUyMTQzMzE1OTA2NDk1IDMxNDcwMDYyNTg5MzA3NDQ=