Skip to content

Commit

Permalink
LazyServiceEntityRepository is autoloadable only if LazyGhostTrait ex…
Browse files Browse the repository at this point in the history
…ists
  • Loading branch information
ondrejmirtes committed Jan 8, 2023
1 parent 31f74fe commit ed1a207
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Stubs/Doctrine/StubFilesExtensionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPStan\PhpDoc\StubFilesExtension;
use function class_exists;
use function dirname;
use function trait_exists;

class StubFilesExtensionLoader implements StubFilesExtension
{
Expand Down Expand Up @@ -33,7 +34,10 @@ public function getFiles(): array
$path . '/EntityRepository.stub',
];

if (class_exists('Doctrine\Bundle\DoctrineBundle\Repository\LazyServiceEntityRepository')) {
if (
trait_exists('Symfony\Component\VarExporter\LazyGhostTrait')
&& class_exists('Doctrine\Bundle\DoctrineBundle\Repository\LazyServiceEntityRepository')
) {
$files[] = $stubsDir . '/LazyServiceEntityRepository.stub';
} else {
$files[] = $stubsDir . '/ServiceEntityRepository.stub';
Expand Down

0 comments on commit ed1a207

Please sign in to comment.