mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #993 - create class string from reconciled assertions where necessary
This commit is contained in:
parent
661087d445
commit
1b7f215406
@ -1450,6 +1450,10 @@ class Reconciler
|
||||
}
|
||||
} elseif ($scalar_type === 'string' || $scalar_type === 'class-string') {
|
||||
if ($existing_var_type->isMixed()) {
|
||||
if ($scalar_type === 'class-string') {
|
||||
return new Type\Union([new Type\Atomic\TLiteralClassString($value)]);
|
||||
}
|
||||
|
||||
return new Type\Union([new Type\Atomic\TLiteralString($value)]);
|
||||
}
|
||||
|
||||
|
@ -260,6 +260,24 @@ class ClassStringTest extends TestCase
|
||||
if ($class === A::class) {}
|
||||
}',
|
||||
],
|
||||
'switchMixedVar' => [
|
||||
'<?php
|
||||
class A {}
|
||||
class B {}
|
||||
class C {}
|
||||
|
||||
/** @param mixed $a */
|
||||
function foo($a) : void {
|
||||
switch ($a) {
|
||||
case A::class:
|
||||
return;
|
||||
|
||||
case B::class:
|
||||
case C::class:
|
||||
return;
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user