Skip to content

Commit

Permalink
Fix #2644 - improve type inference of autoloaded constants
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 17, 2020
1 parent 24e1d54 commit 471d761
Showing 1 changed file with 18 additions and 8 deletions.
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 471d761

Please sign in to comment.