Template in Trait method does not apply T to return type
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 5.9k
- Forks
- 708
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 25
Description
This example works in PHPStan and even PhpStorm recognizes the correct type (with its limited template implementation), do I overlook something?
Tested version 4.25 + 4.28
https://psalm.dev/r/d5129c097a
https://phpstan.org/r/f5f40c20-17ca-4069-ab0e-d1c7184cd3d1
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported trait-template return-type behavior using the Psalm example at psalm.dev/r/d5129c097a and compare it with the PHPStan reproduction. Determine the expected inferred type and verify the behavior against the tested Psalm versions; done means the trait method's return type is inferred as expected and the reproduction no longer demonstrates a discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100