1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix union of literal class string

This commit is contained in:
Matthew Brown 2019-06-06 17:18:24 -04:00
parent 9aeaf1a4ed
commit b091ceaa9a
2 changed files with 7 additions and 8 deletions

View File

@ -370,7 +370,7 @@ class Union
}
$printed_float = true;
} elseif ($type instanceof TLiteralString) {
} elseif ($type instanceof TLiteralString && !$type instanceof Type\Atomic\TLiteralClassString) {
if ($printed_string) {
continue;
}
@ -1690,12 +1690,9 @@ class Union
foreach ($this->types as $key => $atomic_type) {
$atomic_type->replaceClassLike($old, $new);
unset($this->types[$key]);
$this->types[$atomic_type->getKey()] = $atomic_type;
$this->removeType($key);
$this->addType($atomic_type);
}
$this->id = null;
}
/**

View File

@ -94,9 +94,10 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
/**
* @param A $a
* @param A::class|C::class $b
* @return A
*/
function foo(A $a) : A {
function foo(A $a, string $b) : A {
return $a;
}
@ -118,9 +119,10 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
/**
* @param B $a
* @param B::class|C::class $b
* @return B
*/
function foo(B $a) : B {
function foo(B $a, string $b) : B {
return $a;
}