vimeo / vimeo/psalm

False positive on a method call inside a wrapper class when the called method's param is template T of static

Open
#11,368 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
5.9k
Forks
708
Avg merge
2d 3h
Merged PRs (30d)
25

Description

We have an abstract Uuid class in our project, which we use to differentiate between different types of Ids when we compare them, so it has an equals method.

When we compare Ids inside a wrapper class using the method, psalm complains about a wrong type of the param of the equals method of the Uuid class and somehow infers, that the type should have a connection to the wrapper class.

Expected Behavior:
no errors

Actual Behavior:
Argument 1 of UserId::equals expects User&static, but parent type UserId provided

The problem appears starting with psalm 6.5 so I guess this PR might be related https://github.com/vimeo/psalm/pull/11267

https://psalm.dev/r/6f7419118e

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 case in the Psalm playground at https://psalm.dev/r/6f7419118e and compare the behavior introduced around PR 11267. Trace the handling of template T of static for the equals call inside the wrapper class. Done means Psalm reports no error for this reproduction while preserving the intended type checking.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.