If you care about key-strictness, you may need to use an alternative solution (maybe overriding offsetExists() in subclass(es)). So, offsetExists() acts like array_key_exists() and does not handle the key types. Here;
<?php
$array = ['one', 'two', 3.=>'boom!'];
$arrayObject = new ArrayObject($array);
$key = '3';
var_dump(array_key_exists($key, $array)); var_dump(in_array($key, array_keys($array), true)); var_dump($arrayObject->offsetExists($key)); var_dump(in_array($key, array_keys($arrayObject->getArrayCopy()), true)); public function offsetExists($key)
{
return in_array($key, array_keys($this->getArrayCopy()), true);
}
?>