Skip to content

Commit c4a7a46

Browse files
committed
Use templated return type
1 parent 49677cb commit c4a7a46

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

psalm-baseline.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
</TooManyArguments>
151151
</file>
152152
<file src="src/Model/CollectionInfoCommandIterator.php">
153+
<DeprecatedInterface>
154+
<code><![CDATA[CollectionInfoCommandIterator]]></code>
155+
</DeprecatedInterface>
153156
<MixedArrayAssignment>
154157
<code><![CDATA[$info['idIndex']['ns']]]></code>
155158
</MixedArrayAssignment>
@@ -158,6 +161,9 @@
158161
</MixedOperand>
159162
</file>
160163
<file src="src/Model/DatabaseInfoLegacyIterator.php">
164+
<DeprecatedInterface>
165+
<code><![CDATA[DatabaseInfoLegacyIterator]]></code>
166+
</DeprecatedInterface>
161167
<MixedArgument>
162168
<code><![CDATA[current($this->databases)]]></code>
163169
</MixedArgument>
@@ -166,6 +172,11 @@
166172
<code><![CDATA[key($this->databases)]]></code>
167173
</MixedReturnTypeCoercion>
168174
</file>
175+
<file src="src/Model/IndexInfoIteratorIterator.php">
176+
<DeprecatedInterface>
177+
<code><![CDATA[IndexInfoIteratorIterator]]></code>
178+
</DeprecatedInterface>
179+
</file>
169180
<file src="src/Model/IndexInput.php">
170181
<LessSpecificReturnStatement>
171182
<code><![CDATA[(object) $this->index]]></code>
@@ -553,7 +564,22 @@
553564
<code><![CDATA[$document]]></code>
554565
</PossiblyInvalidArgument>
555566
</file>
567+
<file src="src/Operation/ListCollections.php">
568+
<DeprecatedClass>
569+
<code><![CDATA[new CollectionInfoCommandIterator($this->listCollections->execute($server), $this->databaseName)]]></code>
570+
</DeprecatedClass>
571+
</file>
572+
<file src="src/Operation/ListDatabases.php">
573+
<DeprecatedClass>
574+
<code><![CDATA[new DatabaseInfoLegacyIterator($this->listDatabases->execute($server))]]></code>
575+
</DeprecatedClass>
576+
</file>
556577
<file src="src/Operation/ListIndexes.php">
578+
<DeprecatedClass>
579+
<code><![CDATA[IndexInfoIteratorIterator]]></code>
580+
<code><![CDATA[new IndexInfoIteratorIterator($iterator, $this->databaseName . '.' . $this->collectionName)]]></code>
581+
<code><![CDATA[new IndexInfoIteratorIterator(new EmptyIterator())]]></code>
582+
</DeprecatedClass>
557583
<MixedAssignment>
558584
<code><![CDATA[$cmd[$option]]]></code>
559585
<code><![CDATA[$options['session']]]></code>

src/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use MongoDB\Exception\UnsupportedException;
3434
use MongoDB\Model\BSONArray;
3535
use MongoDB\Model\BSONDocument;
36+
use MongoDB\Model\DatabaseInfo;
3637
use MongoDB\Operation\DropDatabase;
3738
use MongoDB\Operation\ListDatabaseNames;
3839
use MongoDB\Operation\ListDatabases;
@@ -293,7 +294,7 @@ public function listDatabaseNames(array $options = []): Iterator
293294
* List databases.
294295
*
295296
* @see ListDatabases::__construct() for supported options
296-
* @return Iterator
297+
* @return Iterator<int, DatabaseInfo>
297298
* @throws UnexpectedValueException if the command response was malformed
298299
* @throws InvalidArgumentException for parameter/option parsing errors
299300
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ public function insertOne($document, array $options = [])
881881
* Returns information for all indexes for the collection.
882882
*
883883
* @see ListIndexes::__construct() for supported options
884-
* @return Iterator
884+
* @return Iterator<int, IndexInfo>
885885
* @throws InvalidArgumentException for parameter/option parsing errors
886886
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
887887
*/

src/Database.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use MongoDB\GridFS\Bucket;
3333
use MongoDB\Model\BSONArray;
3434
use MongoDB\Model\BSONDocument;
35+
use MongoDB\Model\CollectionInfo;
3536
use MongoDB\Operation\Aggregate;
3637
use MongoDB\Operation\CreateCollection;
3738
use MongoDB\Operation\CreateEncryptedCollection;
@@ -472,7 +473,7 @@ public function listCollectionNames(array $options = []): Iterator
472473
* Returns information for all collections in this database.
473474
*
474475
* @see ListCollections::__construct() for supported options
475-
* @return Iterator
476+
* @return Iterator<int, CollectionInfo>
476477
* @throws InvalidArgumentException for parameter/option parsing errors
477478
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
478479
*/

src/Operation/ListCollections.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
2323
use MongoDB\Driver\Server;
2424
use MongoDB\Exception\InvalidArgumentException;
25+
use MongoDB\Model\CollectionInfo;
2526
use MongoDB\Model\CollectionInfoCommandIterator;
2627

2728
/**
@@ -71,7 +72,7 @@ public function __construct(string $databaseName, array $options = [])
7172
* Execute the operation.
7273
*
7374
* @see Executable::execute()
74-
* @return Iterator
75+
* @return Iterator<int, CollectionInfo>
7576
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
7677
*/
7778
public function execute(Server $server)

src/Operation/ListDatabases.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use MongoDB\Driver\Server;
2424
use MongoDB\Exception\InvalidArgumentException;
2525
use MongoDB\Exception\UnexpectedValueException;
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 Iterator
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use MongoDB\Driver\Session;
2727
use MongoDB\Exception\InvalidArgumentException;
2828
use MongoDB\Model\CachingIterator;
29+
use MongoDB\Model\IndexInfo;
2930
use MongoDB\Model\IndexInfoIteratorIterator;
3031

3132
use function is_integer;
@@ -85,7 +86,7 @@ public function __construct(string $databaseName, string $collectionName, array
8586
* Execute the operation.
8687
*
8788
* @see Executable::execute()
88-
* @return Iterator
89+
* @return Iterator<int, IndexInfo>
8990
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
9091
*/
9192
public function execute(Server $server)

0 commit comments

Comments
 (0)