diff --git a/lib/Doctrine/Persistence/ManagerRegistry.php b/lib/Doctrine/Persistence/ManagerRegistry.php index b28664ce..aa504b8a 100644 --- a/lib/Doctrine/Persistence/ManagerRegistry.php +++ b/lib/Doctrine/Persistence/ManagerRegistry.php @@ -76,6 +76,10 @@ public function getManagerNames(); * @param string $persistentManagerName The object manager name (null for the default one). * * @return ObjectRepository + * + * @template T + * @psalm-param class-string $persistentObject + * @psalm-return ObjectRepository */ public function getRepository($persistentObject, $persistentManagerName = null); diff --git a/lib/Doctrine/Persistence/ObjectManager.php b/lib/Doctrine/Persistence/ObjectManager.php index 9b4a9dbf..831fb3f0 100644 --- a/lib/Doctrine/Persistence/ObjectManager.php +++ b/lib/Doctrine/Persistence/ObjectManager.php @@ -20,6 +20,10 @@ interface ObjectManager * @param mixed $id The identity of the object to find. * * @return object|null The found object. + * + * @template T + * @psalm-param class-string $className + * @psalm-return T|null */ public function find($className, $id); @@ -111,9 +115,9 @@ public function flush(); /** * Gets the repository for a class. * - * @param string $className - * - * @return ObjectRepository + * @template T + * @psalm-param class-string $className + * @psalm-return ObjectRepository */ public function getRepository($className); diff --git a/lib/Doctrine/Persistence/ObjectRepository.php b/lib/Doctrine/Persistence/ObjectRepository.php index 7661be20..005e9581 100644 --- a/lib/Doctrine/Persistence/ObjectRepository.php +++ b/lib/Doctrine/Persistence/ObjectRepository.php @@ -7,6 +7,8 @@ /** * Contract for a Doctrine persistence layer ObjectRepository class to implement. + * + * @template T */ interface ObjectRepository { @@ -16,13 +18,17 @@ interface ObjectRepository * @param mixed $id The identifier. * * @return object|null The object. + * + * @psalm-return T|null */ public function find($id); /** * Finds all objects in the repository. * - * @return object[] The objects. + * @return array The objects. + * + * @psalm-return T[] */ public function findAll(); @@ -41,6 +47,8 @@ public function findAll(); * @return object[] The objects. * * @throws UnexpectedValueException + * + * @psalm-return T[] */ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null); @@ -50,6 +58,8 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $ * @param mixed[] $criteria The criteria. * * @return object|null The object. + * + * @psalm-return T|null */ public function findOneBy(array $criteria);