HH\inst_meth

Like fun, but with the purpose of calling an instance method on a specific object.

Description

function HH\inst_meth(
  $instance,
  string $method,
)

Like fun, but with the purpose of calling an instance method on a specific object.

Example:

<?hh
 class C {
  private function isOdd(int $i): bool { return $i % 2 == 1; }
  private function filter(Vector<int> $data): Vector<int> {
    $callback = inst_meth($this, 'isOdd');
    return $data->filter($callback);
  }
}

See also:

Parameters

  • $instance Any class object.
  • string $method Method to call on $instance. Must be a constant string.

Return Values

  • \A - callback which will call $method when invoked.