This API is part of the Hack Standard Library, not HHVM itself.
Facebook Engineer?

This function is available as Dict\group_by() in Facebook's www repository.

Returns a new dict where

  • keys are the results of the given function called on the given values


namespace HH\Lib\Dict;

function group_by<Tk as arraykey, Tv>(
  Traversable<Tv> $values,
  (function(Tv):?Tk) $key_func,
): dict<Tk, vec<Tv>>;
  • values are vecs of original values that all produced the same key. If a value produces a null key, it's omitted from the result.