From 4fc33a015c1a7ec0b5e3b85b62ee97166c6d0d98 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 28 Oct 2021 20:13:13 +0200 Subject: [PATCH] Make AuditReaderInterface generic --- src/Model/AuditManagerInterface.php | 4 +++- src/Model/AuditReaderInterface.php | 11 ++++++----- tests/Fixtures/Model/AuditReader.php | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Model/AuditManagerInterface.php b/src/Model/AuditManagerInterface.php index 2cd71f33af..81cd237e36 100644 --- a/src/Model/AuditManagerInterface.php +++ b/src/Model/AuditManagerInterface.php @@ -39,7 +39,9 @@ public function hasReader(string $class): bool; * * @throws \LogicException * - * @phpstan-param class-string $class + * @phpstan-template T of object + * @phpstan-param class-string $class + * @phpstan-return AuditReaderInterface */ public function getReader(string $class): AuditReaderInterface; } diff --git a/src/Model/AuditReaderInterface.php b/src/Model/AuditReaderInterface.php index e08a5be4d3..66ff2f2e5f 100644 --- a/src/Model/AuditReaderInterface.php +++ b/src/Model/AuditReaderInterface.php @@ -15,6 +15,8 @@ /** * @author Thomas Rabaix + * + * @phpstan-template T of object */ interface AuditReaderInterface { @@ -22,7 +24,6 @@ interface AuditReaderInterface * @param int|string $id * @param int|string $revisionId * - * @phpstan-template T of object * @phpstan-param class-string $className * @phpstan-return T|null */ @@ -31,14 +32,14 @@ public function find(string $className, $id, $revisionId): ?object; /** * @return Revision[] * - * @phpstan-param class-string $className + * @phpstan-param class-string $className */ public function findRevisionHistory(string $className, int $limit = 20, int $offset = 0): array; /** * @param int|string $revisionId * - * @phpstan-param class-string $className + * @phpstan-param class-string $className */ public function findRevision(string $className, $revisionId): ?Revision; @@ -47,7 +48,7 @@ public function findRevision(string $className, $revisionId): ?Revision; * * @return Revision[] * - * @phpstan-param class-string $className + * @phpstan-param class-string $className */ public function findRevisions(string $className, $id): array; @@ -58,7 +59,7 @@ public function findRevisions(string $className, $id): array; * * @return array * - * @phpstan-param class-string $className + * @phpstan-param class-string $className */ public function diff(string $className, $id, $oldRevisionId, $newRevisionId): array; } diff --git a/tests/Fixtures/Model/AuditReader.php b/tests/Fixtures/Model/AuditReader.php index e3b920aea8..1e8ccc7dce 100644 --- a/tests/Fixtures/Model/AuditReader.php +++ b/tests/Fixtures/Model/AuditReader.php @@ -16,6 +16,9 @@ use Sonata\AdminBundle\Model\AuditReaderInterface; use Sonata\AdminBundle\Model\Revision; +/** + * @phpstan-implements AuditReaderInterface + */ final class AuditReader implements AuditReaderInterface { public function find(string $className, $id, $revisionId): ?object