vendor/doctrine/doctrine-bundle/Repository/RepositoryFactoryCompatibility.php line 38

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Repository;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Doctrine\ORM\EntityRepository;
  5. use Doctrine\ORM\Repository\RepositoryFactory;
  6. use Doctrine\Persistence\ObjectRepository;
  7. use ReflectionMethod;
  8. if ((new ReflectionMethod(RepositoryFactory::class, 'getRepository'))->hasReturnType()) {
  9.     // ORM >= 3
  10.     /** @internal */
  11.     trait RepositoryFactoryCompatibility
  12.     {
  13.         /**
  14.          * Gets the repository for an entity class.
  15.          *
  16.          * @param class-string<T> $entityName
  17.          *
  18.          * @return EntityRepository<T>
  19.          *
  20.          * @template T of object
  21.          *
  22.          * @psalm-suppress MethodSignatureMismatch
  23.          */
  24.         public function getRepository(EntityManagerInterface $entityManagerstring $entityName): EntityRepository
  25.         {
  26.             return $this->doGetRepository($entityManager$entityNametrue);
  27.         }
  28.     }
  29. } else {
  30.     // ORM 2
  31.     /** @internal */
  32.     trait RepositoryFactoryCompatibility
  33.     {
  34.         /** {@inheritDoc} */
  35.         public function getRepository(EntityManagerInterface $entityManager$entityName): ObjectRepository
  36.         {
  37.             return $this->doGetRepository($entityManager$entityNamefalse);
  38.         }
  39.     }
  40. }