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:
parent
3a5bb9db9a
commit
a3e51d6f13
@ -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,
|
||||
|
@ -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";
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user