2323use Doctrine \ODM \MongoDB \Repository \ViewRepository ;
2424use Doctrine \Persistence \Mapping \ProxyClassNameResolver ;
2525use Doctrine \Persistence \ObjectManager ;
26+ use Doctrine \Persistence \ObjectRepository ;
2627use InvalidArgumentException ;
2728use Jean85 \PrettyVersions ;
2829use MongoDB \Client ;
@@ -224,12 +225,8 @@ public function getClient(): Client
224225 return $ this ->client ;
225226 }
226227
227- /**
228- * Gets the metadata factory used to gather the metadata of classes.
229- *
230- * @return ClassMetadataFactoryInterface
231- */
232- public function getMetadataFactory ()
228+ /** Gets the metadata factory used to gather the metadata of classes. */
229+ public function getMetadataFactory (): ClassmetadataFactoryInterface
233230 {
234231 return $ this ->metadataFactory ;
235232 }
@@ -241,16 +238,20 @@ public function getMetadataFactory()
241238 *
242239 * @param object $obj
243240 */
244- public function initializeObject ($ obj )
241+ public function initializeObject ($ obj ): void
245242 {
246243 $ this ->unitOfWork ->initializeObject ($ obj );
247244 }
248245
249246 /**
250247 * Helper method to check whether a lazy loading proxy or persistent collection has been initialized.
251248 */
252- public function isUninitializedObject (object $ obj ): bool
249+ public function isUninitializedObject (mixed $ obj ): bool
253250 {
251+ if (! is_object ($ obj )) {
252+ return false ;
253+ }
254+
254255 return $ this ->unitOfWork ->isUninitializedObject ($ obj );
255256 }
256257
@@ -443,7 +444,7 @@ public function createAggregationBuilder(string $documentName): Aggregation\Buil
443444 *
444445 * @throws InvalidArgumentException When the given $object param is not an object.
445446 */
446- public function persist ($ object )
447+ public function persist ($ object ): void
447448 {
448449 if (! is_object ($ object )) {
449450 throw new InvalidArgumentException (gettype ($ object ));
@@ -463,7 +464,7 @@ public function persist($object)
463464 *
464465 * @throws InvalidArgumentException When the $object param is not an object.
465466 */
466- public function remove ($ object )
467+ public function remove ($ object ): void
467468 {
468469 if (! is_object ($ object )) {
469470 throw new InvalidArgumentException (gettype ($ object ));
@@ -481,7 +482,7 @@ public function remove($object)
481482 *
482483 * @throws InvalidArgumentException When the given $object param is not an object.
483484 */
484- public function refresh ($ object )
485+ public function refresh ($ object ): void
485486 {
486487 if (! is_object ($ object )) {
487488 throw new InvalidArgumentException (gettype ($ object ));
@@ -502,7 +503,7 @@ public function refresh($object)
502503 *
503504 * @throws InvalidArgumentException When the $object param is not an object.
504505 */
505- public function detach ($ object )
506+ public function detach ($ object ): void
506507 {
507508 if (! is_object ($ object )) {
508509 throw new InvalidArgumentException (gettype ($ object ));
@@ -562,7 +563,7 @@ public function unlock(object $document): void
562563 *
563564 * @template T of object
564565 */
565- public function getRepository ($ className )
566+ public function getRepository ($ className ): ObjectRepository
566567 {
567568 return $ this ->repositoryFactory ->getRepository ($ this , $ className );
568569 }
@@ -578,7 +579,7 @@ public function getRepository($className)
578579 * @throws MongoDBException
579580 * @throws Throwable From event listeners.
580581 */
581- public function flush (array $ options = [])
582+ public function flush (array $ options = []): void
582583 {
583584 $ this ->errorIfClosed ();
584585 $ this ->unitOfWork ->commit ($ options );
@@ -686,7 +687,7 @@ public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion =
686687 *
687688 * @param string|null $objectName if given, only documents of this type will get detached
688689 */
689- public function clear ($ objectName = null )
690+ public function clear ($ objectName = null ): void
690691 {
691692 if ($ objectName !== null ) {
692693 trigger_deprecation (
@@ -722,7 +723,7 @@ public function close()
722723 *
723724 * @throws InvalidArgumentException When the $object param is not an object.
724725 */
725- public function contains ($ object )
726+ public function contains ($ object ): bool
726727 {
727728 if (! is_object ($ object )) {
728729 throw new InvalidArgumentException (gettype ($ object ));
0 commit comments