Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ public function getProxyDir(): ?string
*/
public function getAutoGenerateProxyClasses(): int
{
if ($this->nativeLazyObject) {
return self::AUTOGENERATE_NEVER;
}

return $this->attributes['autoGenerateProxyClasses'] ?? self::AUTOGENERATE_FILE_NOT_EXISTS;
}

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

public function isLazyGhostObjectEnabled(): bool
{
return $this->lazyGhostObject;
return $this->lazyGhostObject && ! $this->nativeLazyObject;
}

public function setUseNativeLazyObject(bool $nativeLazyObject): void
Expand All @@ -718,7 +722,6 @@ public function setUseNativeLazyObject(bool $nativeLazyObject): void
}

$this->nativeLazyObject = $nativeLazyObject;
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
}

public function isNativeLazyObjectEnabled(): bool
Expand Down
16 changes: 15 additions & 1 deletion tests/Tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public function testUseNativeLazyObjectBeforePHP84(): void
$c->setUseNativeLazyObject(true);
}

#[RequiresPhp('>= 8.4')]
public function testUseNativeLazyObjectPriorityOverLazyGhost(): void
{
$c = new Configuration();

$c->setUseLazyGhostObject(true);
$c->setUseNativeLazyObject(true);

self::assertTrue($c->isNativeLazyObjectEnabled());
self::assertFalse($c->isLazyGhostObjectEnabled());

self::assertSame(Configuration::AUTOGENERATE_NEVER, $c->getAutoGenerateProxyClasses());
}

public function testUseLazyGhostObject(): void
{
$c = new Configuration();
Expand All @@ -42,7 +56,7 @@ public function testUseLazyGhostObject(): void
self::assertFalse($c->isLazyGhostObjectEnabled());
}

public function testNativeLazyObjectDeprecatedByDefault(): void
public function testNativeLazyObjectDisabledByDefault(): void
{
$c = new Configuration();

Expand Down
Loading