eloquent / phony

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

Problems stubbing methods that return instances of a final class #231

Closed ezzatron closed 6 years ago

ezzatron commented 6 years ago

If you have a method that returns instances of a final class, and you attempt to stub using ->with(), a final class exception seems to be thrown:

$handle = mock(ClassA::class);
$handle->methodThatReturnsFinalClass->with('something')->returns($instanceOfFinalClass);

Needs more investigation.

ezzatron commented 6 years ago

As far as I can tell, this is a red herring. The exception actually gets thrown when the mock is called, and there is no matching rule, which makes total sense.