eloquent / phony

Mocks, stubs, and spies for PHP.
http://eloquent-software.com/phony
MIT License
194 stars 7 forks source link

Method with final class as parameter #236

Closed pmall closed 6 years ago

pmall commented 6 years ago

I can't get around this situation:

<?php

final class FinalClass {}

class SomeClass
{
    public function someMethod(FinalClass $p) {}
}

$p = new FinalClass;

$handle = mock(SomeClass::class);
$handle->someMethod->with($p)->returns('something');

It throws a Eloquent\Phony\Mock\Exception\FinalClassException as soon as $handle->someMethod is called.

I know final classes can't be mocked but I can't figure out why it is a problem here. Is it a limitation of the library and is there a workaround for this?

pmall commented 6 years ago

My bad - seems to be a problem with the return type.