HH\Shapes::idx

Shapes::idx is a helper function for accessing shape field value, or getting a default if it's not set - similar to idx(), but for shapes

public static function idx(
  HH\darray $shape,
  arraykey $index,
  $default = null,
);

This behavior cannot be expressed with type hints, so it's hardcoded in the typechecker. Depending on arity, it will be one of the

idx(S $shape, arraykey $index) : ?Tv, idx(S $shape, arraykey $index, Tv $default) : Tv,

where $index must be statically known (literal or class constant), and S is a shape containing such key:

type S = shape( ... $index => Tv, ... )

Parameters

  • HH\darray $shape
  • arraykey $index
  • $default = null