1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix isString check for class strings

This commit is contained in:
Brown 2018-11-02 17:03:49 -04:00
parent f7a37d05b9
commit 07934b8333
2 changed files with 16 additions and 2 deletions

View File

@ -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;
}
/**

View File

@ -271,13 +271,27 @@ class ClassStringTest extends TestCase
switch ($a) {
case A::class:
return;
case B::class:
case C::class:
return;
}
}',
],
'reconcileToFalsy' => [
'<?php
class A {}
/** @psalm-return ?class-string */
function foo() : ?string {
if (rand(0, 1)) return null;
return A::class;
}
$a = foo();
$a ? 1 : 0;',
],
];
}