Skip to content

Commit 56beaa6

Browse files
committed
Fix psalm errors in createEncryptedCollection()
1 parent 153e29c commit 56beaa6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Database.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace MongoDB;
1919

2020
use Iterator;
21+
use MongoDB\BSON\Binary;
2122
use MongoDB\Driver\ClientEncryption;
2223
use MongoDB\Driver\Cursor;
2324
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
@@ -331,6 +332,7 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti
331332
throw InvalidArgumentException::invalidType('"encryptedFields" option', $options['encryptedFields'] ?? null, ['array', 'object']);
332333
}
333334

335+
/** @var array{fields: list<array{keyId: ?Binary}|object{keyId: ?Binary}>} */
334336
$encryptedFields = (array) recursive_copy($options['encryptedFields']);
335337

336338
$createDataKeyArgs = [
@@ -339,6 +341,7 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti
339341
];
340342

341343
try {
344+
/** @psalm-suppress RedundantConditionGivenDocblockType */
342345
if (isset($encryptedFields['fields']) && is_array($encryptedFields['fields'])) {
343346
foreach ($encryptedFields['fields'] as &$field) {
344347
if (is_array($field) && array_key_exists('keyId', $field) && $field['keyId'] === null) {

0 commit comments

Comments
 (0)