Skip to content

Template bound type throws invalid bound type error when referencing another type of the same templated class #3922

@ste93cry

Description

@ste93cry

Bug report

When a type of the template is bound to a generic type that references another template type, the following (false-positive) errors are thrown:

PHPDoc tag @template ... for class ... has invalid bound type ....
PHPDoc tag @template ... for interface ... has invalid bound type ....

I see at least two issues here: the first one is that the same error is thrown twice (for the same line) like if the analysis was done twice, not sure why (one time for the class and another for the interface, even though the line it's referring to is just the latter). The second and most severe issue is that PHPStan is not recognizing that the bound type is referencing another type of the same templated class.

Code snippet that reproduces the problem

https://phpstan.org/r/175d8c1a-3159-4d28-b761-7d1bb8d80bb2

Expected output

No error expected

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions