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:
parent
f7a37d05b9
commit
07934b8333
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user