padraic/mockery — pull request #159 by davedevelopment (2013-05-15 22:40:52+00:00)
Title: [WIP] Generator Rewrite

I've rewritten the generator.

I came to the conclusion that a php-parser generator will be too slow for now (see #118), so I went ahead and implemented some of the architecture I went with on that, but with the same string manipulation for generating mocks.

Why should we merge this?

Loader is injectable
-----------------------------

By default, it uses `eval` to load the defined classes, but you can use a require version, helping with stacktraces

``` php
\Mockery::setLoader(new \Mockery\Loader\RequireLoader());
```

Generator is injectable
--------------------------------

Like the loader, the geneator can be injected, allowing for different implementations, which can help with...

Performance
-----------------

Because the generators accept a `Mockery\Generator\MockConfiguration` object, which tries not to reflect anything until it has to and has a `getHash` method, we can cache the calls to the generator and reuse a mock that is already defined. This is achieved with the `Mockery\Generator\CachingGenerator`, which simply decorates any other `Mockery\Generator\Generator`.

On my suite of 800 tests, majority London style, with xdebug on:

``master``: **Time: 36 seconds, Memory: 285.00Mb**
``parameter-object``: **Time: 13 seconds, Memory: 72.25Mb**

Cleaner
-----------

The code is slightly cleaner than that in master. I've wrapped a lot of the reflection stuff, which should allow us to add workarounds when needed in a reasonable way, along with isolated tests for them etc.

Effort
--------

I worked my balls off on this.

It's not quite ready yet, I think there's some work to on instance mocks, but I'm interested in feedback. The commit history is a bit of a mess, so there's a good chance I'll squash some of it before actually requesting a merge.