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

Fix combining class string types with explicit ones

This commit is contained in:
Matthew Brown 2019-12-01 23:03:09 -05:00
parent ee6bf74a41
commit d5f4c24ee0
2 changed files with 16 additions and 0 deletions

View File

@ -475,6 +475,15 @@ class TypeCombination
}
if ($combination->class_string_types) {
if ($combination->strings) {
foreach ($combination->strings as $k => $string) {
if ($string instanceof TLiteralClassString) {
$combination->class_string_types[$string->value] = new TNamedObject($string->value);
unset($combination->strings[$k]);
}
}
}
if (!isset($combination->value_types['string'])) {
$object_type = self::combineTypes(
array_values($combination->class_string_types),

View File

@ -473,6 +473,13 @@ class TypeCombinationTest extends TestCase
'class-string<Iterator>',
],
],
'combineClassStringsWithLiteral' => [
'class-string',
[
'class-string',
'Exception::class',
],
],
];
}