diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index 26337da66..53ac270b5 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -509,7 +509,7 @@ class Union */ public function hasString() { - return isset($this->types['string']) || $this->literal_string_types; + return isset($this->types['string']) || isset($this->types['class-string']) || $this->literal_string_types; } /** diff --git a/tests/ClassStringTest.php b/tests/ClassStringTest.php index 251e8a1bd..7608f5c38 100644 --- a/tests/ClassStringTest.php +++ b/tests/ClassStringTest.php @@ -271,13 +271,27 @@ class ClassStringTest extends TestCase switch ($a) { case A::class: return; - + case B::class: case C::class: return; } }', ], + 'reconcileToFalsy' => [ + '