$typesInUnion */ $typesInUnion = array_map( self::fromString(...), array_map( static fn (string $type): string => trim($type, '()'), explode(self::UNION_SEPARATOR, $type) ) ); return new UnionType($typesInUnion); } if (str_contains($type, self::INTERSECTION_SEPARATOR)) { /** @var non-empty-list $typesInIntersection */ $typesInIntersection = array_map(self::fromString(...), explode(self::INTERSECTION_SEPARATOR, $type)); return new IntersectionType($typesInIntersection); } return AtomicType::fromString($type); } }