Skip to content

Commit

Permalink
Fix return type at EntityManagerInterface::get(Partial)Reference()
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Aug 16, 2021
1 parent d636d79 commit 0e3dfb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 7 additions & 2 deletions lib/Doctrine/ORM/EntityManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -169,7 +170,7 @@ public function createQueryBuilder();
* @psalm-param class-string<T> $entityName
*
* @return object|null The entity reference.
* @psalm-return ?T
* @psalm-return T|Proxy|null
*
* @throws ORMException
*
Expand All @@ -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<T> $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);

Expand Down
7 changes: 2 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,16 @@
<code>is_object($entity)</code>
<code>is_object($entity)</code>
</DocblockTypeContradiction>
<InvalidReturnStatement occurrences="7">
<code>$entity</code>
<InvalidReturnStatement occurrences="5">
<code>$entity</code>
<code>$entity</code>
<code>$entity instanceof $class-&gt;name ? $entity : null</code>
<code>$persister-&gt;load($sortedId, null, null, [], $lockMode)</code>
<code>$persister-&gt;loadById($sortedId)</code>
<code>$this-&gt;metadataFactory-&gt;getMetadataFor($className)</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="3">
<InvalidReturnType occurrences="2">
<code>?T</code>
<code>getClassMetadata</code>
<code>getReference</code>
</InvalidReturnType>
<InvalidScalarArgument occurrences="2">
<code>$hydrationMode</code>
Expand Down

0 comments on commit 0e3dfb5

Please sign in to comment.