Skip to content

Commit

Permalink
fix PropertyProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 2, 2024
1 parent db4257b commit ee70c54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ReflectionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\PropertyProperty;

/**
* ref original usage https://3v4l.org/duaQI
Expand All @@ -40,6 +41,10 @@ public function getNode(): Node\Attribute
{
/** @var Class_|ClassMethod|Property|ClassConst|Function_|Param $node */
$node = $this->reflector->getNode();
if ($node instanceof PropertyProperty) {
$node = $node->getAttribute('parent');
}

foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attr) {
if ($attr->name->toString() === $this->attributeName) {
Expand Down
2 changes: 2 additions & 0 deletions src/ReflectionEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PhpParser\Node\Stmt\Property;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\NodeVisitor\ParentConnectingVisitor;
use PhpParser\Parser;
use PhpParser\ParserFactory;

Expand Down Expand Up @@ -80,6 +81,7 @@ public static function init(LocatorInterface $locator): void
self::$traverser = $traverser = new NodeTraverser();
$traverser->addVisitor(new NameResolver());
$traverser->addVisitor(new RootNamespaceNormalizer());
$traverser->addVisitor(new ParentConnectingVisitor());

self::$locator = $locator;
}
Expand Down

0 comments on commit ee70c54

Please sign in to comment.