SplObjectStorage objects can also not be cloned reliably. Therefore working around the issue by looping over a clone of the original object is also not an option.
The only thing we can do here is to call rewind() after the loop. Of course, this still changes the index (if it was not on the first element). In most cases, though, I think that changing the index to the first element is "less surprising" than changing it to the last element.
Originally posted by @sebastianbergmann in https://github.com/sebastianbergmann/exporter/issues/49#issuecomment-1711067399