From d592dd341d99e07e8d6318b82486e1f1d27f91a4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 22 Apr 2022 11:22:06 +0200 Subject: [PATCH] Fix Psalm errors caused by ORM 2.12 and Persistence 2.5 (#1511) --- Repository/ContainerRepositoryFactory.php | 10 +++++++++- Repository/ServiceEntityRepository.php | 2 +- psalm.xml.dist | 12 ++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Repository/ContainerRepositoryFactory.php b/Repository/ContainerRepositoryFactory.php index 1907c5384..49b172d84 100644 --- a/Repository/ContainerRepositoryFactory.php +++ b/Repository/ContainerRepositoryFactory.php @@ -20,7 +20,7 @@ */ final class ContainerRepositoryFactory implements RepositoryFactory { - /** @var ObjectRepository[] */ + /** @var array */ private $managedRepositories = []; /** @var ContainerInterface */ @@ -68,6 +68,13 @@ public function getRepository(EntityManagerInterface $entityManager, $entityName return $this->getOrCreateRepository($entityManager, $metadata); } + /** + * @param ClassMetadata $metadata + * + * @return ObjectRepository + * + * @template TEntity of object + */ private function getOrCreateRepository( EntityManagerInterface $entityManager, ClassMetadata $metadata @@ -79,6 +86,7 @@ private function getOrCreateRepository( $repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName(); + /** @psalm-var ObjectRepository */ return $this->managedRepositories[$repositoryHash] = new $repositoryClassName($entityManager, $metadata); } } diff --git a/Repository/ServiceEntityRepository.php b/Repository/ServiceEntityRepository.php index 877d447f1..dd274065f 100644 --- a/Repository/ServiceEntityRepository.php +++ b/Repository/ServiceEntityRepository.php @@ -22,7 +22,7 @@ * } * } * - * @template T + * @template T of object * @template-extends EntityRepository */ class ServiceEntityRepository extends EntityRepository implements ServiceEntityRepositoryInterface diff --git a/psalm.xml.dist b/psalm.xml.dist index dc843675e..a0cb0fb23 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -33,18 +33,18 @@ - - - - - - + + + + + +