Commit 4fd37901 authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-234: Document exceptions for API methods

parent 3cc57327
ref: error-driver-invalidargumentexception
content: |
:php:`MongoDB\\Driver\\Exception\\InvalidArgumentException
<mongodb-driver-exception-invalidargumentexception>` for errors related to the
parsing of parameters or options at the driver level.
---
ref: error-driver-runtimeexception
content: |
:php:`MongoDB\\Driver\\Exception\\RuntimeException
<mongodb-driver-exception-runtimeexception>` for other errors at the driver
level (e.g. connection errors).
---
ref: error-invalidargumentexception
content: |
:phpclass:`MongoDB\\Exception\\InvalidArgumentException` for errors related to
the parsing of parameters or options.
---
ref: error-unexpectedvalueexception
content: |
:phpclass:`MongoDB\\Exception\\UnexpectedValueException` if the command
response from the server was malformed.
---
ref: error-unsupportedexception
content: |
:phpclass:`MongoDB\\Exception\\UnsupportedException` if options are used and
not supported by the selected server (e.g. ``collation``, ``writeConcern``).
...
...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropDatabase ...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on the </reference/command/dropDatabase>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -36,6 +36,13 @@ A traversable :phpclass:`MongoDB\\Model\\DatabaseInfoIterator`, which contains ...@@ -36,6 +36,13 @@ A traversable :phpclass:`MongoDB\\Model\\DatabaseInfoIterator`, which contains
a :phpclass:`MongoDB\\Model\\DatabaseInfo` object for each database on the a :phpclass:`MongoDB\\Model\\DatabaseInfo` object for each database on the
server. server.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\Collection` object. A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\Database` object. A :phpclass:`MongoDB\\Database` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -29,6 +29,13 @@ Definition ...@@ -29,6 +29,13 @@ Definition
.. include:: /includes/apiargs/MongoDBClient-method-construct-driverOptions.rst .. include:: /includes/apiargs/MongoDBClient-method-construct-driverOptions.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -37,6 +37,14 @@ A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or ...@@ -37,6 +37,14 @@ A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or
:php:`ArrayIterator <arrayiterator>` object. In both cases, the return value :php:`ArrayIterator <arrayiterator>` object. In both cases, the return value
will be :php:`Traversable <traversable>`. will be :php:`Traversable <traversable>`.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. _php-agg-method-behavior: .. _php-agg-method-behavior:
Behavior Behavior
......
...@@ -35,6 +35,13 @@ Return Values ...@@ -35,6 +35,13 @@ Return Values
A :phpclass:`MongoDB\\BulkWriteResult` object, which encapsulates a A :phpclass:`MongoDB\\BulkWriteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add output and examples .. todo: add output and examples
See Also See Also
......
...@@ -34,6 +34,14 @@ Return Values ...@@ -34,6 +34,14 @@ Return Values
The number of documents matching the filter criteria. The number of documents matching the filter criteria.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
.. todo: add output and examples .. todo: add output and examples
See Also See Also
......
...@@ -39,6 +39,13 @@ Return Values ...@@ -39,6 +39,13 @@ Return Values
The name of the created index as a string. The name of the created index as a string.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -34,6 +34,13 @@ Return Values ...@@ -34,6 +34,13 @@ Return Values
The names of the created indexes as an array of strings. The names of the created indexes as an array of strings.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
``$indexes`` parameter ``$indexes`` parameter
---------------------- ----------------------
......
...@@ -35,6 +35,13 @@ Return Values ...@@ -35,6 +35,13 @@ Return Values
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -37,6 +37,13 @@ Return Values ...@@ -37,6 +37,13 @@ Return Values
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -34,6 +34,14 @@ Return Values ...@@ -34,6 +34,14 @@ Return Values
An array of the distinct values. An array of the distinct values.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`drop ...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on the </reference/command/drop>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropIndexes ...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on the </reference/command/dropIndexes>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -37,6 +37,13 @@ An array or object with the result document of the :manual:`dropIndexes ...@@ -37,6 +37,13 @@ An array or object with the result document of the :manual:`dropIndexes
</reference/command/dropIndexes>` command. The return type will depend on the </reference/command/dropIndexes>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -34,6 +34,13 @@ Return Values ...@@ -34,6 +34,13 @@ Return Values
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object. A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -36,6 +36,13 @@ An array or object for the :term:`first document <natural order>` document that ...@@ -36,6 +36,13 @@ An array or object for the :term:`first document <natural order>` document that
matched the query, or ``null`` if no document matched the query. The return type matched the query, or ``null`` if no document matched the query. The return type
will depend on the ``typeMap`` option. will depend on the ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -37,6 +37,14 @@ Return Values ...@@ -37,6 +37,14 @@ Return Values
An object for the document that was deleted, or ``null`` if no document matched An object for the document that was deleted, or ``null`` if no document matched
the query. the query.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -38,6 +38,14 @@ An object for either the original or the replaced document, depending on the ...@@ -38,6 +38,14 @@ An object for either the original or the replaced document, depending on the
specified value of the ``returnDocument`` option. By default, the original specified value of the ``returnDocument`` option. By default, the original
document is returned. If no document matched the query, ``null`` is returned. document is returned. If no document matched the query, ``null`` is returned.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -38,6 +38,14 @@ An object for either the original or the updated document, depending on the ...@@ -38,6 +38,14 @@ An object for either the original or the updated document, depending on the
specified value of the ``returnDocument`` option. By default, the original specified value of the ``returnDocument`` option. By default, the original
document is returned. If no document matched the query, ``null`` is returned. document is returned. If no document matched the query, ``null`` is returned.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -35,6 +35,12 @@ Return Values ...@@ -35,6 +35,12 @@ Return Values
A :phpclass:`MongoDB\\InsertManyResult` object, which encapsulates a A :phpclass:`MongoDB\\InsertManyResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -35,6 +35,12 @@ Return Values ...@@ -35,6 +35,12 @@ Return Values
A :phpclass:`MongoDB\\InsertOneResult` object, which encapsulates a A :phpclass:`MongoDB\\InsertOneResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -35,6 +35,12 @@ Return Values ...@@ -35,6 +35,12 @@ Return Values
A traversable :phpclass:`MongoDB\\Model\\IndexInfoIterator`, which contains a A traversable :phpclass:`MongoDB\\Model\\IndexInfoIterator`, which contains a
:phpclass:`MongoDB\\Model\\IndexInfo` object for each index for the collection. :phpclass:`MongoDB\\Model\\IndexInfo` object for each index for the collection.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -37,6 +37,13 @@ Return Values ...@@ -37,6 +37,13 @@ Return Values
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -35,6 +35,13 @@ Return Values ...@@ -35,6 +35,13 @@ Return Values
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -37,6 +37,13 @@ Return Values ...@@ -37,6 +37,13 @@ Return Values
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object. :php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Examples Examples
-------- --------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\Collection` object. A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Example Example
------- -------
......
...@@ -29,6 +29,11 @@ Definition ...@@ -29,6 +29,11 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-construct-option.rst .. include:: /includes/apiargs/MongoDBCollection-method-construct-option.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -34,6 +34,12 @@ Return Values ...@@ -34,6 +34,12 @@ Return Values
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object. A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -53,6 +53,13 @@ Return Values ...@@ -53,6 +53,13 @@ Return Values
An array or object with the result document of the :manual:`create An array or object with the result document of the :manual:`create
</reference/command/create>` command. </reference/command/create>` command.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropDatabase ...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on the </reference/command/dropDatabase>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`drop ...@@ -36,6 +36,13 @@ An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on the </reference/command/drop>` command. The return type will depend on the
``typeMap`` option. ``typeMap`` option.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example Example
------- -------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\Collection` object. A :phpclass:`MongoDB\\Collection` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\GridFS\\Bucket` object. A :phpclass:`MongoDB\\GridFS\\Bucket` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -34,6 +34,11 @@ Return Values ...@@ -34,6 +34,11 @@ Return Values
A :phpclass:`MongoDB\\Database` object. A :phpclass:`MongoDB\\Database` object.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Example Example
------- -------
......
...@@ -29,6 +29,11 @@ Definition ...@@ -29,6 +29,11 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-invalidargumentexception.rst
Behavior Behavior
-------- --------
......
...@@ -4,7 +4,11 @@ namespace MongoDB; ...@@ -4,7 +4,11 @@ namespace MongoDB;
use MongoDB\Driver\Manager; use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Driver\Exception\InvalidArgumentException as DriverInvalidArgumentException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\DatabaseInfoIterator; use MongoDB\Model\DatabaseInfoIterator;
use MongoDB\Operation\DropDatabase; use MongoDB\Operation\DropDatabase;
use MongoDB\Operation\ListDatabases; use MongoDB\Operation\ListDatabases;
...@@ -41,7 +45,9 @@ class Client ...@@ -41,7 +45,9 @@ class Client
* @param string $uri MongoDB connection string * @param string $uri MongoDB connection string
* @param array $uriOptions Additional connection string options * @param array $uriOptions Additional connection string options
* @param array $driverOptions Driver-specific options * @param array $driverOptions Driver-specific options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverInvalidArgumentException for parameter/option parsing errors in the driver
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function __construct($uri = 'mongodb://127.0.0.1/', array $uriOptions = [], array $driverOptions = []) public function __construct($uri = 'mongodb://127.0.0.1/', array $uriOptions = [], array $driverOptions = [])
{ {
...@@ -108,6 +114,9 @@ class Client ...@@ -108,6 +114,9 @@ class Client
* @param string $databaseName Database name * @param string $databaseName Database name
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are unsupported on the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function dropDatabase($databaseName, array $options = []) public function dropDatabase($databaseName, array $options = [])
{ {
...@@ -141,6 +150,9 @@ class Client ...@@ -141,6 +150,9 @@ class Client
* *
* @see ListDatabases::__construct() for supported options * @see ListDatabases::__construct() for supported options
* @return DatabaseInfoIterator * @return DatabaseInfoIterator
* @throws UnexpectedValueException if the command response was malformed
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function listDatabases(array $options = []) public function listDatabases(array $options = [])
{ {
...@@ -158,6 +170,7 @@ class Client ...@@ -158,6 +170,7 @@ class Client
* @param string $collectionName Name of the collection to select * @param string $collectionName Name of the collection to select
* @param array $options Collection constructor options * @param array $options Collection constructor options
* @return Collection * @return Collection
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function selectCollection($databaseName, $collectionName, array $options = []) public function selectCollection($databaseName, $collectionName, array $options = [])
{ {
...@@ -173,6 +186,7 @@ class Client ...@@ -173,6 +186,7 @@ class Client
* @param string $databaseName Name of the database to select * @param string $databaseName Name of the database to select
* @param array $options Database constructor options * @param array $options Database constructor options
* @return Database * @return Database
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function selectDatabase($databaseName, array $options = []) public function selectDatabase($databaseName, array $options = [])
{ {
......
...@@ -7,7 +7,10 @@ use MongoDB\Driver\Manager; ...@@ -7,7 +7,10 @@ use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\IndexInfoIterator; use MongoDB\Model\IndexInfoIterator;
use MongoDB\Operation\Aggregate; use MongoDB\Operation\Aggregate;
use MongoDB\Operation\BulkWrite; use MongoDB\Operation\BulkWrite;
...@@ -74,7 +77,7 @@ class Collection ...@@ -74,7 +77,7 @@ class Collection
* @param string $databaseName Database name * @param string $databaseName Database name
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Collection options * @param array $options Collection options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct(Manager $manager, $databaseName, $collectionName, array $options = []) public function __construct(Manager $manager, $databaseName, $collectionName, array $options = [])
{ {
...@@ -157,6 +160,10 @@ class Collection ...@@ -157,6 +160,10 @@ class Collection
* @param array $pipeline List of pipeline operations * @param array $pipeline List of pipeline operations
* @param array $options Command options * @param array $options Command options
* @return Traversable * @return Traversable
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function aggregate(array $pipeline, array $options = []) public function aggregate(array $pipeline, array $options = [])
{ {
...@@ -199,6 +206,9 @@ class Collection ...@@ -199,6 +206,9 @@ class Collection
* @param array[] $operations List of write operations * @param array[] $operations List of write operations
* @param array $options Command options * @param array $options Command options
* @return BulkWriteResult * @return BulkWriteResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function bulkWrite(array $operations, array $options = []) public function bulkWrite(array $operations, array $options = [])
{ {
...@@ -219,6 +229,10 @@ class Collection ...@@ -219,6 +229,10 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @return integer * @return integer
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function count($filter = [], array $options = []) public function count($filter = [], array $options = [])
{ {
...@@ -245,6 +259,9 @@ class Collection ...@@ -245,6 +259,9 @@ class Collection
* which denote order or an index type * which denote order or an index type
* @param array $options Index options * @param array $options Index options
* @return string The name of the created index * @return string The name of the created index
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function createIndex($key, array $options = []) public function createIndex($key, array $options = [])
{ {
...@@ -277,7 +294,9 @@ class Collection ...@@ -277,7 +294,9 @@ class Collection
* @param array[] $indexes List of index specifications * @param array[] $indexes List of index specifications
* @param array $options Command options * @param array $options Command options
* @return string[] The names of the created indexes * @return string[] The names of the created indexes
* @throws InvalidArgumentException if an index specification is invalid * @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function createIndexes(array $indexes, array $options = []) public function createIndexes(array $indexes, array $options = [])
{ {
...@@ -300,6 +319,9 @@ class Collection ...@@ -300,6 +319,9 @@ class Collection
* @param array|object $filter Query by which to delete documents * @param array|object $filter Query by which to delete documents
* @param array $options Command options * @param array $options Command options
* @return DeleteResult * @return DeleteResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function deleteMany($filter, array $options = []) public function deleteMany($filter, array $options = [])
{ {
...@@ -321,6 +343,9 @@ class Collection ...@@ -321,6 +343,9 @@ class Collection
* @param array|object $filter Query by which to delete documents * @param array|object $filter Query by which to delete documents
* @param array $options Command options * @param array $options Command options
* @return DeleteResult * @return DeleteResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function deleteOne($filter, array $options = []) public function deleteOne($filter, array $options = [])
{ {
...@@ -342,6 +367,10 @@ class Collection ...@@ -342,6 +367,10 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @return mixed[] * @return mixed[]
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function distinct($fieldName, $filter = [], array $options = []) public function distinct($fieldName, $filter = [], array $options = [])
{ {
...@@ -365,6 +394,9 @@ class Collection ...@@ -365,6 +394,9 @@ class Collection
* @see DropCollection::__construct() for supported options * @see DropCollection::__construct() for supported options
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function drop(array $options = []) public function drop(array $options = [])
{ {
...@@ -390,7 +422,9 @@ class Collection ...@@ -390,7 +422,9 @@ class Collection
* @param string $indexName Index name * @param string $indexName Index name
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws InvalidArgumentException if $indexName is an empty string or "*" * @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function dropIndex($indexName, array $options = []) public function dropIndex($indexName, array $options = [])
{ {
...@@ -421,6 +455,9 @@ class Collection ...@@ -421,6 +455,9 @@ class Collection
* @see DropIndexes::__construct() for supported options * @see DropIndexes::__construct() for supported options
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function dropIndexes(array $options = []) public function dropIndexes(array $options = [])
{ {
...@@ -447,6 +484,9 @@ class Collection ...@@ -447,6 +484,9 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Additional options * @param array $options Additional options
* @return Cursor * @return Cursor
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function find($filter = [], array $options = []) public function find($filter = [], array $options = [])
{ {
...@@ -476,6 +516,9 @@ class Collection ...@@ -476,6 +516,9 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Additional options * @param array $options Additional options
* @return array|object|null * @return array|object|null
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function findOne($filter = [], array $options = []) public function findOne($filter = [], array $options = [])
{ {
...@@ -510,6 +553,10 @@ class Collection ...@@ -510,6 +553,10 @@ class Collection
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @return object|null * @return object|null
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function findOneAndDelete($filter, array $options = []) public function findOneAndDelete($filter, array $options = [])
{ {
...@@ -542,6 +589,10 @@ class Collection ...@@ -542,6 +589,10 @@ class Collection
* @param array|object $replacement Replacement document * @param array|object $replacement Replacement document
* @param array $options Command options * @param array $options Command options
* @return object|null * @return object|null
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function findOneAndReplace($filter, $replacement, array $options = []) public function findOneAndReplace($filter, $replacement, array $options = [])
{ {
...@@ -574,6 +625,10 @@ class Collection ...@@ -574,6 +625,10 @@ class Collection
* @param array|object $update Update to apply to the matched document * @param array|object $update Update to apply to the matched document
* @param array $options Command options * @param array $options Command options
* @return object|null * @return object|null
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function findOneAndUpdate($filter, $update, array $options = []) public function findOneAndUpdate($filter, $update, array $options = [])
{ {
...@@ -637,6 +692,8 @@ class Collection ...@@ -637,6 +692,8 @@ class Collection
* @param array[]|object[] $documents The documents to insert * @param array[]|object[] $documents The documents to insert
* @param array $options Command options * @param array $options Command options
* @return InsertManyResult * @return InsertManyResult
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function insertMany(array $documents, array $options = []) public function insertMany(array $documents, array $options = [])
{ {
...@@ -658,6 +715,8 @@ class Collection ...@@ -658,6 +715,8 @@ class Collection
* @param array|object $document The document to insert * @param array|object $document The document to insert
* @param array $options Command options * @param array $options Command options
* @return InsertOneResult * @return InsertOneResult
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function insertOne($document, array $options = []) public function insertOne($document, array $options = [])
{ {
...@@ -676,6 +735,8 @@ class Collection ...@@ -676,6 +735,8 @@ class Collection
* *
* @see ListIndexes::__construct() for supported options * @see ListIndexes::__construct() for supported options
* @return IndexInfoIterator * @return IndexInfoIterator
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function listIndexes(array $options = []) public function listIndexes(array $options = [])
{ {
...@@ -694,6 +755,9 @@ class Collection ...@@ -694,6 +755,9 @@ class Collection
* @param array|object $replacement Replacement document * @param array|object $replacement Replacement document
* @param array $options Command options * @param array $options Command options
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function replaceOne($filter, $replacement, array $options = []) public function replaceOne($filter, $replacement, array $options = [])
{ {
...@@ -716,6 +780,9 @@ class Collection ...@@ -716,6 +780,9 @@ class Collection
* @param array|object $update Update to apply to the matched documents * @param array|object $update Update to apply to the matched documents
* @param array $options Command options * @param array $options Command options
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function updateMany($filter, $update, array $options = []) public function updateMany($filter, $update, array $options = [])
{ {
...@@ -738,6 +805,9 @@ class Collection ...@@ -738,6 +805,9 @@ class Collection
* @param array|object $update Update to apply to the matched document * @param array|object $update Update to apply to the matched document
* @param array $options Command options * @param array $options Command options
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function updateOne($filter, $update, array $options = []) public function updateOne($filter, $update, array $options = [])
{ {
...@@ -757,6 +827,7 @@ class Collection ...@@ -757,6 +827,7 @@ class Collection
* @see Collection::__construct() for supported options * @see Collection::__construct() for supported options
* @param array $options Collection constructor options * @param array $options Collection constructor options
* @return Collection * @return Collection
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function withOptions(array $options = []) public function withOptions(array $options = [])
{ {
......
...@@ -8,7 +8,9 @@ use MongoDB\Driver\Manager; ...@@ -8,7 +8,9 @@ use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException;
use MongoDB\GridFS\Bucket; use MongoDB\GridFS\Bucket;
use MongoDB\Model\CollectionInfoIterator; use MongoDB\Model\CollectionInfoIterator;
use MongoDB\Operation\CreateCollection; use MongoDB\Operation\CreateCollection;
...@@ -58,7 +60,7 @@ class Database ...@@ -58,7 +60,7 @@ class Database
* @param Manager $manager Manager instance from the driver * @param Manager $manager Manager instance from the driver
* @param string $databaseName Database name * @param string $databaseName Database name
* @param array $options Database options * @param array $options Database options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct(Manager $manager, $databaseName, array $options = []) public function __construct(Manager $manager, $databaseName, array $options = [])
{ {
...@@ -142,7 +144,8 @@ class Database ...@@ -142,7 +144,8 @@ class Database
* @param array|object $command Command document * @param array|object $command Command document
* @param array $options Options for command execution * @param array $options Options for command execution
* @return Cursor * @return Cursor
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function command($command, array $options = []) public function command($command, array $options = [])
{ {
...@@ -167,6 +170,9 @@ class Database ...@@ -167,6 +170,9 @@ class Database
* @param string $collectionName * @param string $collectionName
* @param array $options * @param array $options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are not supported by the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function createCollection($collectionName, array $options = []) public function createCollection($collectionName, array $options = [])
{ {
...@@ -191,6 +197,9 @@ class Database ...@@ -191,6 +197,9 @@ class Database
* @see DropDatabase::__construct() for supported options * @see DropDatabase::__construct() for supported options
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are unsupported on the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function drop(array $options = []) public function drop(array $options = [])
{ {
...@@ -216,6 +225,9 @@ class Database ...@@ -216,6 +225,9 @@ class Database
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Additional options * @param array $options Additional options
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if options are unsupported on the selected server
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function dropCollection($collectionName, array $options = []) public function dropCollection($collectionName, array $options = [])
{ {
...@@ -260,6 +272,8 @@ class Database ...@@ -260,6 +272,8 @@ class Database
* @see ListCollections::__construct() for supported options * @see ListCollections::__construct() for supported options
* @param array $options * @param array $options
* @return CollectionInfoIterator * @return CollectionInfoIterator
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function listCollections(array $options = []) public function listCollections(array $options = [])
{ {
...@@ -276,6 +290,7 @@ class Database ...@@ -276,6 +290,7 @@ class Database
* @param string $collectionName Name of the collection to select * @param string $collectionName Name of the collection to select
* @param array $options Collection constructor options * @param array $options Collection constructor options
* @return Collection * @return Collection
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function selectCollection($collectionName, array $options = []) public function selectCollection($collectionName, array $options = [])
{ {
...@@ -295,6 +310,7 @@ class Database ...@@ -295,6 +310,7 @@ class Database
* @see Bucket::__construct() for supported options * @see Bucket::__construct() for supported options
* @param array $options Bucket constructor options * @param array $options Bucket constructor options
* @return Bucket * @return Bucket
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function selectGridFSBucket(array $options = []) public function selectGridFSBucket(array $options = [])
{ {
...@@ -313,6 +329,7 @@ class Database ...@@ -313,6 +329,7 @@ class Database
* @see Database::__construct() for supported options * @see Database::__construct() for supported options
* @param array $options Database constructor options * @param array $options Database constructor options
* @return Database * @return Database
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function withOptions(array $options = []) public function withOptions(array $options = [])
{ {
......
...@@ -7,6 +7,7 @@ use MongoDB\Driver\ReadConcern; ...@@ -7,6 +7,7 @@ use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException; use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -93,7 +94,7 @@ class Aggregate implements Executable ...@@ -93,7 +94,7 @@ class Aggregate implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $pipeline List of pipeline operations * @param array $pipeline List of pipeline operations
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $pipeline, array $options = []) public function __construct($databaseName, $collectionName, array $pipeline, array $options = [])
{ {
...@@ -182,6 +183,7 @@ class Aggregate implements Executable ...@@ -182,6 +183,7 @@ class Aggregate implements Executable
* @return Traversable * @return Traversable
* @throws UnexpectedValueException if the command response was malformed * @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation or write concern is used and unsupported * @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\BulkWriteResult; ...@@ -6,6 +6,7 @@ use MongoDB\BulkWriteResult;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -83,7 +84,7 @@ class BulkWrite implements Executable ...@@ -83,7 +84,7 @@ class BulkWrite implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array[] $operations List of write operations * @param array[] $operations List of write operations
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $operations, array $options = []) public function __construct($databaseName, $collectionName, array $operations, array $options = [])
{ {
...@@ -260,6 +261,7 @@ class BulkWrite implements Executable ...@@ -260,6 +261,7 @@ class BulkWrite implements Executable
* @param Server $server * @param Server $server
* @return BulkWriteResult * @return BulkWriteResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command; ...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException; use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -59,7 +60,7 @@ class Count implements Executable ...@@ -59,7 +60,7 @@ class Count implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter = [], array $options = []) public function __construct($databaseName, $collectionName, $filter = [], array $options = [])
{ {
...@@ -115,6 +116,7 @@ class Count implements Executable ...@@ -115,6 +116,7 @@ class Count implements Executable
* @return integer * @return integer
* @throws UnexpectedValueException if the command response was malformed * @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,6 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,6 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -81,7 +82,7 @@ class CreateCollection implements Executable ...@@ -81,7 +82,7 @@ class CreateCollection implements Executable
* @param string $databaseName Database name * @param string $databaseName Database name
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $options = []) public function __construct($databaseName, $collectionName, array $options = [])
{ {
...@@ -153,6 +154,7 @@ class CreateCollection implements Executable ...@@ -153,6 +154,7 @@ class CreateCollection implements Executable
* @param Server $server * @param Server $server
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if collation or write concern is used and unsupported * @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command; ...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\IndexInput; use MongoDB\Model\IndexInput;
...@@ -44,7 +45,7 @@ class CreateIndexes implements Executable ...@@ -44,7 +45,7 @@ class CreateIndexes implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array[] $indexes List of index specifications * @param array[] $indexes List of index specifications
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $indexes, array $options = []) public function __construct($databaseName, $collectionName, array $indexes, array $options = [])
{ {
...@@ -95,6 +96,7 @@ class CreateIndexes implements Executable ...@@ -95,6 +96,7 @@ class CreateIndexes implements Executable
* @param Server $server * @param Server $server
* @return string[] The names of the created indexes * @return string[] The names of the created indexes
* @throws UnsupportedException if collation or write concern is used and unsupported * @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
...@@ -120,6 +122,7 @@ class CreateIndexes implements Executable ...@@ -120,6 +122,7 @@ class CreateIndexes implements Executable
* command. * command.
* *
* @param Server $server * @param Server $server
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeCommand(Server $server) private function executeCommand(Server $server)
{ {
...@@ -140,6 +143,7 @@ class CreateIndexes implements Executable ...@@ -140,6 +143,7 @@ class CreateIndexes implements Executable
* "system.indexes" collection (MongoDB <2.6). * "system.indexes" collection (MongoDB <2.6).
* *
* @param Server $server * @param Server $server
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeLegacy(Server $server) private function executeLegacy(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command; ...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use MongoDB\Driver\Cursor; use MongoDB\Driver\Cursor;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
/** /**
...@@ -37,7 +38,7 @@ class DatabaseCommand implements Executable ...@@ -37,7 +38,7 @@ class DatabaseCommand implements Executable
* @param string $databaseName Database name * @param string $databaseName Database name
* @param array|object $command Command document * @param array|object $command Command document
* @param array $options Options for command execution * @param array $options Options for command execution
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $command, array $options = []) public function __construct($databaseName, $command, array $options = [])
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\DeleteResult; ...@@ -6,6 +6,7 @@ use MongoDB\DeleteResult;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -47,7 +48,7 @@ class Delete implements Executable ...@@ -47,7 +48,7 @@ class Delete implements Executable
* delete. Must be 0 or 1, for all or a * delete. Must be 0 or 1, for all or a
* single document, respectively. * single document, respectively.
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $limit, array $options = []) public function __construct($databaseName, $collectionName, $filter, $limit, array $options = [])
{ {
...@@ -80,6 +81,7 @@ class Delete implements Executable ...@@ -80,6 +81,7 @@ class Delete implements Executable
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return DeleteResult * @return DeleteResult
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\DeleteResult; use MongoDB\DeleteResult;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -34,7 +35,7 @@ class DeleteMany implements Executable ...@@ -34,7 +35,7 @@ class DeleteMany implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to delete documents * @param array|object $filter Query by which to delete documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, array $options = []) public function __construct($databaseName, $collectionName, $filter, array $options = [])
{ {
...@@ -48,6 +49,7 @@ class DeleteMany implements Executable ...@@ -48,6 +49,7 @@ class DeleteMany implements Executable
* @param Server $server * @param Server $server
* @return DeleteResult * @return DeleteResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\DeleteResult; use MongoDB\DeleteResult;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -34,7 +35,7 @@ class DeleteOne implements Executable ...@@ -34,7 +35,7 @@ class DeleteOne implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to delete documents * @param array|object $filter Query by which to delete documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, array $options = []) public function __construct($databaseName, $collectionName, $filter, array $options = [])
{ {
...@@ -48,6 +49,7 @@ class DeleteOne implements Executable ...@@ -48,6 +49,7 @@ class DeleteOne implements Executable
* @param Server $server * @param Server $server
* @return DeleteResult * @return DeleteResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command; ...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException; use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -53,7 +54,7 @@ class Distinct implements Executable ...@@ -53,7 +54,7 @@ class Distinct implements Executable
* @param string $fieldName Field for which to return distinct values * @param string $fieldName Field for which to return distinct values
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $fieldName, $filter = [], array $options = []) public function __construct($databaseName, $collectionName, $fieldName, $filter = [], array $options = [])
{ {
...@@ -92,6 +93,7 @@ class Distinct implements Executable ...@@ -92,6 +93,7 @@ class Distinct implements Executable
* @return mixed[] * @return mixed[]
* @throws UnexpectedValueException if the command response was malformed * @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,7 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,7 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException; use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -42,6 +42,7 @@ class DropCollection implements Executable ...@@ -42,6 +42,7 @@ class DropCollection implements Executable
* @param string $databaseName Database name * @param string $databaseName Database name
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $options = []) public function __construct($databaseName, $collectionName, array $options = [])
{ {
...@@ -65,6 +66,7 @@ class DropCollection implements Executable ...@@ -65,6 +66,7 @@ class DropCollection implements Executable
* @param Server $server * @param Server $server
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if writeConcern is used and unsupported * @throws UnsupportedException if writeConcern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
...@@ -74,7 +76,7 @@ class DropCollection implements Executable ...@@ -74,7 +76,7 @@ class DropCollection implements Executable
try { try {
$cursor = $server->executeCommand($this->databaseName, $this->createCommand()); $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
} catch (RuntimeException $e) { } catch (DriverRuntimeException $e) {
/* The server may return an error if the collection does not exist. /* The server may return an error if the collection does not exist.
* Check for an error message (unfortunately, there isn't a code) * Check for an error message (unfortunately, there isn't a code)
* and NOP instead of throwing. * and NOP instead of throwing.
......
...@@ -5,6 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,6 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -38,6 +39,7 @@ class DropDatabase implements Executable ...@@ -38,6 +39,7 @@ class DropDatabase implements Executable
* *
* @param string $databaseName Database name * @param string $databaseName Database name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, array $options = []) public function __construct($databaseName, array $options = [])
{ {
...@@ -60,6 +62,7 @@ class DropDatabase implements Executable ...@@ -60,6 +62,7 @@ class DropDatabase implements Executable
* @param Server $server * @param Server $server
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if writeConcern is used and unsupported * @throws UnsupportedException if writeConcern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,6 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,6 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -41,7 +42,7 @@ class DropIndexes implements Executable ...@@ -41,7 +42,7 @@ class DropIndexes implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param string $indexName Index name (use "*" to drop all indexes) * @param string $indexName Index name (use "*" to drop all indexes)
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $indexName, array $options = []) public function __construct($databaseName, $collectionName, $indexName, array $options = [])
{ {
...@@ -72,6 +73,7 @@ class DropIndexes implements Executable ...@@ -72,6 +73,7 @@ class DropIndexes implements Executable
* @param Server $server * @param Server $server
* @return array|object Command result document * @return array|object Command result document
* @throws UnsupportedException if writeConcern is used and unsupported * @throws UnsupportedException if writeConcern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -7,6 +7,7 @@ use MongoDB\Driver\Query; ...@@ -7,6 +7,7 @@ use MongoDB\Driver\Query;
use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -92,7 +93,7 @@ class Find implements Executable ...@@ -92,7 +93,7 @@ class Find implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, array $options = []) public function __construct($databaseName, $collectionName, $filter, array $options = [])
{ {
...@@ -185,6 +186,7 @@ class Find implements Executable ...@@ -185,6 +186,7 @@ class Find implements Executable
* @param Server $server * @param Server $server
* @return Cursor * @return Cursor
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,6 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,6 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException; use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -73,7 +74,7 @@ class FindAndModify implements Executable ...@@ -73,7 +74,7 @@ class FindAndModify implements Executable
* @param string $databaseName Database name * @param string $databaseName Database name
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $options) public function __construct($databaseName, $collectionName, array $options)
{ {
...@@ -144,6 +145,7 @@ class FindAndModify implements Executable ...@@ -144,6 +145,7 @@ class FindAndModify implements Executable
* @return object|null * @return object|null
* @throws UnexpectedValueException if the command response was malformed * @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace MongoDB\Operation; namespace MongoDB\Operation;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -61,7 +62,7 @@ class FindOne implements Executable ...@@ -61,7 +62,7 @@ class FindOne implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, array $options = []) public function __construct($databaseName, $collectionName, $filter, array $options = [])
{ {
...@@ -82,6 +83,7 @@ class FindOne implements Executable ...@@ -82,6 +83,7 @@ class FindOne implements Executable
* @param Server $server * @param Server $server
* @return array|object|null * @return array|object|null
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace MongoDB\Operation; namespace MongoDB\Operation;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -43,7 +44,7 @@ class FindOneAndDelete implements Executable ...@@ -43,7 +44,7 @@ class FindOneAndDelete implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, array $options = []) public function __construct($databaseName, $collectionName, $filter, array $options = [])
{ {
...@@ -75,6 +76,7 @@ class FindOneAndDelete implements Executable ...@@ -75,6 +76,7 @@ class FindOneAndDelete implements Executable
* @param Server $server * @param Server $server
* @return object|null * @return object|null
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace MongoDB\Operation; namespace MongoDB\Operation;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -59,7 +60,7 @@ class FindOneAndReplace implements Executable ...@@ -59,7 +60,7 @@ class FindOneAndReplace implements Executable
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document * @param array|object $replacement Replacement document
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $replacement, array $options = []) public function __construct($databaseName, $collectionName, $filter, $replacement, array $options = [])
{ {
...@@ -115,6 +116,7 @@ class FindOneAndReplace implements Executable ...@@ -115,6 +116,7 @@ class FindOneAndReplace implements Executable
* @param Server $server * @param Server $server
* @return object|null * @return object|null
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace MongoDB\Operation; namespace MongoDB\Operation;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -59,7 +60,7 @@ class FindOneAndUpdate implements Executable ...@@ -59,7 +60,7 @@ class FindOneAndUpdate implements Executable
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document * @param array|object $update Update to apply to the matched document
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $update, array $options = []) public function __construct($databaseName, $collectionName, $filter, $update, array $options = [])
{ {
...@@ -115,6 +116,7 @@ class FindOneAndUpdate implements Executable ...@@ -115,6 +116,7 @@ class FindOneAndUpdate implements Executable
* @param Server $server * @param Server $server
* @return object|null * @return object|null
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\InsertManyResult; ...@@ -6,6 +6,7 @@ use MongoDB\InsertManyResult;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
/** /**
...@@ -42,7 +43,7 @@ class InsertMany implements Executable ...@@ -42,7 +43,7 @@ class InsertMany implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array[]|object[] $documents List of documents to insert * @param array[]|object[] $documents List of documents to insert
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $documents, array $options = []) public function __construct($databaseName, $collectionName, array $documents, array $options = [])
{ {
...@@ -90,6 +91,7 @@ class InsertMany implements Executable ...@@ -90,6 +91,7 @@ class InsertMany implements Executable
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return InsertManyResult * @return InsertManyResult
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\InsertOneResult; ...@@ -6,6 +6,7 @@ use MongoDB\InsertOneResult;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
/** /**
...@@ -38,7 +39,7 @@ class InsertOne implements Executable ...@@ -38,7 +39,7 @@ class InsertOne implements Executable
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array|object $document Document to insert * @param array|object $document Document to insert
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $document, array $options = []) public function __construct($databaseName, $collectionName, $document, array $options = [])
{ {
...@@ -66,6 +67,7 @@ class InsertOne implements Executable ...@@ -66,6 +67,7 @@ class InsertOne implements Executable
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return InsertOneResult * @return InsertOneResult
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,6 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,6 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Query; use MongoDB\Driver\Query;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\CollectionInfoCommandIterator; use MongoDB\Model\CollectionInfoCommandIterator;
use MongoDB\Model\CollectionInfoIterator; use MongoDB\Model\CollectionInfoIterator;
...@@ -36,7 +37,7 @@ class ListCollections implements Executable ...@@ -36,7 +37,7 @@ class ListCollections implements Executable
* *
* @param string $databaseName Database name * @param string $databaseName Database name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, array $options = []) public function __construct($databaseName, array $options = [])
{ {
...@@ -58,6 +59,8 @@ class ListCollections implements Executable ...@@ -58,6 +59,8 @@ class ListCollections implements Executable
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return CollectionInfoIterator * @return CollectionInfoIterator
* @throws InvalidArgumentException if filter.name is not a string for legacy execution
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
...@@ -72,6 +75,7 @@ class ListCollections implements Executable ...@@ -72,6 +75,7 @@ class ListCollections implements Executable
* *
* @param Server $server * @param Server $server
* @return CollectionInfoCommandIterator * @return CollectionInfoCommandIterator
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeCommand(Server $server) private function executeCommand(Server $server)
{ {
...@@ -97,7 +101,8 @@ class ListCollections implements Executable ...@@ -97,7 +101,8 @@ class ListCollections implements Executable
* *
* @param Server $server * @param Server $server
* @return CollectionInfoLegacyIterator * @return CollectionInfoLegacyIterator
* @throws InvalidArgumentException if filter.name is not a string. * @throws InvalidArgumentException if filter.name is not a string
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeLegacy(Server $server) private function executeLegacy(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException; use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Model\DatabaseInfoIterator; use MongoDB\Model\DatabaseInfoIterator;
...@@ -29,7 +30,7 @@ class ListDatabases implements Executable ...@@ -29,7 +30,7 @@ class ListDatabases implements Executable
* run. * run.
* *
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct(array $options = []) public function __construct(array $options = [])
{ {
...@@ -47,6 +48,7 @@ class ListDatabases implements Executable ...@@ -47,6 +48,7 @@ class ListDatabases implements Executable
* @param Server $server * @param Server $server
* @return DatabaseInfoIterator * @return DatabaseInfoIterator
* @throws UnexpectedValueException if the command response was malformed * @throws UnexpectedValueException if the command response was malformed
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -5,7 +5,7 @@ namespace MongoDB\Operation; ...@@ -5,7 +5,7 @@ namespace MongoDB\Operation;
use MongoDB\Driver\Command; use MongoDB\Driver\Command;
use MongoDB\Driver\Query; use MongoDB\Driver\Query;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException; use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\IndexInfoIterator; use MongoDB\Model\IndexInfoIterator;
use MongoDB\Model\IndexInfoIteratorIterator; use MongoDB\Model\IndexInfoIteratorIterator;
...@@ -39,7 +39,7 @@ class ListIndexes implements Executable ...@@ -39,7 +39,7 @@ class ListIndexes implements Executable
* @param string $databaseName Database name * @param string $databaseName Database name
* @param string $collectionName Collection name * @param string $collectionName Collection name
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, array $options = []) public function __construct($databaseName, $collectionName, array $options = [])
{ {
...@@ -58,6 +58,7 @@ class ListIndexes implements Executable ...@@ -58,6 +58,7 @@ class ListIndexes implements Executable
* @see Executable::execute() * @see Executable::execute()
* @param Server $server * @param Server $server
* @return IndexInfoIterator * @return IndexInfoIterator
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
...@@ -72,6 +73,7 @@ class ListIndexes implements Executable ...@@ -72,6 +73,7 @@ class ListIndexes implements Executable
* *
* @param Server $server * @param Server $server
* @return IndexInfoIteratorIterator * @return IndexInfoIteratorIterator
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeCommand(Server $server) private function executeCommand(Server $server)
{ {
...@@ -83,7 +85,7 @@ class ListIndexes implements Executable ...@@ -83,7 +85,7 @@ class ListIndexes implements Executable
try { try {
$cursor = $server->executeCommand($this->databaseName, new Command($cmd)); $cursor = $server->executeCommand($this->databaseName, new Command($cmd));
} catch (RuntimeException $e) { } catch (DriverRuntimeException $e) {
/* The server may return an error if the collection does not exist. /* The server may return an error if the collection does not exist.
* Check for possible error codes (see: SERVER-20463) and return an * Check for possible error codes (see: SERVER-20463) and return an
* empty iterator instead of throwing. * empty iterator instead of throwing.
...@@ -106,6 +108,7 @@ class ListIndexes implements Executable ...@@ -106,6 +108,7 @@ class ListIndexes implements Executable
* *
* @param Server $server * @param Server $server
* @return IndexInfoIteratorIterator * @return IndexInfoIteratorIterator
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
private function executeLegacy(Server $server) private function executeLegacy(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\UpdateResult; use MongoDB\UpdateResult;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -41,7 +42,7 @@ class ReplaceOne implements Executable ...@@ -41,7 +42,7 @@ class ReplaceOne implements Executable
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document * @param array|object $replacement Replacement document
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $replacement, array $options = []) public function __construct($databaseName, $collectionName, $filter, $replacement, array $options = [])
{ {
...@@ -69,6 +70,7 @@ class ReplaceOne implements Executable ...@@ -69,6 +70,7 @@ class ReplaceOne implements Executable
* @param Server $server * @param Server $server
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -6,6 +6,7 @@ use MongoDB\UpdateResult; ...@@ -6,6 +6,7 @@ use MongoDB\UpdateResult;
use MongoDB\Driver\BulkWrite as Bulk; use MongoDB\Driver\BulkWrite as Bulk;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -57,7 +58,7 @@ class Update implements Executable ...@@ -57,7 +58,7 @@ class Update implements Executable
* @param array|object $update Update to apply to the matched * @param array|object $update Update to apply to the matched
* document(s) or a replacement document * document(s) or a replacement document
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $update, array $options = []) public function __construct($databaseName, $collectionName, $filter, $update, array $options = [])
{ {
...@@ -112,6 +113,7 @@ class Update implements Executable ...@@ -112,6 +113,7 @@ class Update implements Executable
* @param Server $server * @param Server $server
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\UpdateResult; use MongoDB\UpdateResult;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -41,7 +42,7 @@ class UpdateMany implements Executable ...@@ -41,7 +42,7 @@ class UpdateMany implements Executable
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched documents * @param array|object $update Update to apply to the matched documents
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $update, array $options = []) public function __construct($databaseName, $collectionName, $filter, $update, array $options = [])
{ {
...@@ -69,6 +70,7 @@ class UpdateMany implements Executable ...@@ -69,6 +70,7 @@ class UpdateMany implements Executable
* @param Server $server * @param Server $server
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
...@@ -4,6 +4,7 @@ namespace MongoDB\Operation; ...@@ -4,6 +4,7 @@ namespace MongoDB\Operation;
use MongoDB\UpdateResult; use MongoDB\UpdateResult;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnsupportedException; use MongoDB\Exception\UnsupportedException;
...@@ -41,7 +42,7 @@ class UpdateOne implements Executable ...@@ -41,7 +42,7 @@ class UpdateOne implements Executable
* @param array|object $filter Query by which to filter documents * @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document * @param array|object $update Update to apply to the matched document
* @param array $options Command options * @param array $options Command options
* @throws InvalidArgumentException * @throws InvalidArgumentException for parameter/option parsing errors
*/ */
public function __construct($databaseName, $collectionName, $filter, $update, array $options = []) public function __construct($databaseName, $collectionName, $filter, $update, array $options = [])
{ {
...@@ -69,6 +70,7 @@ class UpdateOne implements Executable ...@@ -69,6 +70,7 @@ class UpdateOne implements Executable
* @param Server $server * @param Server $server
* @return UpdateResult * @return UpdateResult
* @throws UnsupportedException if collation is used and unsupported * @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/ */
public function execute(Server $server) public function execute(Server $server)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment