1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #925 - set correct flag when coercing class-like string to specific

This commit is contained in:
Matthew Brown 2018-08-20 22:25:10 -04:00
parent 8814dff3c1
commit 36e2b1dd67
2 changed files with 18 additions and 0 deletions

View File

@ -638,6 +638,7 @@ class TypeChecker
if ($input_type_part instanceof TClassString) {
$type_coerced = true;
$type_coerced_from_scalar = true;
return false;
}

View File

@ -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])) {}
}',
],
];
}