From 0e3dfb588e480b6221707189ed11f89294eddc4d Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 16 Aug 2021 23:06:04 +0200 Subject: [PATCH] Fix return type at `EntityManagerInterface::get(Partial)Reference()` --- lib/Doctrine/ORM/EntityManagerInterface.php | 9 +++++++-- psalm-baseline.xml | 7 ++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php index fafa33abaf3..e2fbc179c3e 100644 --- a/lib/Doctrine/ORM/EntityManagerInterface.php +++ b/lib/Doctrine/ORM/EntityManagerInterface.php @@ -23,6 +23,7 @@ use BadMethodCallException; use DateTimeInterface; use Doctrine\Common\EventManager; +use Doctrine\Common\Proxy\Proxy; use Doctrine\DBAL\Connection; use Doctrine\ORM\Internal\Hydration\AbstractHydrator; use Doctrine\ORM\Proxy\ProxyFactory; @@ -169,7 +170,7 @@ public function createQueryBuilder(); * @psalm-param class-string $entityName * * @return object|null The entity reference. - * @psalm-return ?T + * @psalm-return T|Proxy|null * * @throws ORMException * @@ -194,8 +195,12 @@ public function getReference($entityName, $id); * * @param string $entityName The name of the entity type. * @param mixed $identifier The entity identifier. + * @psalm-param class-string $entityName + * + * @return object|null The (partial) entity reference + * @psalm-return T|Proxy|null * - * @return object|null The (partial) entity reference. + * @template T */ public function getPartialReference($entityName, $identifier); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a6ca240b7ca..2a110f0613f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -481,19 +481,16 @@ is_object($entity) is_object($entity) - - $entity + $entity $entity - $entity instanceof $class->name ? $entity : null $persister->load($sortedId, null, null, [], $lockMode) $persister->loadById($sortedId) $this->metadataFactory->getMetadataFor($className) - + ?T getClassMetadata - getReference $hydrationMode