psalm
psalm copied to clipboard
`is_a` not respected when result assigned to variable
Currently, the result of is_a()
is not respected when it's assigned to a variable.
https://psalm.dev/r/387b538c3f
I found these snippets:
https://psalm.dev/r/387b538c3f
<?php
interface Foo {}
interface Bar extends Foo {
public static function bar(): int;
}
/**
* @param class-string<Foo> $foo
*/
function foo(string $foo): void
{
$isBar = is_a($foo, Bar::class, true);
if ($isBar) {
$foo::bar();
}
if (is_a($foo, Bar::class, true)) {
$foo::bar();
}
}
Psalm output (using commit bf57d59):
ERROR: UndefinedMethod - 16:9 - Method Foo::bar does not exist