When using Hashable object as $key, Map::put() will not call the Hashable::hash() on the key until later. For example
<?
class Key implements \Ds\Hashable
{
protected $id;
public function __construct($id)
{
$this->id = $id;
}
public function equals($obj) : bool
{
return $this->id == $obj->id;
}
public function hash()
{
return $this->id;
}
}
$map = new \Ds\Map();
$myki = new Key('myki');
$map->put($myki, "Value String");
var_dump($map->get($myki));
echo 'Map::put() store the Hashable object and it cause error in toArray()'. PHP_EOL;
var_dump($map->toArray());
?>