-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UndefinedConstant when using enum property as const array key #9373
Labels
Comments
I found these snippets: https://psalm.dev/r/3307971eb7<?php
enum MyEnum: int
{
case CASE_1 = 3;
case CASE_2 = 4;
}
class A {
public const MY_CONST = [
MyEnum::CASE_1->value => 'enum case 1',
MyEnum::CASE_2->value => 'enum case 1',
];
}
class B {
public const MY_CONST = [
3 => 'enum case 1',
4 => 'enum case 1',
];
}
echo A::MY_CONST[MyEnum::CASE_1->value];
echo B::MY_CONST[MyEnum::CASE_1->value];
|
ygottschalk
added a commit
to ygottschalk/psalm
that referenced
this issue
Feb 23, 2023
The linked commit looks like it should fix it. |
ygottschalk
added a commit
to ygottschalk/psalm
that referenced
this issue
Feb 24, 2023
Still working on it, did not really fix the issue. PR should be incoming today |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using
Enum::CASE->value
orEnum::CASE->name
as key in constant, psalm throws UndefinedConstant error.No error is thrown when enum property is used as key in regular array (not const).
https://psalm.dev/r/3307971eb7
The text was updated successfully, but these errors were encountered: