MongoDB\Driver\Cursor has historically only implemented Traversable and provided an internal iterator (not to be to the Iterator userland class). PHP 8 required that we implement either Iterator or IteratorAggregate directly (PHPC-1690), although PHP also provides an internal iterator for extensions to make that easier.
That said, we should consider providing a proper Iterator implementation on the Cursor to remove our reliance on the internal iterator class for PHP 8 and present a consistent API for all supported versions.
- is related to
-
PHPC-1690 MongoDB\Driver\Cursor must implement IteratorAggregate for PHP 8
- Closed
- related to
-
PHPLIB-1114 Replace Cursor type hints with CursorInterface
- Closed