psalm icon indicating copy to clipboard operation
psalm copied to clipboard

False positive MethodSignatureMismatch on abstract method

Open GrandLTU opened this issue 6 years ago • 3 comments

https://psalm.dev/r/690466e7c2

GrandLTU avatar Apr 08 '20 18:04 GrandLTU

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

psalm-github-bot[bot] avatar Apr 08 '20 18:04 psalm-github-bot[bot]

Can't reproduce anymore: https://psalm.dev/r/690466e7c2

weirdan avatar Aug 17 '20 02:08 weirdan

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!

psalm-github-bot[bot] avatar Aug 17 '20 02:08 psalm-github-bot[bot]