From 7e4daf3c6dd4e2b1c2a8503e7a9b265b0e14e6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ren=C3=A9=20S=C3=B8rensen?= Date: Tue, 14 Jan 2025 11:11:13 +0100 Subject: [PATCH 1/2] Removed "of object" from docBlock in "Cycle\ORM\RepositoryInterface" --- src/RepositoryInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RepositoryInterface.php b/src/RepositoryInterface.php index 6d33fbe4..422cb9c5 100644 --- a/src/RepositoryInterface.php +++ b/src/RepositoryInterface.php @@ -7,7 +7,7 @@ /** * Defines ability to locate entities based on scope parameters. * - * @template TEntity of object + * @template TEntity */ interface RepositoryInterface { From 0bca2d18639a1ce4fd2b0199ebe97e14ce2c2c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ren=C3=A9=20S=C3=B8rensen?= Date: Tue, 14 Jan 2025 12:06:08 +0100 Subject: [PATCH 2/2] Fixes to the docBlocks to spicify the generic type for the RepositoryInterface. --- src/FactoryInterface.php | 5 +++++ src/Service/Implementation/RepositoryProvider.php | 2 +- src/Service/RepositoryProviderInterface.php | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/FactoryInterface.php b/src/FactoryInterface.php index 70a73c03..1f48526e 100644 --- a/src/FactoryInterface.php +++ b/src/FactoryInterface.php @@ -41,7 +41,12 @@ public function loader( ): LoaderInterface; /** + * @template TEntity + * * Create repository associated with given role. + * + * @param non-empty-string|class-string $role + * @return ($role is class-string ? RepositoryInterface : RepositoryInterface) */ public function repository( ORMInterface $orm, diff --git a/src/Service/Implementation/RepositoryProvider.php b/src/Service/Implementation/RepositoryProvider.php index 90ebec26..b8c074bd 100644 --- a/src/Service/Implementation/RepositoryProvider.php +++ b/src/Service/Implementation/RepositoryProvider.php @@ -18,7 +18,7 @@ */ final class RepositoryProvider implements RepositoryProviderInterface { - /** @var array */ + /** @var array> */ private array $repositories = []; public function __construct( diff --git a/src/Service/RepositoryProviderInterface.php b/src/Service/RepositoryProviderInterface.php index 12a04640..af6565bc 100644 --- a/src/Service/RepositoryProviderInterface.php +++ b/src/Service/RepositoryProviderInterface.php @@ -9,9 +9,12 @@ interface RepositoryProviderInterface { /** + * @template TEntity of object + * * Get repository associated with given entity role. * - * @param non-empty-string $entity + * @param class-string|non-empty-string $entity + * @return ($entity is class-string ? RepositoryInterface : RepositoryInterface) */ public function getRepository(string $entity): RepositoryInterface; }