psalm
psalm copied to clipboard
False positive MethodSignatureMismatch on abstract method
https://psalm.dev/r/690466e7c2
I found these snippets:
https://psalm.dev/r/690466e7c2
<?php declare(strict_types=1);
interface A {
}
interface B {
}
interface C extends A, B {
}
interface AA {
public function foo(): A;
}
abstract class BB {
abstract public function foo(): B;
}
abstract class CC extends BB implements AA {
abstract public function foo(): C;
}
class CC2 extends BB implements AA {
public function foo(): C {
throw new Exception();
}
}
Psalm output (using commit b2e010b):
ERROR: MethodSignatureMismatch - 20:16 - Method BB::foo with return type 'B' is different to return type 'A' of inherited method AA::foo
Can't reproduce anymore: https://psalm.dev/r/690466e7c2
I found these snippets:
https://psalm.dev/r/690466e7c2
<?php declare(strict_types=1);
interface A {
}
interface B {
}
interface C extends A, B {
}
interface AA {
public function foo(): A;
}
abstract class BB {
abstract public function foo(): B;
}
abstract class CC extends BB implements AA {
abstract public function foo(): C;
}
class CC2 extends BB implements AA {
public function foo(): C {
throw new Exception();
}
}
Psalm output (using commit bb3c5d4):
No issues!