Skip to content
Permalink
Browse files

Fix resolution for class names in lazily-evaluated class constants

Fixes #2413
  • Loading branch information
muglug committed Dec 4, 2019
1 parent 3a5bb9d commit a3e51d6f13e2007300a5ecac6bad24f46622b540
Showing with 25 additions and 1 deletion.
  1. +4 −0 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +21 −1 tests/ConstantTest.php
@@ -1615,6 +1615,10 @@ private function resolveConstantType(
}

if ($c instanceof UnresolvedConstant\ClassConstant) {
if ($c->name === 'class') {
return new Type\Atomic\TLiteralClassString($c->fqcln);
}

$found_type = $this->getConstantForClass(
$c->fqcln,
$c->name,
@@ -438,7 +438,27 @@ class Clazz {
}
echo Clazz::cons2;',
]
],
'classConstantClassReferencedLazily' => [
'<?php
/** @return array<string, int> */
function getMap(): array {
return Mapper::MAP;
}
class Mapper {
public const MAP = [
Foo::class => self::A,
Foo::BAR => self::A,
];
private const A = 5;
}
class Foo {
public const BAR = "bar";
}'
],
];
}

0 comments on commit a3e51d6

Please sign in to comment.
You can’t perform that action at this time.