php-mock/php-mock-phpunit

InvocationOrder - it is not an interface

ptomulik opened this issue · 1 comments

Another bug spotted by psalm:

Using reflection to locate file for phpmock\phpunit\DefaultArgumentRemoverReturnTypes
PHP Fatal error:  phpmock\phpunit\DefaultArgumentRemoverReturnTypes cannot implement PHPUnit\Framework\MockObject\Rule\InvocationOrder - it is not an interface in php-mock/php-mock-phpunit/classes/DefaultArgumentRemoverReturnTypes.php on line 17
Fatal error: phpmock\phpunit\DefaultArgumentRemoverReturnTypes cannot implement PHPUnit\Framework\MockObject\Rule\InvocationOrder - it is not an interface in /php-mock/php-mock-phpunit/classes/DefaultArgumentRemoverReturnTypes.php on line 17

The buggy file contains:

use PHPUnit\Framework\MockObject\Matcher\Invocation as InvocationInterface;
// ....
class DefaultArgumentRemoverReturnTypes implements InvocationInterface

and there is an alias in autoload.php, that maps PHPUnit\Framework\MockObject\Matcher\Invocation to PHPUnit\Framework\MockObject\Rule\InvocationOrder, but InvocationOrder is an abstract class, thus it can't be implemented, it should rather be extended.

The interface PHPUnit\Framework\MockObject\Matcher\Invocation exists until PHPUnit 8.3.5. It disappears in 8.4.0. There is abstract class ...\Matcher\InvocationOrder since 8.4.0 and ...\Matcher\* stuff is moved to ...\Rule\* in 8.4.1.

Oh my, this file is used conditionally. Perhaps psalm is wrong trying to load it. Sorry for the noise.