21
21
use Doctrine \ODM \MongoDB \Repository \ViewRepository ;
22
22
use Doctrine \Persistence \Mapping \ProxyClassNameResolver ;
23
23
use Doctrine \Persistence \ObjectManager ;
24
+ use Doctrine \Persistence \ObjectRepository ;
24
25
use InvalidArgumentException ;
25
26
use Jean85 \PrettyVersions ;
26
27
use MongoDB \Client ;
@@ -218,12 +219,8 @@ public function getClient(): Client
218
219
return $ this ->client ;
219
220
}
220
221
221
- /**
222
- * Gets the metadata factory used to gather the metadata of classes.
223
- *
224
- * @return ClassMetadataFactoryInterface
225
- */
226
- public function getMetadataFactory ()
222
+ /** Gets the metadata factory used to gather the metadata of classes. */
223
+ public function getMetadataFactory (): ClassmetadataFactoryInterface
227
224
{
228
225
return $ this ->metadataFactory ;
229
226
}
@@ -235,16 +232,20 @@ public function getMetadataFactory()
235
232
*
236
233
* @param object $obj
237
234
*/
238
- public function initializeObject ($ obj )
235
+ public function initializeObject ($ obj ): void
239
236
{
240
237
$ this ->unitOfWork ->initializeObject ($ obj );
241
238
}
242
239
243
240
/**
244
241
* Helper method to check whether a lazy loading proxy or persistent collection has been initialized.
245
242
*/
246
- public function isUninitializedObject (object $ obj ): bool
243
+ public function isUninitializedObject (mixed $ obj ): bool
247
244
{
245
+ if (! is_object ($ obj )) {
246
+ return false ;
247
+ }
248
+
248
249
return $ this ->unitOfWork ->isUninitializedObject ($ obj );
249
250
}
250
251
@@ -440,7 +441,7 @@ public function createAggregationBuilder(string $documentName): Aggregation\Buil
440
441
*
441
442
* @throws InvalidArgumentException When the given $object param is not an object.
442
443
*/
443
- public function persist ($ object )
444
+ public function persist ($ object ): void
444
445
{
445
446
if (! is_object ($ object )) {
446
447
throw new InvalidArgumentException (gettype ($ object ));
@@ -460,7 +461,7 @@ public function persist($object)
460
461
*
461
462
* @throws InvalidArgumentException When the $object param is not an object.
462
463
*/
463
- public function remove ($ object )
464
+ public function remove ($ object ): void
464
465
{
465
466
if (! is_object ($ object )) {
466
467
throw new InvalidArgumentException (gettype ($ object ));
@@ -478,7 +479,7 @@ public function remove($object)
478
479
*
479
480
* @throws InvalidArgumentException When the given $object param is not an object.
480
481
*/
481
- public function refresh ($ object )
482
+ public function refresh ($ object ): void
482
483
{
483
484
if (! is_object ($ object )) {
484
485
throw new InvalidArgumentException (gettype ($ object ));
@@ -499,7 +500,7 @@ public function refresh($object)
499
500
*
500
501
* @throws InvalidArgumentException When the $object param is not an object.
501
502
*/
502
- public function detach ($ object )
503
+ public function detach ($ object ): void
503
504
{
504
505
if (! is_object ($ object )) {
505
506
throw new InvalidArgumentException (gettype ($ object ));
@@ -561,7 +562,7 @@ public function unlock(object $document): void
561
562
*
562
563
* @template T of object
563
564
*/
564
- public function getRepository ($ className )
565
+ public function getRepository ($ className ): ObjectRepository
565
566
{
566
567
return $ this ->repositoryFactory ->getRepository ($ this , $ className );
567
568
}
@@ -576,7 +577,7 @@ public function getRepository($className)
576
577
*
577
578
* @throws MongoDBException
578
579
*/
579
- public function flush (array $ options = [])
580
+ public function flush (array $ options = []): void
580
581
{
581
582
$ this ->errorIfClosed ();
582
583
$ this ->unitOfWork ->commit ($ options );
@@ -686,7 +687,7 @@ public function find($className, $id, $lockMode = LockMode::NONE, $lockVersion =
686
687
*
687
688
* @param string|null $objectName if given, only documents of this type will get detached
688
689
*/
689
- public function clear ($ objectName = null )
690
+ public function clear ($ objectName = null ): void
690
691
{
691
692
if ($ objectName !== null ) {
692
693
trigger_deprecation (
@@ -722,7 +723,7 @@ public function close()
722
723
*
723
724
* @throws InvalidArgumentException When the $object param is not an object.
724
725
*/
725
- public function contains ($ object )
726
+ public function contains ($ object ): bool
726
727
{
727
728
if (! is_object ($ object )) {
728
729
throw new InvalidArgumentException (gettype ($ object ));
0 commit comments