Skip to content

Tags: mgid/ProxyManager

Tags

2.2.0

Toggle 2.2.0's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
## 2.2.0

This release provides support for the PHP 7.2 `object` type hint, as
well as dramatic (~300%) speed improvement during proxy class generation.
PHP 7.1 support has been dropped.

Total issues resolved: **11**

- [367: Property name (suffixes) differ after each generation of a proxy](Ocramius#367) thanks to @holtkamp
- [381: Adding `object` hit based tests and test assets - preparing for PHP 7.2 compatibility](Ocramius#381) thanks to @Ocramius
- [382: Removed redundant docblocks](Ocramius#382) thanks to @Ocramius
- [383: PHPStan version upgrade 0.8](Ocramius#383) thanks to @Ocramius
- [384: Group generated unique identifiers by name](Ocramius#384) thanks to @nicolas-grekas
- [385: Ocramius#384 Ocramius#367 deterministic generated property suffixes for generated properties](Ocramius#385) thanks to @Ocramius
- [386: Removed licence headers from all single source files](Ocramius#386) thanks to @Ocramius
- [387: Correct createProxy PHPDoc](Ocramius#387) thanks to @PurpleBooth
- [391: PHPUnit 6.x upgrade](Ocramius#391) thanks to @Ocramius
- [392: PHPStan level 7 analysis](Ocramius#392) thanks to @snapshotpl
- [393: remove inheritdoc & body parsing from generated proxies](Ocramius#393) thanks to @Tobion

2.1.1

Toggle 2.1.1's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
This release provides aggressive improvements in static introspection…

… via

[phpstan/phpstan](https://github.com/phpstan/phpstan). No functional
changes, just removed possible bugs due to excessive parameter count
in method calls, as well as test type hint fixes.

Total issues resolved: **3**

- [351: Travis already has xdebug pre-installed for PHP 7.1](Ocramius#351)
- [358: Fix Ocramius#351 - travis has xdebug pre-installed for PHP 7.1](Ocramius#358)
- [361: PHPStan inspection fixes](Ocramius#361)

2.1.0

Toggle 2.1.0's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
## 2.1.0

### Improved

- Introduced support for PHP 7.1, `void` and nullable (`?`)
  types [Ocramius#314](Ocramius#314)
  [Ocramius#327](Ocramius#327)
- The test suite is now fully CI-covered by mutation testing [Ocramius#348](Ocramius#348)
- Moved all performance testing to PHPBench [Ocramius#326](Ocramius#326)
- PHP 7.0 support dropped [Ocramius#327](Ocramius#327)

Total issues resolved: **9**

- [290: Branch-alias version bump: master bump to 3.0.x](Ocramius#290)
- [314: Nullable params type](Ocramius#314)
- [326: Moved performance tests to phpbench-based suite](Ocramius#326)
- [327: PHP 7.1 support](Ocramius#327)
- [336: Hotfix tests for php 7 support](Ocramius#336)
- [339: Provided type ?... is invalid](Ocramius#339)
- [343: Fix typo in ghost objects lazy loading code example](Ocramius#343)
- [348: Introduced full mutation testing](Ocramius#348)
- [349: install xdebug manually for php 7.1](Ocramius#349)

2.0.4

Toggle 2.0.4's commit message
 ## 2.0.4

 ### Fixed

- Remove deprecated `getMock` usage from tests
[Ocramius#325](Ocramius#325)
- Fix incorrect type in docs example
[Ocramius#329](Ocramius#329)
- Bug when proxy `__get` magic method
[Ocramius#344](Ocramius#344)
- Fix lazy loading value holder magic method support
[Ocramius#345](Ocramius#345)

Total issues resolved: **4**

2.0.3

Toggle 2.0.3's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
## 2.0.3

### Fixed

- Various test suite cleanups, mostly because of
  [new PHPUnit 5.4.0 deprecations being introduced](https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0)
  [Ocramius#318](Ocramius#318)
- Removed `zendframework/zend-code:3.0.3` from installable dependencies, since
  a critical bug was introduced in it [Ocramius#321](Ocramius#321) 
  [Ocramius#323](Ocramius#323)
  [Ocramius#324](Ocramius#324). Please upgrade to
  `zendframework/zend-code:3.0.4` or newer.

Total issues resolved: **4**
- [318: Cleanup: remove unused imports, deprecated method usage, static/non-static assertion mixup](Ocramius#318)
- [321: Syntax error, unexpected '\' (T&Ocramius#95;NS&Ocramius#95;SEPARATOR) when using Zend-Code 3.0.3](Ocramius#321)
- [323: Excluding `zendframework/zend-code` `3.0.3` from compatible dependencies](Ocramius#323)
- [324: Excluding `zendframework/zend-code` `3.0.3` from compatible dependencies (2.0.x backport)](Ocramius#324)

2.0.2

Toggle 2.0.2's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
- Various optimizations were performed in the [`ocramius/package-vers…

…ions`](https://github.com/Ocramius/PackageVersions)

  integration in order to prevent "class not found" fatals. [Ocramius#294](Ocramius#294)
- Null objects produced via a given class name were not extending from the given class name, causing obvious LSP
  compliance and type-compatibility issues. [Ocramius#300](Ocramius#300)
  [Ocramius#301](Ocramius#301)
- Specific installation versions were removed from the [README.md](README.md) install instructions, since composer
  is installing the latest available version by default. [Ocramius#305](Ocramius#305)
- PHP 7.0.6 support was dropped. PHP 7.0.6 includes some nasty reflection bugs that caused `__isset` to be called when
  `ReflectionProperty#getValue()` is used (https://bugs.php.net/72174).
  [Ocramius#306](Ocramius#306)
  [Ocramius#308](Ocramius#308)
- PHP 7.0.7 contains additional limitations as to when `$this` can be used. Specifically, `$this` cannot be used as a
  parameter name for closures that have an already assigned `$this`. Due to `$this` being incorrectly used as parameter
  name within this library, running ProxyManager on PHP 7.0.7 would have caused a fatal error.
  [Ocramius#306](Ocramius#306)
  [Ocramius#308](Ocramius#308)
  [Ocramius#316](Ocramius#316)
- PHP 7.1.0-DEV includes type-checks for incompatible arithmetic operations: some of those operations were erroneously
  performed in the library internals. [Ocramius#308](Ocramius#308)

Total issues resolved: **12**
- [294: Fatal error: Class 'ProxyManager\Versions' not found](Ocramius#294)
- [296: Forward port the changelog for 2.0.1 to master as well](Ocramius#296)
- [300: Null objects do not extend their original class](Ocramius#300)
- [301: Correcting null object inheritance - null objects were not extending from their original class](Ocramius#301)
- [305: Update version on README installation example](Ocramius#305)
- [306: PHP 7.0.6 is incompatible with ProxyManager 2.x](Ocramius#306)
- [308: PHP 7.0.7 compatibility](Ocramius#308)
- [310: Port 2.0.1 changelogs to master branch](Ocramius#310)
- [313: Documentation fixlets](Ocramius#313)
- [315: Update lazy-loading-value-holder.md](Ocramius#315)
- [316: Symfony Lazy Services don't work with PHP 7.0.7](Ocramius#316)
- [317: Hotfix: PHP 7.0.7 compatibility (backport for 2.0.2)](Ocramius#317)

2.0.0

Toggle 2.0.0's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
## New features

#### PHP 7 support

ProxyManager will now correctly operate in PHP 7 environments.

#### PHP 7 Return type hints

ProxyManager will now correctly mimic signatures of methods with return type hints:

```php
class SayHello
{
    public function hello() : string
    {
        return 'hello!';
    }
}
```

#### PHP 7 Scalar type hints

ProxyManager will now correctly mimic signatures of methods with scalar type hints

```php
class SayHello
{
    public function hello(string $name) : string
    {
        return 'hello, ' . $name;
    }
}
```

#### PHP 5.6 Variadics support

ProxyManager will now correctly mimic behavior of methods with variadic parameters:

```php
class SayHello
{
    public function hello(string ...$names) : string
    {
        return 'hello, ' . implode(', ', $names);
    }
}
```

By-ref variadic arguments are also supported:

```php
class SayHello
{
    public function hello(string ... & $names)
    {
        foreach ($names as & $name) {
            $name = 'hello, ' . $name;
        }
    }
}
```

#### Constructors in proxies are not replaced anymore

In ProxyManager v1.x, the constructor of a proxy was completely replaced with a method
accepting proxy-specific parameters.

This is no longer true, and you will be able to use the constructor of your objects as
if the class wasn't proxied at all:

```php
class SayHello
{
    public function __construct()
    {
        echo 'Hello!';
    }
}

/* @var $proxyGenerator \ProxyManager\ProxyGenerator\ProxyGeneratorInterface */
$proxyClass = $proxyGenerator->generateProxy(
    new ReflectionClass(SayHello::class),
    new ClassGenerator('ProxyClassName')
);

eval('<?php ' . $proxyClass->generate());

$proxyName = $proxyClass->getName();
$object = new ProxyClassName(); // echoes "Hello!"

var_dump($object); // a proxy object
```

If you still want to manually build a proxy (without factories), a
`public static staticProxyConstructor` method is added to the generated proxy classes.

#### Friend classes support

You can now access state of "friend objects" at any time.

```php
class EmailAddress
{
    private $address;

    public function __construct(string $address)
    {
        assertEmail($address);
        
        $this->address = $address;
    }
    
    public function equalsTo(EmailAddress $other)
    {
        return $this->address === $other->address;
    }
}
```

When using lazy-loading or access-interceptors, the `equalsTo` method will
properly work, as even `protected` and `private` access are now correctly proxied.

#### Ghost objects now only lazy-load on state-access

Lazy loading ghost objects now trigger lazy-loading only when their state is accessed.
This also implies that lazy loading ghost objects cannot be used with interfaces anymore.

```php
class AccessPolicy
{
    private $policyName;
    
    /**
     * Calling this method WILL cause lazy-loading, when using a ghost object,
     * as the method is accessing the object's state
     */
    public function getPolicyName() : string
    {
        return $this->policyName;        
    }
    
    /**
     * Calling this method WILL NOT cause lazy-loading, when using a ghost object,
     * as the method is not reading any from the object.
     */
    public function allowAccess() : bool
    {
        return false;
    }
}
```

#### Faster ghost object state initialization

Lazy loading ghost objects can now be initialized in a more efficient way, by avoiding
reflection or setters:

```php
class Foo
{
    private $a;
    protected $b;
    public $c;
}

$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory();

$proxy = $factory-createProxy(
    Foo::class,
    function (
        GhostObjectInterface $proxy, 
        string $method, 
        array $parameters, 
        & $initializer,
        array $properties
    ) {
        $initializer   = null;

        $properties["\0Foo\0a"] = 'abc';
        $properties["\0*\0b"]   = 'def';
        $properties['c']        = 'ghi';

        return true;
    }
);


$reflectionA = new ReflectionProperty(Foo::class, 'a');
$reflectionA->setAccessible(true);

var_dump($reflectionA->getValue($proxy)); // dumps "abc"

$reflectionB = new ReflectionProperty(Foo::class, 'b');
$reflectionB->setAccessible(true);

var_dump($reflectionB->getValue($proxy)); // dumps "def"

var_dump($proxy->c); // dumps "ghi"
```

#### Skipping lazy-loaded properties in generated proxies

Lazy loading ghost objects can now skip lazy-loading for certain properties.
This is especially useful when you have properties that are always available,
such as identifiers of entities:

```php
class User
{
    private $id;
    private $username;

    public function getId() : int
    {
        return $this->id;
    }

    public function getUsername() : string
    {
        return $this->username;
    }
}

/* @var $proxy User */
$proxy = (new \ProxyManager\Factory\LazyLoadingGhostFactory())->createProxy(
    User::class,
    function (
        GhostObjectInterface $proxy,
        string $method,
        array $parameters,
        & $initializer,
        array $properties
    ) {
        $initializer   = null;

        var_dump('Triggered lazy-loading!');

        $properties["\0User\0username"] = 'Ocramius';

        return true;
    },
    [
        'skippedProperties' => [
            "\0User\0id",
        ],
    ]
);

$idReflection = new \ReflectionProperty(User::class, 'id');

$idReflection->setAccessible(true);
$idReflection->setValue($proxy, 123);

var_dump($proxy->getId());       // 123
var_dump($proxy->getUsername()); // "Triggered lazy-loading!", then "Ocramius"
```

#### Proxies are now always generated on-the-fly by default

Proxies are now automatically generated any time you require them: no configuration
needed. If you want to gain better performance, you may still want to read
the [tuning for production docs](docs/tuning-for-production.md).

#### Proxy names are now hashed, simplified signature is attached to them

Proxy classes now have shorter names, as the parameters used to generate them are
hashed into their name. A signature is attached to proxy classes (as a private static
property) so that proxy classes aren't re-used across library updates.
Upgrading ProxyManager will now cause all proxies to be re-generated automatically,
while the old proxy files are going to be ignored.

## BC Breaks - backwards-incompatible changes

 * PHP `~7.0` is now required to use ProxyManager
 * HHVM compatibility is not guaranteed, as HHVM is not yet PHP 7 compliant
 * All classes and interfaces now use [strict scalar type hints](http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration).
   If you extended or implemented anything from the `ProxyManager\` namespace, you probably need to change
   that code to adapt it to the new signature.
 * All classes and interfaces now use [return type declarations](http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration).
   If you extended or implemented anything from the `ProxyManager\` namespace, you probably need to change
   that code to adapt it to the new signature.
 * ProxyManager will no longer write proxies to disk by default:
   the [`EvaluatingGeneratorStrategy`](src/GeneratorStrategy/EvaluatingGeneratorStrategy.php) is used instead.
   If you still want ProxyManager to write files to disk, please refer to the [tuning for production docs](docs/tuning-for-production.md)
 * Ghost objects were entirely rewritten, for better support and improved performance. Lazy-loading is not
   triggered by public API access, but by property access (private and public). While this is not really a BC
   break, you are encouraged to check your applications if you rely on [ghost objects](docs/lazy-loading-ghost-object.md).
 * If ProxyManager can't find a proxy, it will now automatically attempt to auto-generate it, regardless of
   the settings passed to it.
 * `ProxyManager\Configuration#setAutoGenerateProxies()` was removed. Please look for calls to this method and
   remove them.
 * Private properties are now also correctly handled by ProxyManager: accessing proxy state via friend classes
   (protected or private scope) does not require any particular workarounds anymore.
 * `ProxyManager\Version::VERSION` was removed. Please use `ProxyManager\Version::getVersion()` instead.
 * PHP 4 style constructors are no longer supported

## Changes (raw log)

Total issues resolved: **66**

- [97: Private properties of superclasses are not considered when generating proxies](Ocramius#97)
- [105: Make the evaluating generator strategy a default](Ocramius#105)
- [115: RFC: Recited: Give me my constructor back](Ocramius#115)
- [128: Removal of PHP 5.3 support](Ocramius#128)
- [130: &Ocramius#91;WIP&Ocramius#92; Master branch dev version / 2.0.x dependencies](Ocramius#130)
- [152: Rewrite Ghost Objects to only rely on property lazy loading](Ocramius#152)
- [159: Ideas/considerations for GhostObject Proxies lazy loading](Ocramius#159)
- [167: Drop PHP 5.4 support](Ocramius#167)
- [175: Avoid constructor override](Ocramius#175)
- [177: Add variadics support](Ocramius#177)
- [184: Split documentation homepage into a &quot;features&quot; page, remove duplicate content](Ocramius#184)
- [186: Remove deprecated `ProxyManager\Configuration#setAutoGenerateProxies()`](Ocramius#186)
- [192: Lazy-loading of ghost objects only via properties access (no method overrides)](Ocramius#192)
- [200: Remove deprecated methods on ProxyManager\Configuration](Ocramius#200)
- [203: Remove duplicated content on documentation Ocramius#184](Ocramius#203)
- [204: Cleanup: Ocramius#167 - remove PHP 5.4 support](Ocramius#204)
- [205: Skipping files/directories that are not needed in deployed versions of ProxyManager in the packaged version of the repo](Ocramius#205)
- [208: Document new `GhostObject` behavior (property lazy-loading, by-ref initialization)](Ocramius#208)
- [209: Modify the strategy on Configuration#getGeneratorStrategy to use EvaluationGeneratorStrategy class as default](Ocramius#209)
- [211: Move documentation to be generated by couscous](Ocramius#211)
- [212: Allow skipping properties in `LazyLoadingGhost` for partial initialization](Ocramius#212)
- [214: Cleanup: unused classes removal (constructors, not needed as per Ocramius#115 and Ocramius#175)](Ocramius#214)
- [215: Cleanup: unused imports](Ocramius#215)
- [218: Ocramius#97: handle private properties of superclasses](Ocramius#218)
- [219: Cleanup: run codegen smoke-tests in same process](Ocramius#219)
- [220: CS: imported symbols cleanups](Ocramius#220)
- [221: Skip properties when use ghost objects](Ocramius#221)
- [222: Hotfix: Ghost object generators cannot proxy interfaces, therefore should throw exceptions](Ocramius#222)
- [224: Disable private/protected property checks during lazy loading initialization of GhostObjects](Ocramius#224)
- [225: Ocramius#224 - GhostObjects can simply ignore scope checks during lazy-loading (temporarily fixes Ocramius#210)](Ocramius#225)
- [232: Variadic function support](Ocramius#232)
- [234: Fix html titles](Ocramius#234)
- [237: remove unused title table at README.md ?](Ocramius#237)
- [238: Fix title when rendering](Ocramius#238)
- [239: Skip test inapplicable to php7](Ocramius#239)
- [240: Support scalar type hints (PHP 7)](Ocramius#240)
- [246: Don't suggest package that is already required.](Ocramius#246)
- [247: Hotfix: PHP 7 warnings on binding internal classes](Ocramius#247)
- [251: Hotfix - Ocramius#249 file writer generator strategy rename failures (2.0.x rebase)](Ocramius#251)
- [252: Moving to new travis build infrastructure](Ocramius#252)
- [255: Fix: Use all the columns](Ocramius#255)
- [256: Revert Ocramius#254, add integration test for options in factory logic](Ocramius#256)
- [261: Fix a typo in main.css stylesheet](Ocramius#261)
- [263: Broken links in footer http://ocramius.github.io/ProxyManager/](https://github.com/Ocramius/ProxyManager/issues/263)
- [264: Duplicate semicolons generated](Ocramius#264)
- [265: Document limitation of pre-5.6 variadic usage](Ocramius#265)
- [266: Ocramius#265 - by-ref variadic support](Ocramius#266)
- [267: Ocramius#264 - duplicate semicolon removal](Ocramius#267)
- [268: Ocramius#263 - correcting links in the footer of the docs](Ocramius#268)
- [271: Feature - Ocramius#241 - support scalar type hints](Ocramius#271)
- [272: Document 2.0.0 changes](Ocramius#272)
- [273: The homepage of the doc is confusing](Ocramius#273)
- [274: Add scalar and return type hints where applicable, use strict types](Ocramius#274)
- [276: Test protected member access lazy loading (ghost objects)](Ocramius#276)
- [277: Fix/Ocramius#276 protected member access via friend objects](Ocramius#277)
- [278: Ocramius#274 - scalar type hints, return type hints, strict types](Ocramius#278)
- [279: Feature - Ocramius#274 void and missing return types](Ocramius#279)
- [280: Ocramius#273 - fix homepage docs link, fix presentation link](Ocramius#280)
- [281: Docs - Ocramius#208 document new ghost object behavior](Ocramius#281)
- [282: Grammar improvements to lazy loading ghost object docs](Ocramius#282)
- [283: Docs - Ocramius#272 - document 2.0.0 changes](Ocramius#283)
- [284: Remove the need for a `Version` class](Ocramius#284)
- [285: Feature - Ocramius#284 - dynamic package version resolution](Ocramius#285)
- [287: Docs - Ocramius#272 - document 2.0.0 changes](Ocramius#287)
- [288: Ocramius#276 - testing friend object access against skipped properties](Ocramius#288)
- [289: Suggested stability timeline for 2.x](Ocramius#289)

2.0.0-BETA3

Toggle 2.0.0-BETA3's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
## New features

#### PHP 7 support

ProxyManager will now correctly operate in PHP 7 environments.

#### PHP 7 Return type hints

ProxyManager will now correctly mimic signatures of methods with return type hints:

```php
class SayHello
{
    public function hello() : string
    {
        return 'hello!';
    }
}
```

#### PHP 7 Scalar type hints

ProxyManager will now correctly mimic signatures of methods with scalar type hints

```php
class SayHello
{
    public function hello(string $name) : string
    {
        return 'hello, ' . $name;
    }
}
```

#### PHP 5.6 Variadics support

ProxyManager will now correctly mimic behavior of methods with variadic parameters:

```php
class SayHello
{
    public function hello(string ...$names) : string
    {
        return 'hello, ' . implode(', ', $names);
    }
}
```

By-ref variadic arguments are also supported:

```php
class SayHello
{
    public function hello(string ... & $names)
    {
        foreach ($names as & $name) {
            $name = 'hello, ' . $name;
        }
    }
}
```

#### Constructors in proxies are not replaced anymore

In ProxyManager v1.x, the constructor of a proxy was completely replaced with a method
accepting proxy-specific parameters.

This is no longer true, and you will be able to use the constructor of your objects as
if the class wasn't proxied at all:

```php
class SayHello
{
    public function __construct()
    {
        echo 'Hello!';
    }
}

/* @var $proxyGenerator \ProxyManager\ProxyGenerator\ProxyGeneratorInterface */
$proxyClass = $proxyGenerator->generateProxy(
    new ReflectionClass(SayHello::class),
    new ClassGenerator('ProxyClassName')
);

eval('<?php ' . $proxyClass->generate());

$proxyName = $proxyClass->getName();
$object = new ProxyClassName(); // echoes "Hello!"

var_dump($object); // a proxy object
```

If you still want to manually build a proxy (without factories), a
`public static staticProxyConstructor` method is added to the generated proxy classes.

#### Friend classes support

You can now access state of "friend objects" at any time.

```php
class EmailAddress
{
    private $address;

    public function __construct(string $address)
    {
        assertEmail($address);
        
        $this->address = $address;
    }
    
    public function equalsTo(EmailAddress $other)
    {
        return $this->address === $other->address;
    }
}
```

When using lazy-loading or access-interceptors, the `equalsTo` method will
properly work, as even `protected` and `private` access are now correctly proxied.

#### Ghost objects now only lazy-load on state-access

Lazy loading ghost objects now trigger lazy-loading only when their state is accessed.
This also implies that lazy loading ghost objects cannot be used with interfaces anymore.

```php
class AccessPolicy
{
    private $policyName;
    
    /**
     * Calling this method WILL cause lazy-loading, when using a ghost object,
     * as the method is accessing the object's state
     */
    public function getPolicyName() : string
    {
        return $this->policyName;        
    }
    
    /**
     * Calling this method WILL NOT cause lazy-loading, when using a ghost object,
     * as the method is not reading any from the object.
     */
    public function allowAccess() : bool
    {
        return false;
    }
}
```

#### Faster ghost object state initialization

Lazy loading ghost objects can now be initialized in a more efficient way, by avoiding
reflection or setters:

```php
class Foo
{
    private $a;
    protected $b;
    public $c;
}

$factory = new \ProxyManager\Factory\LazyLoadingGhostFactory();

$proxy = $factory-createProxy(
    Foo::class,
    function (
        GhostObjectInterface $proxy, 
        string $method, 
        array $parameters, 
        & $initializer,
        array $properties
    ) {
        $initializer   = null;

        $properties["\0Foo\0a"] = 'abc';
        $properties["\0*\0b"]   = 'def';
        $properties['c']        = 'ghi';

        return true;
    }
);


$reflectionA = new ReflectionProperty(Foo::class, 'a');
$reflectionA->setAccessible(true);

var_dump($reflectionA->getValue($proxy)); // dumps "abc"

$reflectionB = new ReflectionProperty(Foo::class, 'b');
$reflectionB->setAccessible(true);

var_dump($reflectionB->getValue($proxy)); // dumps "def"

var_dump($proxy->c); // dumps "ghi"
```

#### Skipping lazy-loaded properties in generated proxies

Lazy loading ghost objects can now skip lazy-loading for certain properties.
This is especially useful when you have properties that are always available,
such as identifiers of entities:

```php
class User
{
    private $id;
    private $username;

    public function getId() : int
    {
        return $this->id;
    }

    public function getUsername() : string
    {
        return $this->username;
    }
}

/* @var $proxy User */
$proxy = (new \ProxyManager\Factory\LazyLoadingGhostFactory())->createProxy(
    User::class,
    function (
        GhostObjectInterface $proxy,
        string $method,
        array $parameters,
        & $initializer,
        array $properties
    ) {
        $initializer   = null;

        var_dump('Triggered lazy-loading!');

        $properties["\0User\0username"] = 'Ocramius';

        return true;
    },
    [
        'skippedProperties' => [
            "\0User\0id",
        ],
    ]
);

$idReflection = new \ReflectionProperty(User::class, 'id');

$idReflection->setAccessible(true);
$idReflection->setValue($proxy, 123);

var_dump($proxy->getId());       // 123
var_dump($proxy->getUsername()); // "Triggered lazy-loading!", then "Ocramius"
```

#### Proxies are now always generated on-the-fly by default

Proxies are now automatically generated any time you require them: no configuration
needed. If you want to gain better performance, you may still want to read
the [tuning for production docs](docs/tuning-for-production.md).

#### Proxy names are now hashed, simplified signature is attached to them

Proxy classes now have shorter names, as the parameters used to generate them are
hashed into their name. A signature is attached to proxy classes (as a private static
property) so that proxy classes aren't re-used across library updates.
Upgrading ProxyManager will now cause all proxies to be re-generated automatically,
while the old proxy files are going to be ignored.

## BC Breaks - backwards-incompatible changes

 * PHP `~7.0` is now required to use ProxyManager
 * HHVM compatibility is not guaranteed, as HHVM is not yet PHP 7 compliant
 * All classes and interfaces now use [strict scalar type hints](http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration).
   If you extended or implemented anything from the `ProxyManager\` namespace, you probably need to change
   that code to adapt it to the new signature.
 * All classes and interfaces now use [return type declarations](http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration).
   If you extended or implemented anything from the `ProxyManager\` namespace, you probably need to change
   that code to adapt it to the new signature.
 * ProxyManager will no longer write proxies to disk by default:
   the [`EvaluatingGeneratorStrategy`](src/GeneratorStrategy/EvaluatingGeneratorStrategy.php) is used instead.
   If you still want ProxyManager to write files to disk, please refer to the [tuning for production docs](docs/tuning-for-production.md)
 * Ghost objects were entirely rewritten, for better support and improved performance. Lazy-loading is not
   triggered by public API access, but by property access (private and public). While this is not really a BC
   break, you are encouraged to check your applications if you rely on [ghost objects](docs/lazy-loading-ghost-object.md).
 * If ProxyManager can't find a proxy, it will now automatically attempt to auto-generate it, regardless of
   the settings passed to it.
 * `ProxyManager\Configuration#setAutoGenerateProxies()` was removed. Please look for calls to this method and
   remove them.
 * Private properties are now also correctly handled by ProxyManager: accessing proxy state via friend classes
   (protected or private scope) does not require any particular workarounds anymore.
 * `ProxyManager\Version::VERSION` was removed. Please use `ProxyManager\Version::getVersion()` instead.
 * PHP 4 style constructors are no longer supported

## Changes (raw log)

Total issues resolved: **65**

- [97: Private properties of superclasses are not considered when generating proxies](Ocramius#97)
- [105: Make the evaluating generator strategy a default](Ocramius#105)
- [115: RFC: Recited: Give me my constructor back](Ocramius#115)
- [128: Removal of PHP 5.3 support](Ocramius#128)
- [130: &Ocramius#91;WIP&Ocramius#92; Master branch dev version / 2.0.x dependencies](Ocramius#130)
- [152: Rewrite Ghost Objects to only rely on property lazy loading](Ocramius#152)
- [159: Ideas/considerations for GhostObject Proxies lazy loading](Ocramius#159)
- [167: Drop PHP 5.4 support](Ocramius#167)
- [175: Avoid constructor override](Ocramius#175)
- [177: Add variadics support](Ocramius#177)
- [184: Split documentation homepage into a &quot;features&quot; page, remove duplicate content](Ocramius#184)
- [186: Remove deprecated `ProxyManager\Configuration#setAutoGenerateProxies()`](Ocramius#186)
- [192: Lazy-loading of ghost objects only via properties access (no method overrides)](Ocramius#192)
- [200: Remove deprecated methods on ProxyManager\Configuration](Ocramius#200)
- [203: Remove duplicated content on documentation Ocramius#184](Ocramius#203)
- [204: Cleanup: Ocramius#167 - remove PHP 5.4 support](Ocramius#204)
- [205: Skipping files/directories that are not needed in deployed versions of ProxyManager in the packaged version of the repo](Ocramius#205)
- [208: Document new `GhostObject` behavior (property lazy-loading, by-ref initialization)](Ocramius#208)
- [209: Modify the strategy on Configuration#getGeneratorStrategy to use EvaluationGeneratorStrategy class as default](Ocramius#209)
- [211: Move documentation to be generated by couscous](Ocramius#211)
- [212: Allow skipping properties in `LazyLoadingGhost` for partial initialization](Ocramius#212)
- [214: Cleanup: unused classes removal (constructors, not needed as per Ocramius#115 and Ocramius#175)](Ocramius#214)
- [215: Cleanup: unused imports](Ocramius#215)
- [218: Ocramius#97: handle private properties of superclasses](Ocramius#218)
- [219: Cleanup: run codegen smoke-tests in same process](Ocramius#219)
- [220: CS: imported symbols cleanups](Ocramius#220)
- [221: Skip properties when use ghost objects](Ocramius#221)
- [222: Hotfix: Ghost object generators cannot proxy interfaces, therefore should throw exceptions](Ocramius#222)
- [224: Disable private/protected property checks during lazy loading initialization of GhostObjects](Ocramius#224)
- [225: Ocramius#224 - GhostObjects can simply ignore scope checks during lazy-loading (temporarily fixes Ocramius#210)](Ocramius#225)
- [232: Variadic function support](Ocramius#232)
- [234: Fix html titles](Ocramius#234)
- [237: remove unused title table at README.md ?](Ocramius#237)
- [238: Fix title when rendering](Ocramius#238)
- [239: Skip test inapplicable to php7](Ocramius#239)
- [240: Support scalar type hints (PHP 7)](Ocramius#240)
- [246: Don't suggest package that is already required.](Ocramius#246)
- [247: Hotfix: PHP 7 warnings on binding internal classes](Ocramius#247)
- [251: Hotfix - Ocramius#249 file writer generator strategy rename failures (2.0.x rebase)](Ocramius#251)
- [252: Moving to new travis build infrastructure](Ocramius#252)
- [255: Fix: Use all the columns](Ocramius#255)
- [256: Revert Ocramius#254, add integration test for options in factory logic](Ocramius#256)
- [261: Fix a typo in main.css stylesheet](Ocramius#261)
- [263: Broken links in footer http://ocramius.github.io/ProxyManager/](https://github.com/Ocramius/ProxyManager/issues/263)
- [264: Duplicate semicolons generated](Ocramius#264)
- [265: Document limitation of pre-5.6 variadic usage](Ocramius#265)
- [266: Ocramius#265 - by-ref variadic support](Ocramius#266)
- [267: Ocramius#264 - duplicate semicolon removal](Ocramius#267)
- [268: Ocramius#263 - correcting links in the footer of the docs](Ocramius#268)
- [271: Feature - Ocramius#241 - support scalar type hints](Ocramius#271)
- [272: Document 2.0.0 changes](Ocramius#272)
- [273: The homepage of the doc is confusing](Ocramius#273)
- [274: Add scalar and return type hints where applicable, use strict types](Ocramius#274)
- [276: Test protected member access lazy loading (ghost objects)](Ocramius#276)
- [277: Fix/Ocramius#276 protected member access via friend objects](Ocramius#277)
- [278: Ocramius#274 - scalar type hints, return type hints, strict types](Ocramius#278)
- [279: Feature - Ocramius#274 void and missing return types](Ocramius#279)
- [280: Ocramius#273 - fix homepage docs link, fix presentation link](Ocramius#280)
- [281: Docs - Ocramius#208 document new ghost object behavior](Ocramius#281)
- [282: Grammar improvements to lazy loading ghost object docs](Ocramius#282)
- [283: Docs - Ocramius#272 - document 2.0.0 changes](Ocramius#283)
- [284: Remove the need for a `Version` class](Ocramius#284)
- [285: Feature - Ocramius#284 - dynamic package version resolution](Ocramius#285)
- [287: Docs - Ocramius#272 - document 2.0.0 changes](Ocramius#287)
- [288: Ocramius#276 - testing friend object access against skipped properties](Ocramius#288)

2.0.0-BETA2

Toggle 2.0.0-BETA2's commit message

Verified

This tag was signed with the committer’s verified signature.
Ocramius Marco Pivetta
Total issues resolved: **59**

- [97: Private properties of superclasses are not considered when generating proxies](Ocramius#97)
- [105: Make the evaluating generator strategy a default](Ocramius#105)
- [115: RFC: Recited: Give me my constructor back](Ocramius#115)
- [128: Removal of PHP 5.3 support](Ocramius#128)
- [130: &Ocramius#91;WIP&Ocramius#92; Master branch dev version / 2.0.x dependencies](Ocramius#130)
- [152: Rewrite Ghost Objects to only rely on property lazy loading](Ocramius#152)
- [159: Ideas/considerations for GhostObject Proxies lazy loading](Ocramius#159)
- [167: Drop PHP 5.4 support](Ocramius#167)
- [175: Avoid constructor override](Ocramius#175)
- [177: Add variadics support](Ocramius#177)
- [184: Split documentation homepage into a &quot;features&quot; page, remove duplicate content](Ocramius#184)
- [186: Remove deprecated `ProxyManager\Configuration#setAutoGenerateProxies()`](Ocramius#186)
- [192: Lazy-loading of ghost objects only via properties access (no method overrides)](Ocramius#192)
- [200: Remove deprecated methods on ProxyManager\Configuration](Ocramius#200)
- [203: Remove duplicated content on documentation Ocramius#184](Ocramius#203)
- [204: Cleanup: Ocramius#167 - remove PHP 5.4 support](Ocramius#204)
- [205: Skipping files/directories that are not needed in deployed versions of ProxyManager in the packaged version of the repo](Ocramius#205)
- [208: Document new `GhostObject` behavior (property lazy-loading, by-ref initialization)](Ocramius#208)
- [209: Modify the strategy on Configuration#getGeneratorStrategy to use EvaluationGeneratorStrategy class as default](Ocramius#209)
- [211: Move documentation to be generated by couscous](Ocramius#211)
- [212: Allow skipping properties in `LazyLoadingGhost` for partial initialization](Ocramius#212)
- [214: Cleanup: unused classes removal (constructors, not needed as per Ocramius#115 and Ocramius#175)](Ocramius#214)
- [215: Cleanup: unused imports](Ocramius#215)
- [218: Ocramius#97: handle private properties of superclasses](Ocramius#218)
- [219: Cleanup: run codegen smoke-tests in same process](Ocramius#219)
- [220: CS: imported symbols cleanups](Ocramius#220)
- [221: Skip properties when use ghost objects](Ocramius#221)
- [222: Hotfix: Ghost object generators cannot proxy interfaces, therefore should throw exceptions](Ocramius#222)
- [224: Disable private/protected property checks during lazy loading initialization of GhostObjects](Ocramius#224)
- [225: Ocramius#224 - GhostObjects can simply ignore scope checks during lazy-loading (temporarily fixes Ocramius#210)](Ocramius#225)
- [232: Variadic function support](Ocramius#232)
- [234: Fix html titles](Ocramius#234)
- [237: remove unused title table at README.md ?](Ocramius#237)
- [238: Fix title when rendering](Ocramius#238)
- [239: Skip test inapplicable to php7](Ocramius#239)
- [240: Support scalar type hints (PHP 7)](Ocramius#240)
- [246: Don't suggest package that is already required.](Ocramius#246)
- [247: Hotfix: PHP 7 warnings on binding internal classes](Ocramius#247)
- [251: Hotfix - Ocramius#249 file writer generator strategy rename failures (2.0.x rebase)](Ocramius#251)
- [252: Moving to new travis build infrastructure](Ocramius#252)
- [255: Fix: Use all the columns](Ocramius#255)
- [256: Revert Ocramius#254, add integration test for options in factory logic](Ocramius#256)
- [261: Fix a typo in main.css stylesheet](Ocramius#261)
- [263: Broken links in footer http://ocramius.github.io/ProxyManager/](https://github.com/Ocramius/ProxyManager/issues/263)
- [264: Duplicate semicolons generated](Ocramius#264)
- [265: Document limitation of pre-5.6 variadic usage](Ocramius#265)
- [266: Ocramius#265 - by-ref variadic support](Ocramius#266)
- [267: Ocramius#264 - duplicate semicolon removal](Ocramius#267)
- [268: Ocramius#263 - correcting links in the footer of the docs](Ocramius#268)
- [271: Feature - Ocramius#241 - support scalar type hints](Ocramius#271)
- [273: The homepage of the doc is confusing](Ocramius#273)
- [274: Add scalar and return type hints where applicable, use strict types](Ocramius#274)
- [276: Test protected member access lazy loading (ghost objects)](Ocramius#276)
- [277: Fix/Ocramius#276 protected member access via friend objects](Ocramius#277)
- [278: Ocramius#274 - scalar type hints, return type hints, strict types](Ocramius#278)
- [279: Feature - Ocramius#274 void and missing return types](Ocramius#279)
- [280: Ocramius#273 - fix homepage docs link, fix presentation link](Ocramius#280)
- [281: Docs - Ocramius#208 document new ghost object behavior](Ocramius#281)
- [282: Grammar improvements to lazy loading ghost object docs](Ocramius#282)
- [284: Remove the need for a `Version` class](Ocramius#284)
- [285: Feature - Ocramius#284 - dynamic package version resolution](Ocramius#285)