mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #2644 - improve type inference of autoloaded constants
This commit is contained in:
parent
24e1d5446c
commit
471d7610f0
@ -101,6 +101,24 @@ class ConstFetchAnalyzer
|
|||||||
return Type::getResource();
|
return Type::getResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($fq_const_name) {
|
||||||
|
$stubbed_const_type = $codebase->getStubbedConstantType(
|
||||||
|
$fq_const_name
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($stubbed_const_type) {
|
||||||
|
return $stubbed_const_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$stubbed_const_type = $codebase->getStubbedConstantType(
|
||||||
|
$const_name
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($stubbed_const_type) {
|
||||||
|
return $stubbed_const_type;
|
||||||
|
}
|
||||||
|
|
||||||
$predefined_constants = $codebase->config->getPredefinedConstants();
|
$predefined_constants = $codebase->config->getPredefinedConstants();
|
||||||
|
|
||||||
if (($fq_const_name && array_key_exists($fq_const_name, $predefined_constants))
|
if (($fq_const_name && array_key_exists($fq_const_name, $predefined_constants))
|
||||||
@ -156,14 +174,6 @@ class ConstFetchAnalyzer
|
|||||||
return ClassLikeAnalyzer::getTypeFromValue($predefined_constants[$const_name]);
|
return ClassLikeAnalyzer::getTypeFromValue($predefined_constants[$const_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stubbed_const_type = $codebase->getStubbedConstantType(
|
|
||||||
$fq_const_name ?: $const_name
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($stubbed_const_type) {
|
|
||||||
return $stubbed_const_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user