vimeo / vimeo/psalm

Template in Trait method does not apply T to return type

Open
#8,563 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug templates traits
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.