89
89
*/
90
90
final class DocumentPersister
91
91
{
92
- private ? Collection $ collection = null ;
92
+ private Collection $ collection ;
93
93
94
94
private ?Bucket $ bucket = null ;
95
95
@@ -226,7 +226,6 @@ public function executeInserts(array $options = []): void
226
226
}
227
227
228
228
try {
229
- assert ($ this ->collection instanceof Collection);
230
229
$ this ->collection ->insertMany ($ inserts , $ options );
231
230
} catch (DriverException $ e ) {
232
231
$ this ->queuedInserts = [];
@@ -334,7 +333,6 @@ private function executeUpsert(object $document, array $options): void
334
333
}
335
334
336
335
try {
337
- assert ($ this ->collection instanceof Collection);
338
336
$ this ->collection ->updateOne ($ criteria , $ data , $ options );
339
337
340
338
return ;
@@ -344,7 +342,6 @@ private function executeUpsert(object $document, array $options): void
344
342
}
345
343
}
346
344
347
- assert ($ this ->collection instanceof Collection);
348
345
$ this ->collection ->updateOne ($ criteria , ['$set ' => new stdClass ()], $ options );
349
346
}
350
347
@@ -398,7 +395,6 @@ public function update(object $document, array $options = []): void
398
395
399
396
$ options = $ this ->getWriteOptions ($ options );
400
397
401
- assert ($ this ->collection instanceof Collection);
402
398
$ result = $ this ->collection ->updateOne ($ query , $ update , $ options );
403
399
404
400
if (($ this ->class ->isVersioned || $ this ->class ->isLockable ) && $ result ->getModifiedCount () !== 1 ) {
@@ -439,7 +435,6 @@ public function delete(object $document, array $options = []): void
439
435
440
436
$ options = $ this ->getWriteOptions ($ options );
441
437
442
- assert ($ this ->collection instanceof Collection);
443
438
$ result = $ this ->collection ->deleteOne ($ query , $ options );
444
439
445
440
if (($ this ->class ->isVersioned || $ this ->class ->isLockable ) && ! $ result ->getDeletedCount ()) {
@@ -452,7 +447,6 @@ public function delete(object $document, array $options = []): void
452
447
*/
453
448
public function refresh (object $ document ): void
454
449
{
455
- assert ($ this ->collection instanceof Collection);
456
450
$ query = $ this ->getQueryForDocument ($ document );
457
451
$ data = $ this ->collection ->findOne ($ query );
458
452
if ($ data === null ) {
@@ -498,7 +492,6 @@ public function load($criteria, ?object $document = null, array $hints = [], int
498
492
$ options ['sort ' ] = $ this ->prepareSort ($ sort );
499
493
}
500
494
501
- assert ($ this ->collection instanceof Collection);
502
495
$ result = $ this ->collection ->findOne ($ criteria , $ options );
503
496
$ result = $ result !== null ? (array ) $ result : null ;
504
497
@@ -541,7 +534,6 @@ public function loadAll(array $criteria = [], ?array $sort = null, ?int $limit =
541
534
$ options ['skip ' ] = $ skip ;
542
535
}
543
536
544
- assert ($ this ->collection instanceof Collection);
545
537
$ baseCursor = $ this ->collection ->find ($ criteria , $ options );
546
538
547
539
assert ($ baseCursor instanceof CursorInterface && $ baseCursor instanceof SplIterator);
@@ -603,7 +595,6 @@ private function wrapCursor(SplIterator&CursorInterface $baseCursor): Iterator
603
595
public function exists (object $ document ): bool
604
596
{
605
597
$ id = $ this ->class ->getIdentifierObject ($ document );
606
- assert ($ this ->collection instanceof Collection);
607
598
608
599
return (bool ) $ this ->collection ->findOne (['_id ' => $ id ], ['_id ' ]);
609
600
}
@@ -616,7 +607,7 @@ public function lock(object $document, int $lockMode): void
616
607
$ id = $ this ->uow ->getDocumentIdentifier ($ document );
617
608
$ criteria = ['_id ' => $ this ->class ->getDatabaseIdentifierValue ($ id )];
618
609
$ lockMapping = $ this ->class ->fieldMappings [$ this ->class ->lockField ];
619
- assert ( $ this -> collection instanceof Collection);
610
+
620
611
$ this ->collection ->updateOne ($ criteria , ['$set ' => [$ lockMapping ['name ' ] => $ lockMode ]]);
621
612
$ this ->class ->reflFields [$ this ->class ->lockField ]->setValue ($ document , $ lockMode );
622
613
}
@@ -629,7 +620,7 @@ public function unlock(object $document): void
629
620
$ id = $ this ->uow ->getDocumentIdentifier ($ document );
630
621
$ criteria = ['_id ' => $ this ->class ->getDatabaseIdentifierValue ($ id )];
631
622
$ lockMapping = $ this ->class ->fieldMappings [$ this ->class ->lockField ];
632
- assert ( $ this -> collection instanceof Collection);
623
+
633
624
$ this ->collection ->updateOne ($ criteria , ['$unset ' => [$ lockMapping ['name ' ] => true ]]);
634
625
$ this ->class ->reflFields [$ this ->class ->lockField ]->setValue ($ document , null );
635
626
}
0 commit comments