1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

allow Reconciler to retrieve global constant values

This commit is contained in:
orklah 2021-12-09 21:27:57 +01:00
parent 2612f5a5f1
commit 0716dfcda0

View File

@ -3,6 +3,7 @@ namespace Psalm\Type;
use Psalm\CodeLocation;
use Psalm\Codebase;
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\ConstFetchAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Type\AssertionReconciler;
use Psalm\Issue\DocblockTypeContradiction;
@ -543,7 +544,13 @@ class Reconciler
$key_parts = self::breakUpPathIntoParts($key);
if (count($key_parts) === 1) {
return isset($existing_keys[$key_parts[0]]) ? clone $existing_keys[$key_parts[0]] : null;
if (isset($existing_keys[$key_parts[0]])) {
return clone $existing_keys[$key_parts[0]];
}
if ($type = ConstFetchAnalyzer::getGlobalConstType($codebase, $key_parts[0], $key_parts[0])) {
return $type;
}
}
$base_key = array_shift($key_parts);