diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php index 4516c9f74cf..3e68e23e762 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php @@ -101,6 +101,24 @@ public static function getGlobalConstType( 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(); if (($fq_const_name && array_key_exists($fq_const_name, $predefined_constants)) @@ -156,14 +174,6 @@ public static function getGlobalConstType( 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; } }