Skip to content

Internal error: Failed to find parent class of constant #4288

@vworldat

Description

@vworldat

Bug report

Phpstan fails to find class constants when used as default argument value in a trait method. I have backtracked various phpstan versions. This has not been an issue up until phpstan 0.12.25, from 0.12.26 onwards it breaks on all versions i checked including the latest 0.12.58.

Code snippet that reproduces the problem

https://phpstan.org/r/c17faf82-5d21-4283-a324-b5976c6c1414

Things I have tried to make it pass:

  • constant visibility does not matter
  • method visibility does not matter
  • declaring class as final or not does not matter
  • the class extending a parent class does not matter
  • not declaring strict types does not matter
  • accessing the same constant from inside the method's body instead of the argument default value works fine: https://phpstan.org/r/2dd6fcf6-b07d-4ea6-9958-97c7393d24f0

Expected output

No errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions