Reproducer:
<?php require __DIR__ . '/vendor/autoload.php'; $client = new MongoDB\Client('mongodb://localhost:27070/?replicaSet=rs0'); $collection = $client->test->foo; $collection->drop(); $it = new MongoDB\Model\CachingIterator($collection->find()); var_dump($it); var_dump($it->count());
Result :
MongoDB\Driver\Exception\RuntimeException : Cannot advance a completed or failed cursor.
Expected : no error, the var_dump returns 0