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

Create a virtual ClassConstFetch when encountering a TLiteralClassString

This commit is contained in:
orklah 2021-07-29 20:23:53 +02:00
parent ffbdaa80b1
commit a1c4ece7bd

View File

@ -6,6 +6,7 @@ use PhpParser;
use Psalm\Internal\Scanner\ParsedDocblock;
use Psalm\Node\Expr\VirtualArray;
use Psalm\Node\Expr\VirtualArrayItem;
use Psalm\Node\Expr\VirtualClassConstFetch;
use Psalm\Node\Expr\VirtualConstFetch;
use Psalm\Node\Expr\VirtualVariable;
use Psalm\Node\Name\VirtualFullyQualified;
@ -331,6 +332,10 @@ class StubsGenerator
public static function getExpressionFromType(Type\Union $type) : PhpParser\Node\Expr
{
foreach ($type->getAtomicTypes() as $atomic_type) {
if ($atomic_type instanceof Type\Atomic\TLiteralClassString) {
return new VirtualClassConstFetch(new VirtualName($atomic_type->value), new VirtualIdentifier('class'));
}
if ($atomic_type instanceof Type\Atomic\TLiteralString) {
return new VirtualString($atomic_type->value);
}