Skip to content

Commit

Permalink
feat: simplify type signature of TreeMapper#map()
Browse files Browse the repository at this point in the history
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: #59 (comment)
  • Loading branch information
Ocramius authored and romm committed Jan 13, 2022
1 parent f9b04c5 commit e280033
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 @@ -8,16 +8,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 e280033

Please sign in to comment.