Skip to content

Commit 0d13135

Browse files
jmikolaGromNaN
authored andcommitted
Fix Psalm errors and update baseline
1 parent 683da03 commit 0d13135

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

psalm-baseline.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@
235235
<code><![CDATA[$pipeline]]></code>
236236
</PossiblyInvalidArgument>
237237
</file>
238+
<file src="src/ClientBulkWrite.php">
239+
<PossiblyInvalidArgument>
240+
<code><![CDATA[$document]]></code>
241+
<code><![CDATA[$replacement]]></code>
242+
</PossiblyInvalidArgument>
243+
</file>
238244
<file src="src/Codec/EncodeIfSupported.php">
239245
<ArgumentTypeCoercion>
240246
<code><![CDATA[$value]]></code>
@@ -545,6 +551,14 @@
545551
<code><![CDATA[$args[2]]]></code>
546552
</MixedOperand>
547553
</file>
554+
<file src="src/Operation/ClientBulkWriteCommand.php">
555+
<MixedMethodCall>
556+
<code><![CDATA[isInTransaction]]></code>
557+
</MixedMethodCall>
558+
<MixedReturnStatement>
559+
<code><![CDATA[$server->executeBulkWriteCommand($this->bulkWriteCommand, $options)]]></code>
560+
</MixedReturnStatement>
561+
</file>
548562
<file src="src/Operation/Count.php">
549563
<MixedAssignment>
550564
<code><![CDATA[$cmd[$option]]]></code>

src/ClientBulkWrite.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
namespace MongoDB;
1919

20+
use MongoDB\BSON\Document;
21+
use MongoDB\BSON\PackedArray;
2022
use MongoDB\Codec\DocumentCodec;
2123
use MongoDB\Codec\Encoder;
2224
use MongoDB\Driver\BulkWriteCommand;
2325
use MongoDB\Driver\Manager;
2426
use MongoDB\Exception\InvalidArgumentException;
2527

28+
use stdClass;
2629
use function is_array;
2730
use function is_bool;
2831
use function is_string;
@@ -33,6 +36,7 @@ private function __construct(
3336
public BulkWriteCommand $bulkWriteCommand,
3437
private Manager $manager,
3538
private string $namespace,
39+
/** @psalm-var Encoder<array|stdClass|Document|PackedArray, mixed> */
3640
private Encoder $builderEncoder,
3741
private ?DocumentCodec $codec,
3842
) {
@@ -108,6 +112,7 @@ public function insertOne(array|object $document, mixed &$id = null): self
108112
}
109113

110114
// Capture the document's _id, which may have been generated, in an optional output variable
115+
/** @var mixed */
111116
$id = $this->bulkWriteCommand->insertOne($this->namespace, $document);
112117

113118
return $this;

src/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ public function findOneAndUpdate(array|object $filter, array|object $update, arr
753753
return $operation->execute(select_server_for_write($this->manager, $options));
754754
}
755755

756+
/** @psalm-return Encoder<array|stdClass|Document|PackedArray, mixed> */
756757
public function getBuilderEncoder(): Encoder
757758
{
758759
return $this->builderEncoder;

src/Operation/ClientBulkWriteCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ final class ClientBulkWriteCommand
5353
* @param array $options Command options
5454
* @throws InvalidArgumentException for parameter/option parsing errors
5555
*/
56-
public function __construct(private BulkWriteCommand $bulkWriteCommand, private array $options = [])
56+
public function __construct(
57+
private BulkWriteCommand $bulkWriteCommand,
58+
/** @param array{session: ?Session, writeConcern: ?WriteConcern} */
59+
private array $options = [],
60+
)
5761
{
5862
if (count($bulkWriteCommand) === 0) {
5963
throw new InvalidArgumentException('$bulkWriteCommand is empty');

0 commit comments

Comments
 (0)