Skip to content

Merge v1.x into v2.x #1442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@
</TooManyArguments>
</file>
<file src="src/Model/CollectionInfoCommandIterator.php">
<DeprecatedInterface>
<code><![CDATA[CollectionInfoCommandIterator]]></code>
</DeprecatedInterface>
<MixedArrayAssignment>
<code><![CDATA[$info['idIndex']['ns']]]></code>
</MixedArrayAssignment>
Expand All @@ -368,6 +371,9 @@
</MixedOperand>
</file>
<file src="src/Model/DatabaseInfoLegacyIterator.php">
<DeprecatedInterface>
<code><![CDATA[DatabaseInfoLegacyIterator]]></code>
</DeprecatedInterface>
<MixedArgument>
<code><![CDATA[current($this->databases)]]></code>
</MixedArgument>
Expand All @@ -376,6 +382,11 @@
<code><![CDATA[key($this->databases)]]></code>
</MixedReturnTypeCoercion>
</file>
<file src="src/Model/IndexInfoIteratorIterator.php">
<DeprecatedInterface>
<code><![CDATA[IndexInfoIteratorIterator]]></code>
</DeprecatedInterface>
</file>
<file src="src/Model/IndexInput.php">
<LessSpecificReturnStatement>
<code><![CDATA[(object) $this->index]]></code>
Expand Down Expand Up @@ -774,7 +785,22 @@
<code><![CDATA[$document]]></code>
</PossiblyInvalidArgument>
</file>
<file src="src/Operation/ListCollections.php">
<DeprecatedClass>
<code><![CDATA[new CollectionInfoCommandIterator($this->listCollections->execute($server), $this->databaseName)]]></code>
</DeprecatedClass>
</file>
<file src="src/Operation/ListDatabases.php">
<DeprecatedClass>
<code><![CDATA[new DatabaseInfoLegacyIterator($this->listDatabases->execute($server))]]></code>
</DeprecatedClass>
</file>
<file src="src/Operation/ListIndexes.php">
<DeprecatedClass>
<code><![CDATA[IndexInfoIteratorIterator]]></code>
<code><![CDATA[new IndexInfoIteratorIterator($iterator, $this->databaseName . '.' . $this->collectionName)]]></code>
<code><![CDATA[new IndexInfoIteratorIterator(new EmptyIterator())]]></code>
</DeprecatedClass>
<MixedAssignment>
<code><![CDATA[$cmd[$option]]]></code>
<code><![CDATA[$options['session']]]></code>
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use MongoDB\Exception\UnsupportedException;
use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Model\DatabaseInfoIterator;
use MongoDB\Model\DatabaseInfo;
use MongoDB\Operation\DropDatabase;
use MongoDB\Operation\ListDatabaseNames;
use MongoDB\Operation\ListDatabases;
Expand Down Expand Up @@ -313,7 +313,7 @@ public function listDatabaseNames(array $options = []): Iterator
* List databases.
*
* @see ListDatabases::__construct() for supported options
* @return DatabaseInfoIterator
* @return Iterator<int, DatabaseInfo>
* @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)
Expand Down
3 changes: 1 addition & 2 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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;
Expand Down Expand Up @@ -907,7 +906,7 @@ public function insertOne(array|object $document, array $options = [])
* Returns information for all indexes for the collection.
*
* @see ListIndexes::__construct() for supported options
* @return IndexInfoIterator
* @return Iterator<int, IndexInfo>
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use MongoDB\GridFS\Bucket;
use MongoDB\Model\BSONArray;
use MongoDB\Model\BSONDocument;
use MongoDB\Model\CollectionInfoIterator;
use MongoDB\Model\CollectionInfo;
use MongoDB\Operation\Aggregate;
use MongoDB\Operation\CreateCollection;
use MongoDB\Operation\CreateEncryptedCollection;
Expand Down Expand Up @@ -491,7 +491,7 @@ public function listCollectionNames(array $options = []): Iterator
* Returns information for all collections in this database.
*
* @see ListCollections::__construct() for supported options
* @return CollectionInfoIterator
* @return Iterator<int, CollectionInfo>
* @throws InvalidArgumentException for parameter/option parsing errors
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
Expand Down
1 change: 1 addition & 0 deletions src/Model/CollectionInfoCommandIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @see \MongoDB\Database::listCollections()
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
* @deprecated
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
*/
class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator
Expand Down
1 change: 1 addition & 0 deletions src/Model/CollectionInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* This iterator is used for enumerating collections in a database.
*
* @see \MongoDB\Database::listCollections()
* @deprecated
* @template-extends Iterator<int, CollectionInfo>
*/
interface CollectionInfoIterator extends Iterator
Expand Down
1 change: 1 addition & 0 deletions src/Model/DatabaseInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* This iterator is used for enumerating databases on a server.
*
* @see \MongoDB\Client::listDatabases()
* @deprecated
* @template-extends Iterator<int, DatabaseInfo>
*/
interface DatabaseInfoIterator extends Iterator
Expand Down
1 change: 1 addition & 0 deletions src/Model/DatabaseInfoLegacyIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @internal
* @see \MongoDB\Client::listDatabases()
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
* @deprecated
*/
class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
{
Expand Down
6 changes: 5 additions & 1 deletion src/Model/IndexInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ public function getName()
/**
* Return the index namespace (e.g. "db.collection").
*
* @deprecated
*
* @return string
*/
public function getNamespace()
{
@trigger_error('MongoDB 4.4 drops support for the namespace in indexes, the method "IndexInfo::getNamespace()" will be removed in a future release', E_USER_DEPRECATED);

return (string) $this->info['ns'];
}

Expand Down Expand Up @@ -128,7 +132,7 @@ public function is2dSphere()
*/
public function isGeoHaystack()
{
trigger_error('MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in a future release', E_USER_DEPRECATED);
@trigger_error('MongoDB 5.0 removes support for "geoHaystack" indexes, the method "IndexInfo::isGeoHaystack()" will be removed in a future release', E_USER_DEPRECATED);

return array_search('geoHaystack', $this->getKey(), true) !== false;
}
Expand Down
1 change: 1 addition & 0 deletions src/Model/IndexInfoIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* This iterator is used for enumerating indexes in a collection.
*
* @see \MongoDB\Collection::listIndexes()
* @deprecated
* @template-extends Iterator<int, IndexInfo>
*/
interface IndexInfoIterator extends Iterator
Expand Down
1 change: 1 addition & 0 deletions src/Model/IndexInfoIteratorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
* @see https://mongodb.com/docs/manual/reference/command/listIndexes/
* @see https://mongodb.com/docs/manual/reference/system-collections/
* @deprecated
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
*/
class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator
Expand Down
5 changes: 3 additions & 2 deletions src/Operation/ListCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

namespace MongoDB\Operation;

use Iterator;
use MongoDB\Command\ListCollections as ListCollectionsCommand;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Driver\Server;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Model\CollectionInfo;
use MongoDB\Model\CollectionInfoCommandIterator;
use MongoDB\Model\CollectionInfoIterator;

/**
* Operation for the listCollections command.
Expand Down Expand Up @@ -70,7 +71,7 @@ public function __construct(private string $databaseName, array $options = [])
* Execute the operation.
*
* @see Executable::execute()
* @return CollectionInfoIterator
* @return Iterator<int, CollectionInfo>
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
public function execute(Server $server)
Expand Down
5 changes: 3 additions & 2 deletions src/Operation/ListDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

namespace MongoDB\Operation;

use Iterator;
use MongoDB\Command\ListDatabases as ListDatabasesCommand;
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
use MongoDB\Driver\Server;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\UnexpectedValueException;
use MongoDB\Model\DatabaseInfoIterator;
use MongoDB\Model\DatabaseInfo;
use MongoDB\Model\DatabaseInfoLegacyIterator;

/**
Expand Down Expand Up @@ -70,7 +71,7 @@ public function __construct(array $options = [])
* Execute the operation.
*
* @see Executable::execute()
* @return DatabaseInfoIterator
* @return Iterator<int, DatabaseInfo>
* @throws UnexpectedValueException if the command response was malformed
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Operation/ListIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
namespace MongoDB\Operation;

use EmptyIterator;
use Iterator;
use MongoDB\Driver\Command;
use MongoDB\Driver\Exception\CommandException;
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\Model\IndexInfoIterator;
use MongoDB\Model\IndexInfo;
use MongoDB\Model\IndexInfoIteratorIterator;

use function is_integer;
Expand Down Expand Up @@ -77,7 +78,7 @@ public function __construct(private string $databaseName, private string $collec
* Execute the operation.
*
* @see Executable::execute()
* @return IndexInfoIterator
* @return Iterator<int, IndexInfo>
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
public function execute(Server $server)
Expand Down