function stringify_shape()

in src/PageSections/_Private/stringify_shape.hack [15:38]


function stringify_shape(
  string $ns,
  vec<ScannedShapeField> $fields,
): string {
  $ret = "shape(\n";
  foreach ($fields as $field) {
    $ret .= '  '.stringify_expression($field->getName());
    $ret .= ' => ';

    $value = stringify_typehint($ns, $field->getValueType());
    $lines = Str\split($value, "\n");
    if (C\count($lines) === 1) {
      $ret .= $lines[0];
    } else {
      $ret .= $lines
        |> Vec\map($$, $l ==> '  '.$l)
        |> Str\join($$, "\n")
        |> "\n".$$;
    }
    $ret .= ",\n";
  }

  return $ret.')';
}