Skip to content

Defining Array Constants in PHP Traits Causes Errors When Using Class Constants as Keys or Values #11351

@zengboin

Description

@zengboin

Bug report

When defining array constants within a PHP trait, if the array's keys or values utilize constants defined in the class that uses the trait, an error occurs. This issue hinders the ability to leverage class constants within trait-defined array constants, which can be a significant limitation in certain use cases.

Code snippet that reproduces the problem

https://phpstan.org/r/258a27f9-3c5a-4636-8f73-467efaeb5332

Expected output

OK

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions