mongoc_client_read_write_command_with_opts() includes logic to inject the mongo_client_t's read concern, read preference, and write concern if said options are not specified in the BSON options (not the same as the command document). Since PHPLIB currently passes in these options in the command document, a simple migration to mongoc_client_read_write_command_with_opts() would see duplicate fields injected by libmongoc. Therefore, PHPC's executeCommand() methods will need to extract these fields from command documents and supply them in the separate BSON options document.
When combined with
PHPLIB-261, this will ensure that only PHPC and libmongoc are responsible for injecting client-level options into commands.
Lastly, it should be noted that mongoc_client_read_write_command_with_opts() does not inspect a command document to determine whether it is a read or write command. The default behavior will see read concern and write concern always injected from mongo_client_t if not provided in BSON options. Therefore, the PHP driver may need to implement some detection on its own to determine whether to call mongoc_client_read_command_with_opts() or mongoc_client_write_command_with_opts() on a per-command basis.