Skip to content

Commit

Permalink
feat: Simplified type signature of TreeMapper#map() to only require…
Browse files Browse the repository at this point in the history
… 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: CuyZ#59 (comment)
  • Loading branch information
Ocramius committed Jan 13, 2022
1 parent 77e0100 commit ea6e56b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Mapper/TreeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
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
* )
*
Expand Down

0 comments on commit ea6e56b

Please sign in to comment.