Código PHP:
class Coleccion extends ArrayObject
{
public function clear()
{
$iterator = $this->getIterator();
foreach($iterator as $key => $value)
$this->offsetUnset($key);
}
}
resultado:
NOTICE Coleccion::clear(): ArrayIterator::next(): Array was modified outside object and internal position is no longer valid