1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix resolution for class names in lazily-evaluated class constants

Fixes #2413
This commit is contained in:
Brown 2019-12-04 13:33:50 -05:00
parent 3a5bb9db9a
commit a3e51d6f13
2 changed files with 25 additions and 1 deletions

View File

@ -1615,6 +1615,10 @@ class ClassLikes
}
if ($c instanceof UnresolvedConstant\ClassConstant) {
if ($c->name === 'class') {
return new Type\Atomic\TLiteralClassString($c->fqcln);
}
$found_type = $this->getConstantForClass(
$c->fqcln,
$c->name,

View File

@ -438,7 +438,27 @@ class ConstantTest extends TestCase
}
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";
}'
],
];
}