Skip to content

Commit 935ed81

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

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ public function testUseNativeLazyObjectBeforePHP84(): void
3131
$c->setUseNativeLazyObject(true);
3232
}
3333

34+
#[RequiresPhp('>= 8.4')]
35+
public function testUseNativeLazyObjectPriorityOverLazyGhost(): void
36+
{
37+
$c = new Configuration();
38+
39+
$c->setUseLazyGhostObject(true);
40+
$c->setUseNativeLazyObject(true);
41+
42+
self::assertTrue($c->isNativeLazyObjectEnabled());
43+
self::assertFalse($c->isLazyGhostObjectEnabled());
44+
45+
self::assertSame(Configuration::AUTOGENERATE_NEVER, $c->getAutoGenerateProxyClasses());
46+
}
47+
3448
public function testUseLazyGhostObject(): void
3549
{
3650
$c = new Configuration();
@@ -42,7 +56,7 @@ public function testUseLazyGhostObject(): void
4256
self::assertFalse($c->isLazyGhostObjectEnabled());
4357
}
4458

45-
public function testNativeLazyObjectDeprecatedByDefault(): void
59+
public function testNativeLazyObjectDisabledByDefault(): void
4660
{
4761
$c = new Configuration();
4862

0 commit comments

Comments
 (0)