Skip to content

Commit a0cdabf

Browse files
committed
Review
1 parent b91d647 commit a0cdabf

File tree

10 files changed

+23
-18
lines changed

10 files changed

+23
-18
lines changed

lib/Doctrine/ODM/MongoDB/Configuration.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public function isTransactionalFlushEnabled(): bool
689689
* Generate proxy classes using Symfony VarExporter's LazyGhostTrait if true.
690690
* Otherwise, use ProxyManager's LazyLoadingGhostFactory (deprecated)
691691
*/
692-
public function setLazyGhostObject(bool $flag): void
692+
public function setUseLazyGhostObject(bool $flag): void
693693
{
694694
if ($this->nativeLazyObjects) {
695695
throw new LogicException('Cannot enable or disable LazyGhostObject when native lazy objects are enabled.');
@@ -715,21 +715,21 @@ public function isLazyGhostObjectEnabled(): bool
715715
return $this->lazyGhostObject;
716716
}
717717

718-
public function enableNativeLazyObjects(bool $nativeLazyObjects): void
718+
public function setUseNativeLazyObject(bool $nativeLazyObject): void
719719
{
720-
if (PHP_VERSION_ID >= 80400 && ! $nativeLazyObjects) {
720+
if (PHP_VERSION_ID >= 80400 && ! $nativeLazyObject) {
721721
trigger_deprecation('doctrine/mongodb-odm', '2.14', 'Disabling native lazy objects is deprecated and will be impossible in Doctrine MongoDB ODM 3.0.');
722722
}
723723

724-
if (PHP_VERSION_ID < 80400 && $nativeLazyObjects) {
725-
throw new LogicException('Lazy loading proxies require PHP 8.4 or higher.');
724+
if (PHP_VERSION_ID < 80400 && $nativeLazyObject) {
725+
throw new LogicException('Native lazy objects require PHP 8.4 or higher.');
726726
}
727727

728-
$this->nativeLazyObjects = $nativeLazyObjects;
729-
$this->lazyGhostObject = ! $nativeLazyObjects || $this->lazyGhostObject;
728+
$this->nativeLazyObjects = $nativeLazyObject;
729+
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
730730
}
731731

732-
public function isNativeLazyObjectsEnabled(): bool
732+
public function isNativeLazyObjectEnabled(): bool
733733
{
734734
return $this->nativeLazyObjects;
735735
}

lib/Doctrine/ODM/MongoDB/DocumentManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected function __construct(?Client $client = null, ?Configuration $config =
182182
$this->unitOfWork = new UnitOfWork($this, $this->eventManager, $this->hydratorFactory);
183183
$this->schemaManager = new SchemaManager($this, $this->metadataFactory);
184184
$this->proxyFactory = match (true) {
185-
$this->config->isNativeLazyObjectsEnabled() => new NativeLazyObjectFactory($this),
185+
$this->config->isNativeLazyObjectEnabled() => new NativeLazyObjectFactory($this),
186186
$this->config->isLazyGhostObjectEnabled() => new LazyGhostProxyFactory($this, $this->config->getProxyDir(), $this->config->getProxyNamespace(), $this->config->getAutoGenerateProxyClasses()),
187187
default => new StaticProxyFactory($this),
188188
};

lib/Doctrine/ODM/MongoDB/Mapping/PropertyAccessors/RawValuePropertyAccessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* It works based on the raw values of a property, which for a case of property hooks
2020
* is the backed value. If we kept using setValue/getValue, this would go through the hooks,
2121
* which potentially change the data.
22+
*
23+
* @internal
2224
*/
2325
class RawValuePropertyAccessor implements PropertyAccessor
2426
{

lib/Doctrine/ODM/MongoDB/Proxy/Factory/NativeLazyObjectFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function getProxy(ClassMetadata $metadata, $identifier): object
7575
return $proxy;
7676
}
7777

78-
/** Only for internal tests */
78+
/** @internal Only for tests */
7979
public static function enableTracking(bool $enabled = true): void
8080
{
8181
if ($enabled) {
@@ -85,7 +85,7 @@ public static function enableTracking(bool $enabled = true): void
8585
}
8686
}
8787

88-
/** Only for internal tests */
88+
/** @internal Only for tests */
8989
public static function isLazyObject(object $object): bool
9090
{
9191
if (! isset(self::$lazyObjects)) {

lib/Doctrine/ODM/MongoDB/UnitOfWork.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,7 @@ public function getOrCreateDocument(string $className, array $data, array &$hint
27852785
$document = $this->identityMap[$class->name][$serializedId];
27862786
$oid = spl_object_id($document);
27872787
if ($this->isUninitializedObject($document)) {
2788-
if ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) {
2788+
if ($this->dm->getConfiguration()->isNativeLazyObjectEnabled()) {
27892789
$class->reflClass->markLazyObjectAsInitialized($document);
27902790
} elseif ($document instanceof InternalProxy) {
27912791
$document->__setInitialized(true);
@@ -3096,7 +3096,7 @@ public function isUninitializedObject(object $obj): bool
30963096
$obj instanceof InternalProxy => ! $obj->__isInitialized(),
30973097
$obj instanceof GhostObjectInterface => ! $obj->isProxyInitialized(),
30983098
$obj instanceof PersistentCollectionInterface => ! $obj->isInitialized(),
3099-
$this->dm->getConfiguration()->isNativeLazyObjectsEnabled() => $this->dm->getClassMetadata($obj::class)->reflClass->isUninitializedLazyObject($obj),
3099+
$this->dm->getConfiguration()->isNativeLazyObjectEnabled() => $this->dm->getClassMetadata($obj::class)->reflClass->isUninitializedLazyObject($obj),
31003100
default => false
31013101
};
31023102
}

tests/Doctrine/ODM/MongoDB/Tests/BaseTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ protected static function getConfiguration(): Configuration
105105
$config->setPersistentCollectionNamespace('PersistentCollections');
106106
$config->setDefaultDB(DOCTRINE_MONGODB_DATABASE);
107107
$config->setMetadataDriverImpl(static::createMetadataDriverImpl());
108-
$config->setLazyGhostObject((bool) $_ENV['USE_LAZY_GHOST_OBJECTS']);
109-
$config->enableNativeLazyObjects((bool) $_ENV['USE_NATIVE_LAZY_OBJECTS']);
108+
$config->setUseLazyGhostObject((bool) $_ENV['USE_LAZY_GHOST_OBJECTS']);
109+
$config->setUseNativeLazyObject((bool) $_ENV['USE_NATIVE_LAZY_OBJECTS']);
110110

111-
if ($config->isNativeLazyObjectsEnabled()) {
111+
if ($config->isNativeLazyObjectEnabled()) {
112112
NativeLazyObjectFactory::enableTracking();
113113
}
114114

tests/Doctrine/ODM/MongoDB/Tests/Functional/PropertyHooksTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919

20-
if ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) {
20+
if ($this->dm->getConfiguration()->isNativeLazyObjectEnabled()) {
2121
return;
2222
}
2323

tests/Doctrine/ODM/MongoDB/Tests/Functional/ReferencePrimerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function testPrimeReferencesWithDBRefObjects(): void
9494
->field('groups')->prime(true);
9595

9696
foreach ($qb->getQuery() as $user) {
97+
self::assertTrue(self::isLazyObject($user->getAccount()));
9798
self::assertFalse($this->uow->isUninitializedObject($user->getAccount()));
9899

99100
self::assertCount(2, $user->getGroups());

tests/Doctrine/ODM/MongoDB/Tests/Mapping/AbstractAnnotationDriverTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function testGetAllClassNamesIsIdempotent(): void
9797
{
9898
$annotationDriver = $this->loadDriverForCMSDocuments();
9999
$original = $annotationDriver->getAllClassNames();
100+
101+
$annotationDriver = $this->loadDriverForCMSDocuments();
100102
$afterTestReset = $annotationDriver->getAllClassNames();
101103

102104
self::assertEquals($original, $afterTestReset);

tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testCreateProxyForDocumentWithUnmappedProperties(): void
8989
$proxy->__setInitialized(true);
9090
} elseif ($proxy instanceof GhostObjectInterface) {
9191
$proxy->setProxyInitializer(null);
92-
} elseif ($this->dm->getConfiguration()->isNativeLazyObjectsEnabled()) {
92+
} elseif ($this->dm->getConfiguration()->isNativeLazyObjectEnabled()) {
9393
$this->dm->getClassMetadata($proxy::class)->getReflectionClass()->markLazyObjectAsInitialized($proxy);
9494
}
9595

0 commit comments

Comments
 (0)