54
54
use Throwable ;
55
55
56
56
use function is_array ;
57
- use function sprintf ;
58
57
use function strlen ;
59
- use function trigger_error ;
60
-
61
- use const E_USER_DEPRECATED ;
62
58
63
59
class Database
64
60
{
@@ -274,19 +270,12 @@ public function command(array|object $command, array $options = []): CursorInter
274
270
* @see CreateCollection::__construct() for supported options
275
271
* @see https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#create-collection-helper
276
272
* @see https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-collections/
277
- * @return array|object Command result document
278
273
* @throws UnsupportedException if options are not supported by the selected server
279
274
* @throws InvalidArgumentException for parameter/option parsing errors
280
275
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
281
276
*/
282
- public function createCollection (string $ collectionName , array $ options = []): array | object
277
+ public function createCollection (string $ collectionName , array $ options = []): void
283
278
{
284
- if (! isset ($ options ['typeMap ' ])) {
285
- $ options ['typeMap ' ] = $ this ->typeMap ;
286
- } else {
287
- @trigger_error (sprintf ('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated ' , __FUNCTION__ ), E_USER_DEPRECATED );
288
- }
289
-
290
279
if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
291
280
$ options ['writeConcern ' ] = $ this ->writeConcern ;
292
281
}
@@ -301,7 +290,7 @@ public function createCollection(string $collectionName, array $options = []): a
301
290
302
291
$ server = select_server_for_write ($ this ->manager , $ options );
303
292
304
- return $ operation ->execute ($ server );
293
+ $ operation ->execute ($ server );
305
294
}
306
295
307
296
/**
@@ -319,19 +308,13 @@ public function createCollection(string $collectionName, array $options = []): a
319
308
* getPrevious() and getEncryptedFields() methods, respectively.
320
309
*
321
310
* @see CreateCollection::__construct() for supported options
322
- * @return array A tuple containing the command result document from creating the collection and the modified "encryptedFields" option
311
+ * @return array The modified "encryptedFields" option
323
312
* @throws InvalidArgumentException for parameter/option parsing errors
324
313
* @throws CreateEncryptedCollectionException for any errors creating data keys or creating the collection
325
314
* @throws UnsupportedException if Queryable Encryption is not supported by the selected server
326
315
*/
327
316
public function createEncryptedCollection (string $ collectionName , ClientEncryption $ clientEncryption , string $ kmsProvider , ?array $ masterKey , array $ options ): array
328
317
{
329
- if (! isset ($ options ['typeMap ' ])) {
330
- $ options ['typeMap ' ] = $ this ->typeMap ;
331
- } else {
332
- @trigger_error (sprintf ('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated ' , __FUNCTION__ ), E_USER_DEPRECATED );
333
- }
334
-
335
318
if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
336
319
$ options ['writeConcern ' ] = $ this ->writeConcern ;
337
320
}
@@ -340,10 +323,10 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti
340
323
$ server = select_server_for_write ($ this ->manager , $ options );
341
324
342
325
try {
343
- $ operation ->createDataKeys ($ clientEncryption , $ kmsProvider , $ masterKey, $ encryptedFields );
344
- $ result = $ operation ->execute ($ server );
326
+ $ encryptedFields = $ operation ->createDataKeys ($ clientEncryption , $ kmsProvider , $ masterKey );
327
+ $ operation ->execute ($ server );
345
328
346
- return [ $ result , $ encryptedFields] ;
329
+ return $ encryptedFields ;
347
330
} catch (Throwable $ e ) {
348
331
throw new CreateEncryptedCollectionException ($ e , $ encryptedFields ?? []);
349
332
}
@@ -354,19 +337,12 @@ public function createEncryptedCollection(string $collectionName, ClientEncrypti
354
337
*
355
338
* @see DropDatabase::__construct() for supported options
356
339
* @param array $options Additional options
357
- * @return array|object Command result document
358
340
* @throws UnsupportedException if options are unsupported on the selected server
359
341
* @throws InvalidArgumentException for parameter/option parsing errors
360
342
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
361
343
*/
362
- public function drop (array $ options = []): array | object
344
+ public function drop (array $ options = []): void
363
345
{
364
- if (! isset ($ options ['typeMap ' ])) {
365
- $ options ['typeMap ' ] = $ this ->typeMap ;
366
- } else {
367
- @trigger_error (sprintf ('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated ' , __FUNCTION__ ), E_USER_DEPRECATED );
368
- }
369
-
370
346
$ server = select_server_for_write ($ this ->manager , $ options );
371
347
372
348
if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
@@ -375,7 +351,7 @@ public function drop(array $options = []): array|object
375
351
376
352
$ operation = new DropDatabase ($ this ->databaseName , $ options );
377
353
378
- return $ operation ->execute ($ server );
354
+ $ operation ->execute ($ server );
379
355
}
380
356
381
357
/**
@@ -384,19 +360,12 @@ public function drop(array $options = []): array|object
384
360
* @see DropCollection::__construct() for supported options
385
361
* @param string $collectionName Collection name
386
362
* @param array $options Additional options
387
- * @return array|object Command result document
388
363
* @throws UnsupportedException if options are unsupported on the selected server
389
364
* @throws InvalidArgumentException for parameter/option parsing errors
390
365
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
391
366
*/
392
- public function dropCollection (string $ collectionName , array $ options = []): array | object
367
+ public function dropCollection (string $ collectionName , array $ options = []): void
393
368
{
394
- if (! isset ($ options ['typeMap ' ])) {
395
- $ options ['typeMap ' ] = $ this ->typeMap ;
396
- } else {
397
- @trigger_error (sprintf ('The function %s() will return nothing in mongodb/mongodb v2.0, the "typeMap" option is deprecated ' , __FUNCTION__ ), E_USER_DEPRECATED );
398
- }
399
-
400
369
$ server = select_server_for_write ($ this ->manager , $ options );
401
370
402
371
if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
@@ -412,7 +381,7 @@ public function dropCollection(string $collectionName, array $options = []): arr
412
381
? new DropEncryptedCollection ($ this ->databaseName , $ collectionName , $ options )
413
382
: new DropCollection ($ this ->databaseName , $ collectionName , $ options );
414
383
415
- return $ operation ->execute ($ server );
384
+ $ operation ->execute ($ server );
416
385
}
417
386
418
387
/**
@@ -534,21 +503,16 @@ public function modifyCollection(string $collectionName, array $collectionOption
534
503
* @param string $toCollectionName New name of the collection
535
504
* @param string|null $toDatabaseName New database name of the collection. Defaults to the original database.
536
505
* @param array $options Additional options
537
- * @return array|object Command result document
538
506
* @throws UnsupportedException if options are unsupported on the selected server
539
507
* @throws InvalidArgumentException for parameter/option parsing errors
540
508
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
541
509
*/
542
- public function renameCollection (string $ fromCollectionName , string $ toCollectionName , ?string $ toDatabaseName = null , array $ options = []): array | object
510
+ public function renameCollection (string $ fromCollectionName , string $ toCollectionName , ?string $ toDatabaseName = null , array $ options = []): void
543
511
{
544
512
if (! isset ($ toDatabaseName )) {
545
513
$ toDatabaseName = $ this ->databaseName ;
546
514
}
547
515
548
- if (! isset ($ options ['typeMap ' ])) {
549
- $ options ['typeMap ' ] = $ this ->typeMap ;
550
- }
551
-
552
516
$ server = select_server_for_write ($ this ->manager , $ options );
553
517
554
518
if (! isset ($ options ['writeConcern ' ]) && ! is_in_transaction ($ options )) {
@@ -557,7 +521,7 @@ public function renameCollection(string $fromCollectionName, string $toCollectio
557
521
558
522
$ operation = new RenameCollection ($ this ->databaseName , $ fromCollectionName , $ toDatabaseName , $ toCollectionName , $ options );
559
523
560
- return $ operation ->execute ($ server );
524
+ $ operation ->execute ($ server );
561
525
}
562
526
563
527
/**
0 commit comments