You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phpabstractclass A {}
class B extends A {}
functiona(A$a): void {
switch ($a::class) {
case B::class:
b($a);
}
switch (get_class($a)) {
case B::class:
b($a);
}
}
functionb(B$b): void {
}
Psalm output (using commit 698adef):
ERROR: ArgumentTypeCoercion - 9:15 - Argument 1 of b expects B, parent type A provided
INFO: UnusedParam - 18:14 - Param $b is never referenced in this method
<?phpabstractclass A {}
class B extends A {}
functiona(A$a): void {
if($a::class == B::class) {
b($a);
}
}
functionb(B$b): void {
}
Psalm output (using commit cd74f66):
ERROR: ArgumentTypeCoercion - 8:11 - Argument 1 of b expects B, parent type A provided
INFO: UnusedParam - 12:14 - Param $b is never referenced in this method
When using
$object::class
in switch statement, narrowing the type usingcase $child::class
does not narrow it for psalmget_class()
still works fine.https://psalm.dev/r/c8c3fadc13
crosslink for previous issue #5479
The text was updated successfully, but these errors were encountered: