Removes the $index field from the $shape (passed in as an inout argument)

public static function removeKey<T as shape()>(
  inout darray $shape,
  arraykey $index,
): void;

As with all inout arguments, it can only be used with local variables.


  • inout darray $shape
  • arraykey $index


  • void


This example shows that removeKey directly removes a key from a Shape:

function run(shape('x' => int, 'y' => int) $point): void {
  // Prints the value at key 'y'

  Shapes::removeKey(inout $point, 'y');

  // Prints NULL because the key 'y' doesn't exist any more
  /* HH_IGNORE_ERROR[4251] typechecker knows the key doesn't exist */
  \var_dump(Shapes::idx($point, 'y'));

function basic_usage_main(): void {
  run(shape('x' => 3, 'y' => -1));