Skip to content

Generic type resolution issue with method chaining when static return type breaks global generic parameter #12680

Closed

Description

@kayw-geek

Bug report

The issues appear in PHPStan 2.x.

Code snippet that reproduces the problem

https://phpstan.org/r/427a4280-7c91-4286-a5b4-5199a8fd33f5

Expected output

Parsed generic values

Did PHPStan help you today? Did it make you happy in any way?

No response

Activity

  1. kayw-geek commented on Mar 17, 2025

    @kayw-geek
    Author

    The bug looked is seem be resolve in latest version.

  2. ondrejmirtes commented on Mar 17, 2025

    @ondrejmirtes
    Member

    This isn't really fixed. I believe all the lines should say mixed: https://phpstan.org/r/c2b8d2e5-de05-4b8d-9d99-2e56e86edcb9

  3. added this to the Generics milestone on Mar 17, 2025
  4. phpstan-bot commented on Mar 17, 2025

    @phpstan-bot
    Contributor

    @kayw-geek After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:

    @@ @@
     28: Dumped type: TValue (class Collection, parameter)
    -30: Dumped type: mixed
    +30: Dumped type: TValue (class Collection, parameter)
    Full report
    Line Error
    28 Dumped type: TValue (class Collection, parameter)
    30 Dumped type: TValue (class Collection, parameter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions