[DCOM-96] ProxyFactory logic moved to doctrine common

## Initial requirements

 1. Common proxy generation for:
      * [ORM](doctrine/doctrine2)
      * [MongoDB ODM](doctrine/mongodb-odm)
      * [CouchDB ODM](doctrine/couchdb-odm)
      * [PHPCR ODM](doctrine/phpcr-odm)
 2. Generic implementation of proxies: it is now possible to proxy any object as long as a `ClassMetadata` definition is provided
 3. Public properties lazy loading (yes we can!)

## Sample Proxy

See [this example generated proxy class](https://gist.github.com/4038004)

## Public properties lazy loading

Public properties lazy loading has been implemented, and I've opened php/php-src#228 to protect the trick discovered by @lsmith77.

Mapped public fields and associations will trigger lazy loading through `__get`, `__set` and `__isset`.

Transient properties and identifier fields won't trigger lazy loading. Same applies for simple identifier getters (as was already happening in ORM since 2.2). I've used the `ClassMetadata` interface to determine fields and associations to lazy load.

## New Proxy interface (not a BC Break)

```php
interface Proxy
{
    const MARKER = '__CG__';
    const MARKER_LENGTH = 6;
    public function __load();
    public function __isInitialized();
    public function __setInitialized($initialized);
    public function __setInitializer(Closure $initializer = null);
    public function __getInitializer();
    public function __setCloner(Closure $cloner = null);
    public function __getCloner();
    public function __getLazyProperties(); // retrieves default properties values - useful when restoring properties
}
```

## Lazy loading via closures

I came up with the idea of using closures to lazy load proxies. This allows removal of any reference to the `OjectManager`, and makes it possible to dump Proxy objects as long as there are not circular references between them (XDebug solves this).

The default constructor as of the current proxy generator implementation has following signature:

```php
public function __construct(Closure $initializer = null, Closure $cloner = null);
```

When used by the Proxy, the initializer will be called with object itself as first parameter, the called method name (the one that triggered lazy loading) as second parameter and the parameters that were passed to that method as third parameter.

This allows any of the current implementation to define an initialization logic (even outside the scope of persistence), and to eventually define some finer grained logic to be dispatched for LOB fields or getters/setters.

## Proxy generation

Generating a proxy requires that a valid instance of `Doctrine\Common\Persistence\Mapping\ClassMetadata` is passed to the `Doctrine\Common\Proxy\ProxyGenerator`. A proxy namespace and a proxy directory are also required to build the `ProxyGenerator` itself.

The generator uses a template and a list of placeholders mapped to either strings or callables. Those placeholders are used in the template while generating the Proxy class. Every callable mapped as a placeholder is called with the class metadata as first parameter. This should allow some fine-grained customization when the defaults of the proxy generator are not enough.

## Autoloading

Autoloader for proxies has been simply copied from the ORM.

## Testing

I tested each case that I could come up with. I need suggestions on edge cases that should be documented (like above, when I mentioned setting public properties and the [PHP bug](https://bugs.php.net/bug.php?id=63463)).

## Directions for MongoDB ODM/PHPCR implementors

I've opened following related PRs:

 * doctrine/doctrine2#406
 * doctrine/phpcr-odm#187
 * doctrine/mongodb-odm#445
 * doctrine/couchdb-odm#52

## Performance

 * When having identifier fields being private or protected, the proxy factory is twice as fast in instantiating a proxy compared to before (proxy factory to be seen in doctrine/doctrine2#406)
 * When having identifier fields being public, the proxy factory is twice as slow in instantiating a proxy compared to before. Hydration is also slower on public properties. This can be fixed by excluding the identifier fields from being associated to a `Doctrine\Common\Reflection\RuntimePublicReflectionProperty`, which is a workaround for [PHP Bug 63463](https://bugs.php.net/bug.php?id=63463). It could also be possible to speed up hydration of proxies by using bulk reflection operation.

That said, allover performance and memory usage is kept almost at same levels (sometimes even faster), but the new feature is introduced.