Skip to content

Commit

Permalink
Removing last required bits of Zend\Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 19, 2013
1 parent 797b623 commit 2b51c5c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

namespace GeneratedHydrator\ClassGenerator\Hydrator\PropertyGenerator;

use PHPParser_Node_Stmt_Class;
use PHPParser_Node_Stmt_Property;
use ReflectionProperty;
use Zend\Code\Generator\PropertyGenerator;
use CodeGenerationUtils\Inflector\Util\UniqueIdentifierGenerator;

/**
Expand All @@ -29,7 +30,7 @@
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class PropertyAccessor extends PropertyGenerator
class PropertyAccessor extends PHPParser_Node_Stmt_Property
{
/**
* @var \ReflectionProperty
Expand All @@ -44,10 +45,12 @@ public function __construct(ReflectionProperty $accessedProperty, $nameSuffix)
{
$this->accessedProperty = $accessedProperty;
$originalName = $this->accessedProperty->getName();
$name = UniqueIdentifierGenerator::getIdentifier($originalName . $nameSuffix);

parent::__construct(UniqueIdentifierGenerator::getIdentifier($originalName . $nameSuffix));
$this->setVisibility(self::VISIBILITY_PRIVATE);
$this->setDocblock("@var \\ReflectionProperty used to access {@see parent::$originalName}");
parent::__construct(
PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE,
array(new \PHPParser_Node_Stmt_PropertyProperty($name))
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function replaceConstructor(PHPParser_Node_Stmt_ClassMethod $method = nu
$bodyParts = array();

foreach ($this->propertyWriters as $propertyWriter) {
$accessorName = $propertyWriter->getName();
$accessorName = $propertyWriter->props[0]->name;
$originalProperty = $propertyWriter->getOriginalProperty();
$className = $originalProperty->getDeclaringClass()->getName();
$property = $originalProperty->getName();
Expand Down Expand Up @@ -104,7 +104,7 @@ private function replaceHydrate(PHPParser_Node_Stmt_ClassMethod $method = null)

foreach ($this->propertyWriters as $propertyWriter) {
$body .= '$this->'
. $propertyWriter->getName()
. $propertyWriter->props[0]->name
. '->__invoke($object, $data['
. var_export($propertyWriter->getOriginalProperty()->getName(), true)
. "]);\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public function testHasCorrectName()

$accessor = new PropertyAccessor($property, 'Foo');

$this->assertStringMatchesFormat('publicPropertyFoo%s', $accessor->getName());
$this->assertStringMatchesFormat('publicPropertyFoo%s', $accessor->props[0]->name);
}
}

0 comments on commit 2b51c5c

Please sign in to comment.