We are not always passing around objects in collections, and collections musn't have only objects. I am not sure if this is a helpful addition for users and as you show in the test, the API actually requires quite some code to instantiate and add elements to the collection, whereas i could just do:

    $query->setParameter('foo', array_map(function ($object) {
        return $object->getId();
    }, array($a, $b));

This is much simpler and generic.