Phan\Language\UnionType::withTemplateParameterTypeMap PHP Method

withTemplateParameterTypeMap() public method

public withTemplateParameterTypeMap ( array $template_parameter_type_map ) : UnionType
$template_parameter_type_map array A map from template type identifiers to concrete types
return UnionType This UnionType with any template types contained herein mapped to concrete types defined in the given map.
    public function withTemplateParameterTypeMap(array $template_parameter_type_map) : UnionType
    {
        $concrete_type_list = [];
        foreach ($this->getTypeSet() as $i => $type) {
            if ($type instanceof TemplateType && isset($template_parameter_type_map[$type->getName()])) {
                $union_type = $template_parameter_type_map[$type->getName()];
                foreach ($union_type->getTypeSet() as $concrete_type) {
                    $concrete_type_list[] = $concrete_type;
                }
            } else {
                $concrete_type_list[] = $type;
            }
        }
        return new UnionType($concrete_type_list);
    }