Skip to content
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

Internal Psalm error: 'Failed to infer case value' when using a constant from a class as enum value. #10272

Closed
mestefanell-rentman opened this issue Oct 10, 2023 · 1 comment · Fixed by #10274

Comments

@mestefanell-rentman
Copy link

When using a constant from a class as the enum value, an error raises with the message Failed to infer case value for $ENUM_CASE$. Functionally it's accepted and works but Psalm throws an error.

Here's a code snippet to reproduce it https://psalm.dev/r/fb70dd37d2

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/fb70dd37d2
<?php

abstract class AbstractClass {

	public const CASE_1 = "Case 1";
	public const CASE_2 = "Case 2";
}

enum EnumUsingAbstractClassConstants: string {
	case ENUM_CASE_1 = AbstractClass::CASE_1;
	case ENUM_CASE_2 = AbstractClass::CASE_2;
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php: Failed to infer case value for ENUM_CASE_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant