class myCustomStorage extends SplObjectStorage { public function clear() { foreach( $this as $item ) { $this->detach( $item ); } }}