function normalize()

in src/ChildValidation/private.hack [14:28]


function normalize(mixed $x): mixed {
  if (
    $x is (int, int, mixed) &&
    $x[0] === XHPChild\LegacyExpressionType::EXACTLY_ONE &&
    $x[1] === XHPChild\LegacyConstraintType::EXPRESSION
  ) {
    return normalize($x[2]);
  }

  if ($x is (int, mixed, mixed)) {
    return tuple($x[0], normalize($x[1]), normalize($x[2]));
  }

  return $x;
}