psalm
psalm copied to clipboard
False positive PossiblyUnusedReturnValue when value is used via interface but not in concrete class
Reproduce: https://psalm.dev/r/ba6aad7b6a
TestImpl::method1
is called within the TestImpl
class, and the return value is not used.
But at the mean time, this method is belongs to an interface, so it should not report this error.
Originally posted by @yyueniao in https://github.com/vimeo/psalm/issues/6021#issuecomment-1766452210
I found these snippets:
https://psalm.dev/r/ba6aad7b6a
<?php
interface TestInterface {
public function method1():string;
public function method2():void;
}
class TestImpl implements TestInterface {
public function method2():void{
$this->method1();
}
public function method1():string{
return "test";
}
}
function main(TestInterface $test):void {
echo $test->method1();
$test->method2();
}
main(new TestImpl());
Psalm output (using commit 24168f6):
ERROR: PossiblyUnusedReturnValue - 12:31 - The return value for this method is never used
@orklah Sorry i misused a wrong account, but it is me