psalm icon indicating copy to clipboard operation
psalm copied to clipboard

False positive MethodSignatureMismatch for php 7.4

Open GrandLTU opened this issue 6 years ago • 1 comments

https://psalm.dev/r/33c181de5d

Since php 7.4 supports covariant return types this is valid now

GrandLTU avatar Apr 01 '20 10:04 GrandLTU

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

psalm-github-bot[bot] avatar Apr 01 '20 10:04 psalm-github-bot[bot]