-
Notifications
You must be signed in to change notification settings - Fork 667
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
Defining enum case with a class constant causes a crash #8978
Comments
I found these snippets: https://psalm.dev/r/224fdb8a5d<?php
enum AppEnvs: string
{
case Development = Environments::DEV;
case Production = Environments::PROD;
case Testing = Environments::TEST;
}
class Environments {
public const DEV = 'dev';
public const PROD = 'prod';
public const TEST = 'test';
}
|
It seems to be because in if ($existing_class_constants === null
&& $file_source instanceof StatementsAnalyzer
) {
try {
$foreign_class_constant = $codebase->classlikes->getClassConstantType(
$const_fq_class_name,
$stmt->name->name,
ReflectionProperty::IS_PRIVATE,
$file_source,
);
if ($foreign_class_constant) {
return $foreign_class_constant;
}
return null;
} catch (InvalidArgumentException | CircularReferenceException $e) {
return null;
}
}
}
|
That's because we're trying to infer values in the scanning phase. When that fails, we need to store |
Hey, any update on this? Having a similar issue, and what is more frustrating is that directive does not work for a file with such error :( |
Resolves a number of long-standing bugs ('Failed to infer case value ...') Fixes vimeo#10374 Fixes vimeo#10560 Fixes vimeo#10643 Fixes vimeo#8978
Resolves a number of long-standing bugs ('Failed to infer case value ...') Fixes vimeo#10374 Fixes vimeo#10560 Fixes vimeo#10643 Fixes vimeo#8978
https://psalm.dev/r/224fdb8a5d
The text was updated successfully, but these errors were encountered: