Skip to content

Commit 823b074

Browse files
Merge v1.x into v2.x (#1442)
2 parents 081e9da + 8bb895b commit 823b074

14 files changed

+51
-13
lines changed

psalm-baseline.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@
360360
</TooManyArguments>
361361
</file>
362362
<file src="src/Model/CollectionInfoCommandIterator.php">
363+
<DeprecatedInterface>
364+
<code><![CDATA[CollectionInfoCommandIterator]]></code>
365+
</DeprecatedInterface>
363366
<MixedArrayAssignment>
364367
<code><![CDATA[$info['idIndex']['ns']]]></code>
365368
</MixedArrayAssignment>
@@ -368,6 +371,9 @@
368371
</MixedOperand>
369372
</file>
370373
<file src="src/Model/DatabaseInfoLegacyIterator.php">
374+
<DeprecatedInterface>
375+
<code><![CDATA[DatabaseInfoLegacyIterator]]></code>
376+
</DeprecatedInterface>
371377
<MixedArgument>
372378
<code><![CDATA[current($this->databases)]]></code>
373379
</MixedArgument>
@@ -376,6 +382,11 @@
376382
<code><![CDATA[key($this->databases)]]></code>
377383
</MixedReturnTypeCoercion>
378384
</file>
385+
<file src="src/Model/IndexInfoIteratorIterator.php">
386+
<DeprecatedInterface>
387+
<code><![CDATA[IndexInfoIteratorIterator]]></code>
388+
</DeprecatedInterface>
389+
</file>
379390
<file src="src/Model/IndexInput.php">
380391
<LessSpecificReturnStatement>
381392
<code><![CDATA[(object) $this->index]]></code>
@@ -774,7 +785,22 @@
774785
<code><![CDATA[$document]]></code>
775786
</PossiblyInvalidArgument>
776787
</file>
788+
<file src="src/Operation/ListCollections.php">
789+
<DeprecatedClass>
790+
<code><![CDATA[new CollectionInfoCommandIterator($this->listCollections->execute($server), $this->databaseName)]]></code>
791+
</DeprecatedClass>
792+
</file>
793+
<file src="src/Operation/ListDatabases.php">
794+
<DeprecatedClass>
795+
<code><![CDATA[new DatabaseInfoLegacyIterator($this->listDatabases->execute($server))]]></code>
796+
</DeprecatedClass>
797+
</file>
777798
<file src="src/Operation/ListIndexes.php">
799+
<DeprecatedClass>
800+
<code><![CDATA[IndexInfoIteratorIterator]]></code>
801+
<code><![CDATA[new IndexInfoIteratorIterator($iterator, $this->databaseName . '.' . $this->collectionName)]]></code>
802+
<code><![CDATA[new IndexInfoIteratorIterator(new EmptyIterator())]]></code>
803+
</DeprecatedClass>
778804
<MixedAssignment>
779805
<code><![CDATA[$cmd[$option]]]></code>
780806
<code><![CDATA[$options['session']]]></code>

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
use MongoDB\Exception\UnsupportedException;
3939
use MongoDB\Model\BSONArray;
4040
use MongoDB\Model\BSONDocument;
41-
use MongoDB\Model\DatabaseInfoIterator;
41+
use MongoDB\Model\DatabaseInfo;
4242
use MongoDB\Operation\DropDatabase;
4343
use MongoDB\Operation\ListDatabaseNames;
4444
use MongoDB\Operation\ListDatabases;
@@ -313,7 +313,7 @@ public function listDatabaseNames(array $options = []): Iterator
313313
* List databases.
314314
*
315315
* @see ListDatabases::__construct() for supported options
316-
* @return DatabaseInfoIterator
316+
* @return Iterator<int, DatabaseInfo>
317317
* @throws UnexpectedValueException if the command response was malformed
318318
* @throws InvalidArgumentException for parameter/option parsing errors
319319
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)

src/Collection.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use MongoDB\Model\BSONArray;
3939
use MongoDB\Model\BSONDocument;
4040
use MongoDB\Model\IndexInfo;
41-
use MongoDB\Model\IndexInfoIterator;
4241
use MongoDB\Operation\Aggregate;
4342
use MongoDB\Operation\BulkWrite;
4443
use MongoDB\Operation\Count;
@@ -907,7 +906,7 @@ public function insertOne(array|object $document, array $options = [])
907906
* Returns information for all indexes for the collection.
908907
*
909908
* @see ListIndexes::__construct() for supported options
910-
* @return IndexInfoIterator
909+
* @return Iterator<int, IndexInfo>
911910
* @throws InvalidArgumentException for parameter/option parsing errors
912911
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
913912
*/

src/Database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
use MongoDB\GridFS\Bucket;
3838
use MongoDB\Model\BSONArray;
3939
use MongoDB\Model\BSONDocument;
40-
use MongoDB\Model\CollectionInfoIterator;
40+
use MongoDB\Model\CollectionInfo;
4141
use MongoDB\Operation\Aggregate;
4242
use MongoDB\Operation\CreateCollection;
4343
use MongoDB\Operation\CreateEncryptedCollection;
@@ -491,7 +491,7 @@ public function listCollectionNames(array $options = []): Iterator
491491
* Returns information for all collections in this database.
492492
*
493493
* @see ListCollections::__construct() for supported options
494-
* @return CollectionInfoIterator
494+
* @return Iterator<int, CollectionInfo>
495495
* @throws InvalidArgumentException for parameter/option parsing errors
496496
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
497497
*/

src/Model/CollectionInfoCommandIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* @see \MongoDB\Database::listCollections()
3131
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst
3232
* @see https://mongodb.com/docs/manual/reference/command/listCollections/
33+
* @deprecated
3334
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
3435
*/
3536
final class CollectionInfoCommandIterator extends IteratorIterator implements CollectionInfoIterator

src/Model/CollectionInfoIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* This iterator is used for enumerating collections in a database.
2727
*
2828
* @see \MongoDB\Database::listCollections()
29+
* @deprecated
2930
* @template-extends Iterator<int, CollectionInfo>
3031
*/
3132
interface CollectionInfoIterator extends Iterator

src/Model/DatabaseInfoIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* This iterator is used for enumerating databases on a server.
2727
*
2828
* @see \MongoDB\Client::listDatabases()
29+
* @deprecated
2930
* @template-extends Iterator<int, DatabaseInfo>
3031
*/
3132
interface DatabaseInfoIterator extends Iterator

src/Model/DatabaseInfoLegacyIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @internal
3232
* @see \MongoDB\Client::listDatabases()
3333
* @see https://mongodb.com/docs/manual/reference/command/listDatabases/
34+
* @deprecated
3435
*/
3536
final class DatabaseInfoLegacyIterator implements DatabaseInfoIterator
3637
{

src/Model/IndexInfo.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ public function getName()
9393
/**
9494
* Return the index namespace (e.g. "db.collection").
9595
*
96+
* @deprecated
97+
*
9698
* @return string
9799
*/
98100
public function getNamespace()
99101
{
102+
@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);
103+
100104
return (string) $this->info['ns'];
101105
}
102106

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

133137
return array_search('geoHaystack', $this->getKey(), true) !== false;
134138
}

src/Model/IndexInfoIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* This iterator is used for enumerating indexes in a collection.
2727
*
2828
* @see \MongoDB\Collection::listIndexes()
29+
* @deprecated
2930
* @template-extends Iterator<int, IndexInfo>
3031
*/
3132
interface IndexInfoIterator extends Iterator

src/Model/IndexInfoIteratorIterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst
3535
* @see https://mongodb.com/docs/manual/reference/command/listIndexes/
3636
* @see https://mongodb.com/docs/manual/reference/system-collections/
37+
* @deprecated
3738
* @template-extends IteratorIterator<int, array, Traversable<int, array>>
3839
*/
3940
final class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator

src/Operation/ListCollections.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
namespace MongoDB\Operation;
1919

20+
use Iterator;
2021
use MongoDB\Command\ListCollections as ListCollectionsCommand;
2122
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2223
use MongoDB\Driver\Server;
2324
use MongoDB\Exception\InvalidArgumentException;
25+
use MongoDB\Model\CollectionInfo;
2426
use MongoDB\Model\CollectionInfoCommandIterator;
25-
use MongoDB\Model\CollectionInfoIterator;
2627

2728
/**
2829
* Operation for the listCollections command.
@@ -68,7 +69,7 @@ public function __construct(private string $databaseName, array $options = [])
6869
* Execute the operation.
6970
*
7071
* @see Executable::execute()
71-
* @return CollectionInfoIterator
72+
* @return Iterator<int, CollectionInfo>
7273
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
7374
*/
7475
public function execute(Server $server)

src/Operation/ListDatabases.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
namespace MongoDB\Operation;
1919

20+
use Iterator;
2021
use MongoDB\Command\ListDatabases as ListDatabasesCommand;
2122
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2223
use MongoDB\Driver\Server;
2324
use MongoDB\Exception\InvalidArgumentException;
2425
use MongoDB\Exception\UnexpectedValueException;
25-
use MongoDB\Model\DatabaseInfoIterator;
26+
use MongoDB\Model\DatabaseInfo;
2627
use MongoDB\Model\DatabaseInfoLegacyIterator;
2728

2829
/**
@@ -68,7 +69,7 @@ public function __construct(array $options = [])
6869
* Execute the operation.
6970
*
7071
* @see Executable::execute()
71-
* @return DatabaseInfoIterator
72+
* @return Iterator<int, DatabaseInfo>
7273
* @throws UnexpectedValueException if the command response was malformed
7374
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
7475
*/

src/Operation/ListIndexes.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
namespace MongoDB\Operation;
1919

2020
use EmptyIterator;
21+
use Iterator;
2122
use MongoDB\Driver\Command;
2223
use MongoDB\Driver\Exception\CommandException;
2324
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2425
use MongoDB\Driver\Server;
2526
use MongoDB\Driver\Session;
2627
use MongoDB\Exception\InvalidArgumentException;
2728
use MongoDB\Model\CachingIterator;
28-
use MongoDB\Model\IndexInfoIterator;
29+
use MongoDB\Model\IndexInfo;
2930
use MongoDB\Model\IndexInfoIteratorIterator;
3031

3132
use function is_integer;
@@ -75,7 +76,7 @@ public function __construct(private string $databaseName, private string $collec
7576
* Execute the operation.
7677
*
7778
* @see Executable::execute()
78-
* @return IndexInfoIterator
79+
* @return Iterator<int, IndexInfo>
7980
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
8081
*/
8182
public function execute(Server $server)

0 commit comments

Comments
 (0)