Skip to content

Commit 012fefa

Browse files
committed
Fix useLazyGhostObject option is false when useNativeLazyObject is true
And disable auto generate proxy classes
1 parent 2f1298c commit 012fefa

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Configuration.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ public function getProxyDir(): ?string
337337
*/
338338
public function getAutoGenerateProxyClasses(): int
339339
{
340+
if ($this->nativeLazyObject) {
341+
return self::AUTOGENERATE_NEVER;
342+
}
343+
340344
return $this->attributes['autoGenerateProxyClasses'] ?? self::AUTOGENERATE_FILE_NOT_EXISTS;
341345
}
342346

@@ -708,7 +712,7 @@ public function setUseLazyGhostObject(bool $flag): void
708712

709713
public function isLazyGhostObjectEnabled(): bool
710714
{
711-
return $this->lazyGhostObject;
715+
return $this->lazyGhostObject && ! $this->nativeLazyObject;
712716
}
713717

714718
public function setUseNativeLazyObject(bool $nativeLazyObject): void
@@ -718,7 +722,6 @@ public function setUseNativeLazyObject(bool $nativeLazyObject): void
718722
}
719723

720724
$this->nativeLazyObject = $nativeLazyObject;
721-
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
722725
}
723726

724727
public function isNativeLazyObjectEnabled(): bool

tests/Tests/ConfigurationTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ public function testUseNativeLazyObjectBeforePHP84(): void
3131
$c->setUseNativeLazyObject(true);
3232
}
3333

34+
public function testUseNativeLazyObjectPriorityOverLazyGhost(): void
35+
{
36+
$c = new Configuration();
37+
38+
$c->setUseLazyGhostObject(true);
39+
$c->setUseNativeLazyObject(true);
40+
41+
self::assertTrue($c->isNativeLazyObjectEnabled());
42+
self::assertFalse($c->isLazyGhostObjectEnabled());
43+
44+
self::assertSame(Configuration::AUTOGENERATE_NEVER, $c->getAutoGenerateProxyClasses());
45+
}
46+
3447
public function testUseLazyGhostObject(): void
3548
{
3649
$c = new Configuration();
@@ -42,7 +55,7 @@ public function testUseLazyGhostObject(): void
4255
self::assertFalse($c->isLazyGhostObjectEnabled());
4356
}
4457

45-
public function testNativeLazyObjectDeprecatedByDefault(): void
58+
public function testNativeLazyObjectDisabledByDefault(): void
4659
{
4760
$c = new Configuration();
4861

0 commit comments

Comments
 (0)