Instead of Mockery/Prophet, why do people not use anonymous classes? Oh, that's right. The vast majority of PHP developers have never bothered to learn them.
These are largely the same. You can, if you need to, ensure that each of those functions are called only once (use static $runCount), then they would be largely identical.
Instead of Mockery/Prophet, why do people not use anonymous classes? Oh, that's right. The vast majority of PHP developers have never bothered to learn them.
Take this:
It can be rewritten into this:
These are largely the same. You can, if you need to, ensure that each of those functions are called only once (use
static $runCount
), then they would be largely identical.I use a mocking framework because it is consistent with what other developers I work alongside will use.
I would have no problems using an anonymous class but I don't see the benefit it offers over a mature, well tested and known library.