Skip to content

Commit

Permalink
Merge pull request #7054 from orklah/6933
Browse files Browse the repository at this point in the history
fix missing case for displaying varId
  • Loading branch information
orklah committed Dec 9, 2021
2 parents 761d5f3 + 0716dfc commit ae765df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -217,6 +217,10 @@ public static function getArrayVarId(
}
}

if ($stmt instanceof PhpParser\Node\Expr\ConstFetch) {
return implode('\\', $stmt->name->parts);
}

return self::getVarId($stmt, $this_class_name, $source);
}
}
9 changes: 8 additions & 1 deletion src/Psalm/Type/Reconciler.php
Expand Up @@ -4,6 +4,7 @@
use InvalidArgumentException;
use Psalm\CodeLocation;
use Psalm\Codebase;
use Psalm\Internal\Analyzer\Statements\Expression\Fetch\ConstFetchAnalyzer;
use Psalm\Internal\Analyzer\StatementsAnalyzer;
use Psalm\Internal\Codebase\TaintFlowGraph;
use Psalm\Internal\Codebase\VariableUseGraph;
Expand Down Expand Up @@ -553,7 +554,13 @@ private static function getValueForKey(
$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);
Expand Down

0 comments on commit ae765df

Please sign in to comment.