function firstx()

in src/c/select.php [112:132]


function firstx<T>(
  Traversable<T> $traversable,
)[]: T {
  if ($traversable is Container<_>) {
    $first_value = _Private\Native\first($traversable);
    if ($first_value is nonnull) {
      return $first_value;
    }
    invariant(
      !is_empty($traversable),
      '%s: Expected at least one element.',
      __FUNCTION__,
    );
    /* HH_FIXME[4110] invariant above implies this is T */
    return $first_value;
  }
  foreach ($traversable as $value) {
    return $value;
  }
  invariant_violation('%s: Expected at least one element.', __FUNCTION__);
}