Skip to content

Commit

Permalink
Fix for inferring enum case value from a class constant, const test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tuqqu committed Oct 12, 2023
1 parent 6039e2b commit 8988ff6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Psalm\Internal\Analyzer\Statements\Expression\BinaryOp\ArithmeticOpAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Provider\NodeDataProvider;
use Psalm\Internal\Scanner\FileScanner;
use Psalm\Internal\Type\TypeCombiner;
use Psalm\StatementsSource;
use Psalm\Storage\ClassConstantStorage;
Expand Down Expand Up @@ -337,7 +338,10 @@ public static function infer(
return Type::getLiteralClassString($const_fq_class_name, true);
}

if ($existing_class_constants === null || $existing_class_constants === []) {
if ($existing_class_constants === null
|| $existing_class_constants === []
&& $file_source !== null
) {
try {
$foreign_class_constant = $codebase->classlikes->getClassConstantType(
$const_fq_class_name,
Expand Down

0 comments on commit 8988ff6

Please sign in to comment.