I get that people want to do that, it's so comfortable. But is it really a good idea? When I have that kind of problem, I use:
class Foo{
protected $date = "date";
function getDate(){
return ($this->date)();
}
}
$mockFoo = new class extends Foo{ protected $date = "my_fake_date"; };
Or dependency injection (I inject the function as closure in the ctor).
Alternatively, you could consider using https://github.com/krakjoe/uopz
which allows to redefine functions at runtime.
