Skip to content
Permalink
Browse files

Fix combining class string types with explicit ones

  • Loading branch information
muglug committed Dec 2, 2019
1 parent ee6bf74 commit d5f4c24ee0796357f410eed54697f9e814c553d1
Showing with 16 additions and 0 deletions.
  1. +9 −0 src/Psalm/Internal/Type/TypeCombination.php
  2. +7 −0 tests/TypeCombinationTest.php
@@ -475,6 +475,15 @@ function (Type\Union $type) : bool {
}
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),
@@ -473,6 +473,13 @@ public function providerTestValidTypeCombination()
'class-string<Iterator>',
],
],
'combineClassStringsWithLiteral' => [
'class-string',
[
'class-string',
'Exception::class',
],
],
];
}

0 comments on commit d5f4c24

Please sign in to comment.
You can’t perform that action at this time.