mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #925 - set correct flag when coercing class-like string to specific
This commit is contained in:
parent
8814dff3c1
commit
36e2b1dd67
@ -638,6 +638,7 @@ class TypeChecker
|
||||
|
||||
if ($input_type_part instanceof TClassString) {
|
||||
$type_coerced = true;
|
||||
$type_coerced_from_scalar = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -221,6 +221,23 @@ class ConstantTest extends TestCase
|
||||
fwrite(STDOUT, "asd");
|
||||
fwrite(STDERR, "zcx");'
|
||||
],
|
||||
'classStringArrayOffset' => [
|
||||
'<?php
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
const C = [
|
||||
A::class => 1,
|
||||
B::class => 2,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param class-string $s
|
||||
*/
|
||||
function foo(string $s) : void {
|
||||
if (isset(C[$s])) {}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user