HH\Shapes::removeKey

Description

public static function removeKey(
  array &$shape,
  arraykey $index,
): void

Parameters

  • array &$shape
  • arraykey $index

Examples

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

<?hh

namespace Hack\UserDocumentation\API\Examples\HH\Shapes\RemoveKey;

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

  // Prints the value at key 'y'
  var_dump($point['y']);

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

  // Prints NULL because the key 'y' doesn't exist any more
  var_dump(Shapes::idx($point, 'y'));
}

run();
Output
int(-1)
NULL