In this case, wouldn't you want to also catch where the user specified `['_id' => 'foo']` as `$query`? The important part isn't that they provided a scalar or MongoId, but that they're only querying by `_id`. In that case, `$isScalar` (after renaming it to something more sensible) would be set to the boolean result of `isset($query['_id']) && count($query) === 1` (perhaps `array_key_exists()` to be more strict).