psalm
psalm copied to clipboard
False positive MethodSignatureMismatch for php 7.4
https://psalm.dev/r/33c181de5d
Since php 7.4 supports covariant return types this is valid now
I found these snippets:
https://psalm.dev/r/33c181de5d
<?php
trait FooTrait
{
/**
* @return $this
*/
public function bar(): self
{
return $this;
}
}
interface FooInterface
{
/**
* @return $this
*/
public function bar(): self;
}
class FooClass implements FooInterface {
use FooTrait;
}
Psalm output (using commit 5876635):
ERROR: MethodSignatureMismatch - 22:7 - Method FooTrait::bar with return type 'FooTrait' is different to return type 'FooInterface' of inherited method FooInterface::bar