From ea6e56ba7ecc418501ec23ac8d21010fdce5d8c8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 13 Jan 2022 18:29:54 +0100 Subject: [PATCH] feat: Simplified type signature of `TreeMapper#map()` to only require a single templated type This also brings `TreeMapper#map()` closer to PHPStorm support, whilst still benefiting from more precise `vimeo/psalm:4.18.x` types thanks to the conditional return specification. Ref: https://github.com/CuyZ/Valinor/pull/59#discussion_r782362428 --- src/Mapper/TreeMapper.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Mapper/TreeMapper.php b/src/Mapper/TreeMapper.php index e122c00b..d567e85d 100644 --- a/src/Mapper/TreeMapper.php +++ b/src/Mapper/TreeMapper.php @@ -7,16 +7,15 @@ interface TreeMapper { /** - * @psalm-template TObject of object - * @psalm-template TypeDefinition of string|class-string + * @template T of object * - * @param TypeDefinition $signature + * @param string|class-string $signature * @param mixed $source - * @return TObject|mixed + * @return T|mixed * * @psalm-return ( - * $signature is class-string - * ? TObject + * $signature is class-string + * ? T * : mixed * ) *