feat: simplify type signature of TreeMapper#map()

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
This commit is contained in:
Marco Pivetta 2022-01-13 18:29:54 +01:00 committed by Romain Canon
parent f9b04c5c27
commit e280033941

View File

@ -8,16 +8,15 @@ namespace CuyZ\Valinor\Mapper;
interface TreeMapper
{
/**
* @psalm-template TObject of object
* @psalm-template TypeDefinition of string|class-string<TObject>
* @template T of object
*
* @param TypeDefinition $signature
* @param string|class-string<T> $signature
* @param mixed $source
* @return TObject|mixed
* @return T|mixed
*
* @psalm-return (
* $signature is class-string<TObject>
* ? TObject
* $signature is class-string<T>
* ? T
* : mixed
* )
*