phpspec / prophecy

Highly opinionated mocking framework for PHP 5.3+
MIT License
8.53k stars 240 forks source link

Support for mocking methods with "static" return type #620

Open aik099 opened 3 months ago

aik099 commented 3 months ago

When attempting to mock a method with a static return type (see https://php.watch/versions/8.0/static-return-type), then you'll get this error:

Prophecy\Exception\Prophecy\MethodProphecyException: Cannot create a return value for the method as the type "static" is not supported. Configure an explicit return value instead.

Code:

class Process implements \IteratorAggregate
{
    public function mustRun(?callable $callback = null, array $env = []): static
    {
        return $this;
    }
}