From 2ac9fe0529fc256d9d172d3cd5b0174c09e60fe9 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Mon, 21 Aug 2023 09:29:06 -0400 Subject: [PATCH] Adding phpdoc generics for the interfaces --- src/MapperInterface.php | 15 +++++++++++++++ src/MicroMapperInterface.php | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/MapperInterface.php b/src/MapperInterface.php index 6da1a6a..bd05f4e 100644 --- a/src/MapperInterface.php +++ b/src/MapperInterface.php @@ -14,11 +14,26 @@ * * Also add #[AsMapper(from: Foo:class, to: Bar:class)] to each mapper class. * + * @template TFrom of object + * @template TTo of object + * * @author Ryan Weaver */ interface MapperInterface { + /** + * @param TFrom $from + * @param class-string $toClass + * + * @return TTo + */ public function load(object $from, string $toClass, array $context): object; + /** + * @param TFrom $from + * @param TTo $to + * + * @return TTo + */ public function populate(object $from, object $to, array $context): object; } diff --git a/src/MicroMapperInterface.php b/src/MicroMapperInterface.php index abf3320..03eadf3 100644 --- a/src/MicroMapperInterface.php +++ b/src/MicroMapperInterface.php @@ -11,10 +11,19 @@ /** * Maps one object to another using the configured mappers. + * + * @template TFrom of object + * @template TTo of object */ interface MicroMapperInterface { public const MAX_DEPTH = 'max_depth'; + /** + * @param TFrom $from + * @param class-string $toClass + * + * @return TTo + */ public function map(object $from, string $toClass, array $context = []): object; }