diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md
index 8dabbdd59..8b3562013 100644
--- a/UPGRADE-2.0.md
+++ b/UPGRADE-2.0.md
@@ -3,6 +3,25 @@ UPGRADE FROM 1.x to 2.0
* Classes in the namespace `MongoDB\Operation\` are `final`.
* All methods in interfaces and classes now define a return type.
+ * The `MongoDB\ChangeStream::CURSOR_NOT_FOUND` constant is now private.
+ * The `MongoDB\Operation\Watch::FULL_DOCUMENT_DEFAULT` constant has been
+ removed.
+ * The `getNamespace` and `isGeoHaystack` methods have been removed from the
+ `MongoDB\Model\IndexInfo` class.
+ * The `maxScan`, `modifiers`, `oplogReplay`, and `snapshot` options for `find`
+ and `findOne` operations have been removed.
+ * The `MongoDB\Collection::mapReduce` method has been removed. Use
+ [aggregation pipeline](https://www.mongodb.com/docs/manual/reference/map-reduce-to-aggregation-pipeline/)
+ instead.
+ * The following classes and interfaces have been removed without replacement:
+ * `MongoDB\MapReduceResult`
+ * `MongoDB\Model\CollectionInfoCommandIterator`
+ * `MongoDB\Model\CollectionInfoIterator`
+ * `MongoDB\Model\DatabaseInfoIterator`
+ * `MongoDB\Model\DatabaseInfoLegacyIterator`
+ * `MongoDB\Model\IndexInfoIterator`
+ * `MongoDB\Model\IndexInfoIteratorIterator`
+ * `MongoDB\Operation\Executable`
GridFS
------
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 5ea414eb3..541a5380f 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -179,18 +179,7 @@
count($queriesOrArrayOfQueries[0]) > 0]]>
-
-
-
-
-
-
-
-
-
- ]]>
-
@@ -198,9 +187,6 @@
-
- ]]>
-
@@ -232,19 +218,10 @@
-
-
-
-
- ]]>
-
-
- ]]>
-
@@ -271,19 +248,10 @@
-
-
-
-
- ]]>
-
-
- ]]>
-
@@ -388,34 +356,6 @@
current()]]>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- databases)]]>
-
-
-
- databases)]]>
-
-
-
-
-
-
-
index]]>
@@ -713,11 +653,7 @@
options['codec']]]>
options['typeMap']]]>
-
-
-
-
@@ -802,64 +738,11 @@
-
-
-
-
-
- ]]>
-
-
- ]]>
-
-
-
-
-
-
-
- ]]>
-
-
- ]]>
-
-
-
-
- databaseName . '.' . $this->collectionName)]]>
-
-
-
-
-
-
- ]]>
-
-
-
-
-
-
- ]]>
-
-
-
-
- result->collection]]>
- result->db]]>
- options['typeMap']]]>
-
-
-
-
-
-
-
diff --git a/src/ChangeStream.php b/src/ChangeStream.php
index a1a732666..c48cd1483 100644
--- a/src/ChangeStream.php
+++ b/src/ChangeStream.php
@@ -43,11 +43,7 @@
*/
class ChangeStream implements Iterator
{
- /**
- * @deprecated 1.4
- * @todo make this constant private in 2.0 (see: PHPLIB-360)
- */
- public const CURSOR_NOT_FOUND = 43;
+ private const CURSOR_NOT_FOUND = 43;
private const RESUMABLE_ERROR_CODES = [
6, // HostUnreachable
diff --git a/src/Client.php b/src/Client.php
index 00a1a6ed3..38803fe52 100644
--- a/src/Client.php
+++ b/src/Client.php
@@ -39,7 +39,6 @@
use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Model\DatabaseInfo;
-use MongoDB\Model\DatabaseInfoIterator;
use MongoDB\Operation\DropDatabase;
use MongoDB\Operation\ListDatabaseNames;
use MongoDB\Operation\ListDatabases;
@@ -284,6 +283,7 @@ public function getWriteConcern(): WriteConcern
* List database names.
*
* @see ListDatabaseNames::__construct() for supported options
+ * @return Iterator
* @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)
@@ -305,7 +305,7 @@ public function listDatabaseNames(array $options = []): Iterator
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
- public function listDatabases(array $options = []): DatabaseInfoIterator
+ public function listDatabases(array $options = []): Iterator
{
$operation = new ListDatabases($options);
$server = select_server($this->manager, $options);
diff --git a/src/Collection.php b/src/Collection.php
index ec87cb928..88606e449 100644
--- a/src/Collection.php
+++ b/src/Collection.php
@@ -20,7 +20,6 @@
use Countable;
use Iterator;
use MongoDB\BSON\Document;
-use MongoDB\BSON\JavascriptInterface;
use MongoDB\BSON\PackedArray;
use MongoDB\Builder\BuilderEncoder;
use MongoDB\Builder\Pipeline;
@@ -38,7 +37,6 @@
use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Model\IndexInfo;
-use MongoDB\Model\IndexInfoIterator;
use MongoDB\Operation\Aggregate;
use MongoDB\Operation\BulkWrite;
use MongoDB\Operation\Count;
@@ -64,7 +62,6 @@
use MongoDB\Operation\InsertOne;
use MongoDB\Operation\ListIndexes;
use MongoDB\Operation\ListSearchIndexes;
-use MongoDB\Operation\MapReduce;
use MongoDB\Operation\RenameCollection;
use MongoDB\Operation\ReplaceOne;
use MongoDB\Operation\UpdateMany;
@@ -78,11 +75,7 @@
use function array_key_exists;
use function current;
use function is_array;
-use function sprintf;
use function strlen;
-use function trigger_error;
-
-use const E_USER_DEPRECATED;
class Collection
{
@@ -884,7 +877,7 @@ public function insertOne(array|object $document, array $options = []): InsertOn
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
- public function listIndexes(array $options = []): IndexInfoIterator
+ public function listIndexes(array $options = []): Iterator
{
$operation = new ListIndexes($this->databaseName, $this->collectionName, $options);
@@ -909,48 +902,6 @@ public function listSearchIndexes(array $options = []): Iterator
return $operation->execute($server);
}
- /**
- * Executes a map-reduce aggregation on the collection.
- *
- * @see MapReduce::__construct() for supported options
- * @see https://mongodb.com/docs/manual/reference/command/mapReduce/
- * @param JavascriptInterface $map Map function
- * @param JavascriptInterface $reduce Reduce function
- * @param string|array|object $out Output specification
- * @param array $options Command options
- * @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)
- * @throws UnexpectedValueException if the command response was malformed
- */
- public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce, string|array|object $out, array $options = []): MapReduceResult
- {
- @trigger_error(sprintf('The %s method is deprecated and will be removed in a version 2.0.', __METHOD__), E_USER_DEPRECATED);
-
- $hasOutputCollection = ! is_mapreduce_output_inline($out);
-
- // Check if the out option is inline because we will want to coerce a primary read preference if not
- if ($hasOutputCollection) {
- $options['readPreference'] = new ReadPreference(ReadPreference::PRIMARY);
- } else {
- $options = $this->inheritReadPreference($options);
- }
-
- /* A "majority" read concern is not compatible with inline output, so
- * avoid providing the Collection's read concern if it would conflict.
- */
- if (! $hasOutputCollection || $this->readConcern->getLevel() !== ReadConcern::MAJORITY) {
- $options = $this->inheritReadConcern($options);
- }
-
- $options = $this->inheritWriteOptions($options);
- $options = $this->inheritTypeMap($options);
-
- $operation = new MapReduce($this->databaseName, $this->collectionName, $map, $reduce, $out, $options);
-
- return $operation->execute(select_server_for_write($this->manager, $options));
- }
-
/**
* Renames the collection.
*
diff --git a/src/Command/ListCollections.php b/src/Command/ListCollections.php
index f2fb2410f..d42250cd3 100644
--- a/src/Command/ListCollections.php
+++ b/src/Command/ListCollections.php
@@ -18,13 +18,11 @@
namespace MongoDB\Command;
use MongoDB\Driver\Command;
-use MongoDB\Driver\Cursor;
+use MongoDB\Driver\CursorInterface;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Driver\Server;
use MongoDB\Driver\Session;
use MongoDB\Exception\InvalidArgumentException;
-use MongoDB\Model\CachingIterator;
-use MongoDB\Operation\Executable;
use function is_bool;
use function is_integer;
@@ -36,7 +34,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
*/
-final class ListCollections implements Executable
+final class ListCollections
{
/**
* Constructs a listCollections command.
@@ -93,17 +91,16 @@ public function __construct(private string $databaseName, private array $options
/**
* Execute the operation.
*
- * @return CachingIterator
- * @see Executable::execute()
+ * @return CursorInterface
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
- public function execute(Server $server): CachingIterator
+ public function execute(Server $server): CursorInterface
{
- /** @var Cursor $cursor */
+ /** @var CursorInterface $cursor */
$cursor = $server->executeReadCommand($this->databaseName, $this->createCommand(), $this->createOptions());
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
- return new CachingIterator($cursor);
+ return $cursor;
}
/**
diff --git a/src/Command/ListDatabases.php b/src/Command/ListDatabases.php
index 7ceeb4206..31ca5f741 100644
--- a/src/Command/ListDatabases.php
+++ b/src/Command/ListDatabases.php
@@ -23,7 +23,6 @@
use MongoDB\Driver\Session;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException;
-use MongoDB\Operation\Executable;
use function current;
use function is_array;
@@ -37,7 +36,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
*/
-final class ListDatabases implements Executable
+final class ListDatabases
{
/**
* Constructs a listDatabases command.
@@ -93,7 +92,6 @@ public function __construct(private array $options = [])
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return array An array of database info structures
* @throws UnexpectedValueException if the command response was malformed
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
@@ -102,6 +100,7 @@ public function execute(Server $server): array
{
$cursor = $server->executeReadCommand('admin', $this->createCommand(), $this->createOptions());
$cursor->setTypeMap(['root' => 'array', 'document' => 'array']);
+
$result = current($cursor->toArray());
if (! isset($result['databases']) || ! is_array($result['databases'])) {
diff --git a/src/Database.php b/src/Database.php
index e8e256c49..b3282d7af 100644
--- a/src/Database.php
+++ b/src/Database.php
@@ -38,7 +38,6 @@
use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Model\CollectionInfo;
-use MongoDB\Model\CollectionInfoIterator;
use MongoDB\Operation\Aggregate;
use MongoDB\Operation\CreateCollection;
use MongoDB\Operation\CreateEncryptedCollection;
@@ -460,6 +459,7 @@ public function getWriteConcern(): WriteConcern
* Returns the names of all collections in this database
*
* @see ListCollectionNames::__construct() for supported options
+ * @return Iterator
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
@@ -479,7 +479,7 @@ public function listCollectionNames(array $options = []): Iterator
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
- public function listCollections(array $options = []): CollectionInfoIterator
+ public function listCollections(array $options = []): Iterator
{
$operation = new ListCollections($this->databaseName, $options);
$server = select_server($this->manager, $options);
diff --git a/src/MapReduceResult.php b/src/MapReduceResult.php
deleted file mode 100644
index dbe0e1dda..000000000
--- a/src/MapReduceResult.php
+++ /dev/null
@@ -1,103 +0,0 @@
-
- * @psalm-type MapReduceCallable = callable(): Traversable
- */
-class MapReduceResult implements IteratorAggregate
-{
- /**
- * @var callable
- * @psalm-var MapReduceCallable
- */
- private $getIterator;
-
- private int $executionTimeMS;
-
- private array $counts;
-
- private array $timing;
-
- /**
- * Returns various count statistics from the mapReduce command.
- */
- public function getCounts(): array
- {
- return $this->counts;
- }
-
- /**
- * Return the command execution time in milliseconds.
- */
- public function getExecutionTimeMS(): int
- {
- return $this->executionTimeMS;
- }
-
- /**
- * Return the mapReduce results as a Traversable.
- *
- * @see https://php.net/iteratoraggregate.getiterator
- * @return Traversable
- */
- public function getIterator(): Traversable
- {
- return call_user_func($this->getIterator);
- }
-
- /**
- * Returns various timing statistics from the mapReduce command.
- *
- * Note: timing statistics are only available if the mapReduce command's
- * "verbose" option was true; otherwise, an empty array will be returned.
- */
- public function getTiming(): array
- {
- return $this->timing;
- }
-
- /**
- * @internal
- * @param callable $getIterator Callback that returns a Traversable for mapReduce results
- * @param stdClass $result Result document from the mapReduce command
- * @psalm-param MapReduceCallable $getIterator
- */
- public function __construct(callable $getIterator, stdClass $result)
- {
- $this->getIterator = $getIterator;
- $this->executionTimeMS = isset($result->timeMillis) ? (integer) $result->timeMillis : 0;
- $this->counts = isset($result->counts) ? (array) $result->counts : [];
- $this->timing = isset($result->timing) ? (array) $result->timing : [];
- }
-}
diff --git a/src/Model/CallbackIterator.php b/src/Model/CallbackIterator.php
index 161224925..4a8e5dda9 100644
--- a/src/Model/CallbackIterator.php
+++ b/src/Model/CallbackIterator.php
@@ -28,7 +28,7 @@
*
* @internal
*
- * @template TKey
+ * @template TKey of array-key
* @template TValue
* @template TCallbackValue
* @template-implements Iterator
diff --git a/src/Model/CollectionInfoCommandIterator.php b/src/Model/CollectionInfoCommandIterator.php
deleted file mode 100644
index 37c28b051..000000000
--- a/src/Model/CollectionInfoCommandIterator.php
+++ /dev/null
@@ -1,60 +0,0 @@
->
- */
-final class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
-{
- /** @param Traversable $iterator */
- public function __construct(Traversable $iterator, private ?string $databaseName = null)
- {
- parent::__construct($iterator);
- }
-
- /**
- * Return the current element as a CollectionInfo instance.
- *
- * @see CollectionInfoIterator::current()
- * @see https://php.net/iterator.current
- */
- public function current(): CollectionInfo
- {
- $info = parent::current();
-
- if ($this->databaseName !== null && isset($info['idIndex']) && ! isset($info['idIndex']['ns'])) {
- $info['idIndex']['ns'] = $this->databaseName . '.' . $info['name'];
- }
-
- return new CollectionInfo($info);
- }
-}
diff --git a/src/Model/CollectionInfoIterator.php b/src/Model/CollectionInfoIterator.php
deleted file mode 100644
index 6ce22c551..000000000
--- a/src/Model/CollectionInfoIterator.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-interface CollectionInfoIterator extends Iterator
-{
- /**
- * Return the current element as a CollectionInfo instance.
- */
- public function current(): CollectionInfo;
-}
diff --git a/src/Model/DatabaseInfoIterator.php b/src/Model/DatabaseInfoIterator.php
deleted file mode 100644
index fc00fb79b..000000000
--- a/src/Model/DatabaseInfoIterator.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-interface DatabaseInfoIterator extends Iterator
-{
- /**
- * Return the current element as a DatabaseInfo instance.
- */
- public function current(): DatabaseInfo;
-}
diff --git a/src/Model/DatabaseInfoLegacyIterator.php b/src/Model/DatabaseInfoLegacyIterator.php
deleted file mode 100644
index e6a73ab75..000000000
--- a/src/Model/DatabaseInfoLegacyIterator.php
+++ /dev/null
@@ -1,92 +0,0 @@
-databases));
- }
-
- /**
- * Return the key of the current element.
- *
- * @see https://php.net/iterator.key
- */
- public function key(): int
- {
- return key($this->databases);
- }
-
- /**
- * Move forward to next element.
- *
- * @see https://php.net/iterator.next
- */
- public function next(): void
- {
- next($this->databases);
- }
-
- /**
- * Rewind the Iterator to the first element.
- *
- * @see https://php.net/iterator.rewind
- */
- public function rewind(): void
- {
- reset($this->databases);
- }
-
- /**
- * Checks if current position is valid.
- *
- * @see https://php.net/iterator.valid
- */
- public function valid(): bool
- {
- return key($this->databases) !== null;
- }
-}
diff --git a/src/Model/IndexInfo.php b/src/Model/IndexInfo.php
index 4e2177765..ce6e04be5 100644
--- a/src/Model/IndexInfo.php
+++ b/src/Model/IndexInfo.php
@@ -22,9 +22,6 @@
use function array_key_exists;
use function array_search;
-use function trigger_error;
-
-use const E_USER_DEPRECATED;
/**
* Index information model class.
@@ -82,18 +79,6 @@ public function getName(): string
return (string) $this->info['name'];
}
- /**
- * Return the index namespace (e.g. "db.collection").
- *
- * @deprecated
- */
- public function getNamespace(): string
- {
- @trigger_error('MongoDB 4.4 drops support for the namespace in indexes, the method "IndexInfo::getNamespace()" will be removed in version 2.0', E_USER_DEPRECATED);
-
- return (string) $this->info['ns'];
- }
-
/**
* Return the index version.
*/
@@ -110,18 +95,6 @@ public function is2dSphere(): bool
return array_search('2dsphere', $this->getKey(), true) !== false;
}
- /**
- * Return whether or not this index is of type geoHaystack.
- *
- * @deprecated Since 1.16: MongoDB 5.0 removes support for geoHaystack indexes.
- */
- public function isGeoHaystack(): bool
- {
- @trigger_error('MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in version 2.0', E_USER_DEPRECATED);
-
- return array_search('geoHaystack', $this->getKey(), true) !== false;
- }
-
/**
* Return whether this is a sparse index.
*
diff --git a/src/Model/IndexInfoIterator.php b/src/Model/IndexInfoIterator.php
deleted file mode 100644
index f52e8dbfa..000000000
--- a/src/Model/IndexInfoIterator.php
+++ /dev/null
@@ -1,37 +0,0 @@
-
- */
-interface IndexInfoIterator extends Iterator
-{
- /**
- * Return the current element as a IndexInfo instance.
- */
- public function current(): IndexInfo;
-}
diff --git a/src/Model/IndexInfoIteratorIterator.php b/src/Model/IndexInfoIteratorIterator.php
deleted file mode 100644
index 04a95528b..000000000
--- a/src/Model/IndexInfoIteratorIterator.php
+++ /dev/null
@@ -1,64 +0,0 @@
->
- */
-final class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
-{
- /** @param Traversable $iterator */
- public function __construct(Traversable $iterator, private ?string $ns = null)
- {
- parent::__construct($iterator);
- }
-
- /**
- * Return the current element as an IndexInfo instance.
- *
- * @see IndexInfoIterator::current()
- * @see https://php.net/iterator.current
- */
- public function current(): IndexInfo
- {
- $info = parent::current();
-
- if (! array_key_exists('ns', $info) && $this->ns !== null) {
- $info['ns'] = $this->ns;
- }
-
- return new IndexInfo($info);
- }
-}
diff --git a/src/Operation/Aggregate.php b/src/Operation/Aggregate.php
index b7f109589..0588df188 100644
--- a/src/Operation/Aggregate.php
+++ b/src/Operation/Aggregate.php
@@ -47,7 +47,7 @@
* @see \MongoDB\Collection::aggregate()
* @see https://mongodb.com/docs/manual/reference/command/aggregate/
*/
-final class Aggregate implements Executable, Explainable
+final class Aggregate implements Explainable
{
private bool $isWrite;
@@ -212,7 +212,6 @@ public function __construct(private string $databaseName, private ?string $colle
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if read concern or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/BulkWrite.php b/src/Operation/BulkWrite.php
index 178ff1847..411c9d24d 100644
--- a/src/Operation/BulkWrite.php
+++ b/src/Operation/BulkWrite.php
@@ -46,7 +46,7 @@
*
* @see \MongoDB\Collection::bulkWrite()
*/
-final class BulkWrite implements Executable
+final class BulkWrite
{
public const DELETE_MANY = 'deleteMany';
public const DELETE_ONE = 'deleteOne';
@@ -185,7 +185,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/Count.php b/src/Operation/Count.php
index df91214bd..d79d49447 100644
--- a/src/Operation/Count.php
+++ b/src/Operation/Count.php
@@ -41,7 +41,7 @@
* @see \MongoDB\Collection::count()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
-final class Count implements Executable, Explainable
+final class Count implements Explainable
{
/**
* Constructs a count command.
@@ -124,7 +124,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/CountDocuments.php b/src/Operation/CountDocuments.php
index 4badaaf3b..7d00e8bed 100644
--- a/src/Operation/CountDocuments.php
+++ b/src/Operation/CountDocuments.php
@@ -37,7 +37,7 @@
* @see \MongoDB\Collection::countDocuments()
* @see https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#countdocuments
*/
-final class CountDocuments implements Executable
+final class CountDocuments
{
private array $aggregateOptions;
@@ -103,7 +103,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation or read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/CreateCollection.php b/src/Operation/CreateCollection.php
index 6411d1d2e..0e7918f37 100644
--- a/src/Operation/CreateCollection.php
+++ b/src/Operation/CreateCollection.php
@@ -41,7 +41,7 @@
* @see \MongoDB\Database::createCollection()
* @see https://mongodb.com/docs/manual/reference/command/create/
*/
-final class CreateCollection implements Executable
+final class CreateCollection
{
public const USE_POWER_OF_2_SIZES = 1;
public const NO_PADDING = 2;
@@ -239,7 +239,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return array|object Command result document
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/CreateEncryptedCollection.php b/src/Operation/CreateEncryptedCollection.php
index fec5f2d18..7c1075c29 100644
--- a/src/Operation/CreateEncryptedCollection.php
+++ b/src/Operation/CreateEncryptedCollection.php
@@ -48,7 +48,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#create-encrypted-collection-helper
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
*/
-final class CreateEncryptedCollection implements Executable
+final class CreateEncryptedCollection
{
private const WIRE_VERSION_FOR_QUERYABLE_ENCRYPTION_V2 = 21;
@@ -155,7 +155,6 @@ public function createDataKeys(ClientEncryption $clientEncryption, string $kmsPr
}
/**
- * @see Executable::execute()
* @return array|object Command result document from creating the encrypted collection
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws UnsupportedException if the server does not support Queryable Encryption
diff --git a/src/Operation/CreateIndexes.php b/src/Operation/CreateIndexes.php
index 0b164c48c..6591270b7 100644
--- a/src/Operation/CreateIndexes.php
+++ b/src/Operation/CreateIndexes.php
@@ -41,7 +41,7 @@
* @see \MongoDB\Collection::createIndexes()
* @see https://mongodb.com/docs/manual/reference/command/createIndexes/
*/
-final class CreateIndexes implements Executable
+final class CreateIndexes
{
private const WIRE_VERSION_FOR_COMMIT_QUORUM = 9;
@@ -116,7 +116,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return string[] The names of the created indexes
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/CreateSearchIndexes.php b/src/Operation/CreateSearchIndexes.php
index b96ca0f41..d21ed9428 100644
--- a/src/Operation/CreateSearchIndexes.php
+++ b/src/Operation/CreateSearchIndexes.php
@@ -37,7 +37,7 @@
* @see \MongoDB\Collection::createSearchIndexes()
* @see https://mongodb.com/docs/manual/reference/command/createSearchIndexes/
*/
-final class CreateSearchIndexes implements Executable
+final class CreateSearchIndexes
{
private array $indexes = [];
@@ -68,7 +68,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return string[] The names of the created indexes
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/DatabaseCommand.php b/src/Operation/DatabaseCommand.php
index 97cb7a500..567bbff9e 100644
--- a/src/Operation/DatabaseCommand.php
+++ b/src/Operation/DatabaseCommand.php
@@ -32,7 +32,7 @@
*
* @see \MongoDB\Database::command()
*/
-final class DatabaseCommand implements Executable
+final class DatabaseCommand
{
private Command $command;
@@ -78,11 +78,6 @@ public function __construct(private string $databaseName, array|object $command,
$this->command = $command instanceof Command ? $command : new Command($command);
}
- /**
- * Execute the operation.
- *
- * @see Executable::execute()
- */
public function execute(Server $server): CursorInterface
{
$cursor = $server->executeCommand($this->databaseName, $this->command, $this->createOptions());
diff --git a/src/Operation/Delete.php b/src/Operation/Delete.php
index ae2a46306..7e264152f 100644
--- a/src/Operation/Delete.php
+++ b/src/Operation/Delete.php
@@ -42,7 +42,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
-final class Delete implements Executable, Explainable
+final class Delete implements Explainable
{
private const WIRE_VERSION_FOR_HINT = 9;
@@ -120,7 +120,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if hint or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/DeleteMany.php b/src/Operation/DeleteMany.php
index 78090c464..5278ee08a 100644
--- a/src/Operation/DeleteMany.php
+++ b/src/Operation/DeleteMany.php
@@ -29,7 +29,7 @@
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
-final class DeleteMany implements Executable, Explainable
+final class DeleteMany implements Explainable
{
private Delete $delete;
@@ -74,7 +74,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/DeleteOne.php b/src/Operation/DeleteOne.php
index 157bb748a..44dd47ba5 100644
--- a/src/Operation/DeleteOne.php
+++ b/src/Operation/DeleteOne.php
@@ -29,7 +29,7 @@
* @see \MongoDB\Collection::deleteOne()
* @see https://mongodb.com/docs/manual/reference/command/delete/
*/
-final class DeleteOne implements Executable, Explainable
+final class DeleteOne implements Explainable
{
private Delete $delete;
@@ -74,7 +74,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/Distinct.php b/src/Operation/Distinct.php
index 1f06c0ff2..09ae1f00d 100644
--- a/src/Operation/Distinct.php
+++ b/src/Operation/Distinct.php
@@ -40,7 +40,7 @@
* @see \MongoDB\Collection::distinct()
* @see https://mongodb.com/docs/manual/reference/command/distinct/
*/
-final class Distinct implements Executable, Explainable
+final class Distinct implements Explainable
{
/**
* Constructs a distinct command.
@@ -109,7 +109,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/DropCollection.php b/src/Operation/DropCollection.php
index d1a0b65a8..c5878359e 100644
--- a/src/Operation/DropCollection.php
+++ b/src/Operation/DropCollection.php
@@ -36,7 +36,7 @@
* @see \MongoDB\Database::dropCollection()
* @see https://mongodb.com/docs/manual/reference/command/drop/
*/
-final class DropCollection implements Executable
+final class DropCollection
{
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;
@@ -83,7 +83,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return array|object Command result document
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/DropDatabase.php b/src/Operation/DropDatabase.php
index c60015e5c..3f9d7756f 100644
--- a/src/Operation/DropDatabase.php
+++ b/src/Operation/DropDatabase.php
@@ -34,7 +34,7 @@
* @see \MongoDB\Database::drop()
* @see https://mongodb.com/docs/manual/reference/command/dropDatabase/
*/
-final class DropDatabase implements Executable
+final class DropDatabase
{
/**
* Constructs a dropDatabase command.
@@ -78,7 +78,6 @@ public function __construct(private string $databaseName, private array $options
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return array|object Command result document
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/DropEncryptedCollection.php b/src/Operation/DropEncryptedCollection.php
index 32f143ee5..52fa1b8e3 100644
--- a/src/Operation/DropEncryptedCollection.php
+++ b/src/Operation/DropEncryptedCollection.php
@@ -37,7 +37,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#drop-collection-helper
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
*/
-final class DropEncryptedCollection implements Executable
+final class DropEncryptedCollection
{
private DropCollection $dropCollection;
@@ -85,7 +85,6 @@ public function __construct(string $databaseName, string $collectionName, array
}
/**
- * @see Executable::execute()
* @return array|object Command result document from dropping the encrypted collection
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/DropIndexes.php b/src/Operation/DropIndexes.php
index d6b1beb59..152977445 100644
--- a/src/Operation/DropIndexes.php
+++ b/src/Operation/DropIndexes.php
@@ -35,7 +35,7 @@
* @see \MongoDB\Collection::dropIndexes()
* @see https://mongodb.com/docs/manual/reference/command/dropIndexes/
*/
-final class DropIndexes implements Executable
+final class DropIndexes
{
/**
* Constructs a dropIndexes command.
@@ -92,7 +92,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @return array|object Command result document
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/DropSearchIndex.php b/src/Operation/DropSearchIndex.php
index 73b9c6e17..c79025fbb 100644
--- a/src/Operation/DropSearchIndex.php
+++ b/src/Operation/DropSearchIndex.php
@@ -30,7 +30,7 @@
* @see \MongoDB\Collection::dropSearchIndexes()
* @see https://mongodb.com/docs/manual/reference/command/dropSearchIndexes/
*/
-final class DropSearchIndex implements Executable
+final class DropSearchIndex
{
private const ERROR_CODE_NAMESPACE_NOT_FOUND = 26;
@@ -53,7 +53,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/EstimatedDocumentCount.php b/src/Operation/EstimatedDocumentCount.php
index 2a5aada61..716996541 100644
--- a/src/Operation/EstimatedDocumentCount.php
+++ b/src/Operation/EstimatedDocumentCount.php
@@ -35,7 +35,7 @@
* @see \MongoDB\Collection::estimatedDocumentCount()
* @see https://mongodb.com/docs/manual/reference/command/count/
*/
-final class EstimatedDocumentCount implements Executable, Explainable
+final class EstimatedDocumentCount implements Explainable
{
private array $options;
@@ -87,7 +87,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation or read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/Executable.php b/src/Operation/Executable.php
deleted file mode 100644
index 2c8dbc9f2..000000000
--- a/src/Operation/Executable.php
+++ /dev/null
@@ -1,39 +0,0 @@
-options['maxAwaitTimeMS'], 'integer');
}
- if (isset($this->options['maxScan']) && ! is_integer($this->options['maxScan'])) {
- throw InvalidArgumentException::invalidType('"maxScan" option', $this->options['maxScan'], 'integer');
- }
-
if (isset($this->options['maxTimeMS']) && ! is_integer($this->options['maxTimeMS'])) {
throw InvalidArgumentException::invalidType('"maxTimeMS" option', $this->options['maxTimeMS'], 'integer');
}
@@ -219,18 +194,10 @@ public function __construct(private string $databaseName, private string $collec
throw InvalidArgumentException::expectedDocumentType('"min" option', $this->options['min']);
}
- if (isset($this->options['modifiers']) && ! is_document($this->options['modifiers'])) {
- throw InvalidArgumentException::expectedDocumentType('"modifiers" option', $this->options['modifiers']);
- }
-
if (isset($this->options['noCursorTimeout']) && ! is_bool($this->options['noCursorTimeout'])) {
throw InvalidArgumentException::invalidType('"noCursorTimeout" option', $this->options['noCursorTimeout'], 'boolean');
}
- if (isset($this->options['oplogReplay']) && ! is_bool($this->options['oplogReplay'])) {
- throw InvalidArgumentException::invalidType('"oplogReplay" option', $this->options['oplogReplay'], 'boolean');
- }
-
if (isset($this->options['projection']) && ! is_document($this->options['projection'])) {
throw InvalidArgumentException::expectedDocumentType('"projection" option', $this->options['projection']);
}
@@ -259,10 +226,6 @@ public function __construct(private string $databaseName, private string $collec
throw InvalidArgumentException::invalidType('"skip" option', $this->options['skip'], 'integer');
}
- if (isset($this->options['snapshot']) && ! is_bool($this->options['snapshot'])) {
- throw InvalidArgumentException::invalidType('"snapshot" option', $this->options['snapshot'], 'boolean');
- }
-
if (isset($this->options['sort']) && ! is_document($this->options['sort'])) {
throw InvalidArgumentException::expectedDocumentType('"sort" option', $this->options['sort']);
}
@@ -287,7 +250,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
@@ -329,28 +291,6 @@ public function getCommandDocument(): array
// maxAwaitTimeMS is a Query level option so should not be considered here
unset($options['maxAwaitTimeMS']);
- $modifierFallback = [
- ['allowPartialResults', 'partial'],
- ['comment', '$comment'],
- ['hint', '$hint'],
- ['maxScan', '$maxScan'],
- ['max', '$max'],
- ['maxTimeMS', '$maxTimeMS'],
- ['min', '$min'],
- ['returnKey', '$returnKey'],
- ['showRecordId', '$showDiskLoc'],
- ['sort', '$orderby'],
- ['snapshot', '$snapshot'],
- ];
-
- foreach ($modifierFallback as $modifier) {
- if (! isset($options[$modifier[0]]) && isset($options['modifiers'][$modifier[1]])) {
- $options[$modifier[0]] = $options['modifiers'][$modifier[1]];
- }
- }
-
- unset($options['modifiers']);
-
return $cmd + $options;
}
@@ -395,7 +335,7 @@ private function createQueryOptions(): array
}
}
- foreach (['allowDiskUse', 'allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxScan', 'maxTimeMS', 'noCursorTimeout', 'oplogReplay', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'snapshot', 'sort'] as $option) {
+ foreach (['allowDiskUse', 'allowPartialResults', 'batchSize', 'comment', 'hint', 'limit', 'maxAwaitTimeMS', 'maxTimeMS', 'noCursorTimeout', 'projection', 'readConcern', 'returnKey', 'showRecordId', 'skip', 'sort'] as $option) {
if (isset($this->options[$option])) {
$options[$option] = $this->options[$option];
}
@@ -407,12 +347,6 @@ private function createQueryOptions(): array
}
}
- if (! empty($this->options['modifiers'])) {
- /** @psalm-var array|object */
- $modifiers = $this->options['modifiers'];
- $options['modifiers'] = is_object($modifiers) ? document_to_array($modifiers) : $modifiers;
- }
-
return $options;
}
}
diff --git a/src/Operation/FindAndModify.php b/src/Operation/FindAndModify.php
index 8b1f14f2e..27a888bc6 100644
--- a/src/Operation/FindAndModify.php
+++ b/src/Operation/FindAndModify.php
@@ -51,7 +51,7 @@
* @internal
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
-final class FindAndModify implements Executable, Explainable
+final class FindAndModify implements Explainable
{
private const WIRE_VERSION_FOR_HINT = 9;
@@ -221,7 +221,6 @@ public function __construct(private string $databaseName, private string $collec
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if hint or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
diff --git a/src/Operation/FindOne.php b/src/Operation/FindOne.php
index 0290356ee..f685de5ae 100644
--- a/src/Operation/FindOne.php
+++ b/src/Operation/FindOne.php
@@ -31,7 +31,7 @@
* @see https://mongodb.com/docs/manual/tutorial/query-documents/
* @see https://mongodb.com/docs/manual/reference/operator/query-modifier/
*/
-final class FindOne implements Executable, Explainable
+final class FindOne implements Explainable
{
private Find $find;
@@ -55,20 +55,11 @@ final class FindOne implements Executable, Explainable
*
* * max (document): The exclusive upper bound for a specific index.
*
- * * maxScan (integer): Maximum number of documents or index keys to scan
- * when executing the query.
- *
- * This option has been deprecated since version 1.4.
- *
* * maxTimeMS (integer): The maximum amount of time to allow the query to
- * run. If "$maxTimeMS" also exists in the modifiers document, this
- * option will take precedence.
+ * run.
*
* * min (document): The inclusive upper bound for a specific index.
*
- * * modifiers (document): Meta-operators modifying the output or behavior
- * of a query.
- *
* * projection (document): Limits the fields to return for the matching
* document.
*
@@ -87,9 +78,7 @@ final class FindOne implements Executable, Explainable
*
* * skip (integer): The number of documents to skip before returning.
*
- * * sort (document): The order in which to return matching documents. If
- * "$orderby" also exists in the modifiers document, this option will
- * take precedence.
+ * * sort (document): The order in which to return matching documents.
*
* * let (document): Map of parameter names and values. Values must be
* constant or closed expressions that do not reference document fields.
@@ -117,7 +106,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation or read concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/FindOneAndDelete.php b/src/Operation/FindOneAndDelete.php
index bf70bfc4a..7c0f22ad0 100644
--- a/src/Operation/FindOneAndDelete.php
+++ b/src/Operation/FindOneAndDelete.php
@@ -30,7 +30,7 @@
* @see \MongoDB\Collection::findOneAndDelete()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
-final class FindOneAndDelete implements Executable, Explainable
+final class FindOneAndDelete implements Explainable
{
private FindAndModify $findAndModify;
@@ -107,7 +107,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/FindOneAndReplace.php b/src/Operation/FindOneAndReplace.php
index b9a5bdf7d..5ea0c5a34 100644
--- a/src/Operation/FindOneAndReplace.php
+++ b/src/Operation/FindOneAndReplace.php
@@ -35,7 +35,7 @@
* @see \MongoDB\Collection::findOneAndReplace()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
-final class FindOneAndReplace implements Executable, Explainable
+final class FindOneAndReplace implements Explainable
{
public const RETURN_DOCUMENT_BEFORE = 1;
public const RETURN_DOCUMENT_AFTER = 2;
@@ -150,7 +150,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/FindOneAndUpdate.php b/src/Operation/FindOneAndUpdate.php
index 56db8cb8e..00e97972b 100644
--- a/src/Operation/FindOneAndUpdate.php
+++ b/src/Operation/FindOneAndUpdate.php
@@ -34,7 +34,7 @@
* @see \MongoDB\Collection::findOneAndUpdate()
* @see https://mongodb.com/docs/manual/reference/command/findAndModify/
*/
-final class FindOneAndUpdate implements Executable, Explainable
+final class FindOneAndUpdate implements Explainable
{
public const RETURN_DOCUMENT_BEFORE = 1;
public const RETURN_DOCUMENT_AFTER = 2;
@@ -150,7 +150,6 @@ public function __construct(string $databaseName, string $collectionName, array|
/**
* Execute the operation.
*
- * @see Executable::execute()
* @throws UnsupportedException if collation or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
diff --git a/src/Operation/InsertMany.php b/src/Operation/InsertMany.php
index 9de46a1f0..70e149076 100644
--- a/src/Operation/InsertMany.php
+++ b/src/Operation/InsertMany.php
@@ -38,7 +38,7 @@
* @see \MongoDB\Collection::insertMany()
* @see https://mongodb.com/docs/manual/reference/command/insert/
*/
-final class InsertMany implements Executable
+final class InsertMany
{
/** @var list