diff --git a/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Constructor.php b/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Constructor.php index 62ea5c69a..f1f586cfc 100644 --- a/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Constructor.php +++ b/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Constructor.php @@ -40,13 +40,13 @@ public function __construct(array $propertyAccessors) $this->setDocblock("@param \\ReflectionProperty[] \$propertyAccessors to hydrate private properties"); //$this->setParameter(new ParameterGenerator('propertyAccessors', 'array')); - $body = empty($propertyAccessors) ? '' : '$this->foobarbaztab = null; $values = & $this->foobarbaztab; '; + $body = empty($propertyAccessors) ? '' : '$values = & $this->foobarbaztab; $object = & $this->blargh;'; foreach ($propertyAccessors as $propertyAccessor) { $originalProperty = $propertyAccessor->getOriginalProperty(); $body .= '$this->' . $propertyAccessor->getName() - . ' = \Closure::bind(function ($object) use ($values) { $object->' + . ' = \Closure::bind(function () use (& $values, & $object) { $object->' . $originalProperty->getName() . ' = $values[' . var_export($originalProperty->getName(), true) . ']; }, null, ' . var_export($originalProperty->getDeclaringClass()->getName(), true) diff --git a/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Hydrate.php b/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Hydrate.php index 60ae66600..cbf2de42b 100644 --- a/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Hydrate.php +++ b/src/ProxyManager/ProxyGenerator/Hydrator/MethodGenerator/Hydrate.php @@ -52,14 +52,11 @@ public function __construct(array $accessibleProperties, array $propertyAccessor } if (! empty($propertyAccessors)) { - $body .= "\n\$this->foobarbaztab = \$data;\n\n"; + $body .= "\n\$this->foobarbaztab = \$data;\n\$this->blargh = \$object;\n\n"; } foreach ($propertyAccessors as $propertyAccessor) { - // @todo object by reference? - $body .= '$this->' - . $propertyAccessor->getName() - . "->__invoke(\$object);\n"; + $body .= '$this->' . $propertyAccessor->getName() . "->__invoke();\n"; } $body .= "\nreturn \$object;"; diff --git a/src/ProxyManager/ProxyGenerator/HydratorGenerator.php b/src/ProxyManager/ProxyGenerator/HydratorGenerator.php index f5fd58e60..3757f7b34 100644 --- a/src/ProxyManager/ProxyGenerator/HydratorGenerator.php +++ b/src/ProxyManager/ProxyGenerator/HydratorGenerator.php @@ -113,6 +113,7 @@ function (ReflectionMethod $method) use ($excluded) { $classGenerator->addProperties($propertyAccessors); if (! empty($propertyAccessors)) { $classGenerator->addProperties(array('foobarbaztab')); + $classGenerator->addProperties(array('blargh')); } $classGenerator->addMethodFromGenerator(new Constructor($propertyAccessors)); $classGenerator->addMethodFromGenerator(new Hydrate($accessibleProperties, $propertyAccessors));