Skip to content

Commit

Permalink
final touch: ensure get attributes to correct value on ReflectionAttr…
Browse files Browse the repository at this point in the history
…ibute::getNode()
  • Loading branch information
samsonasik committed Feb 4, 2024
1 parent ece7e1f commit f62cbe6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/ReflectionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Go\ParserReflection;

use Go\ParserReflection\ValueResolver\NodeExpressionResolver;
use ReflectionAttribute as BaseReflectionAttribute;
use PhpParser\Node;
use PhpParser\Node\Param;
Expand Down Expand Up @@ -45,11 +46,24 @@ public function getNode(): Node\Attribute
$node = $this->reflector->getTypeNode();
}

$nodeExpressionResolver = new NodeExpressionResolver($this);
foreach ($node->attrGroups as $attrGroup) {
foreach ($attrGroup->attrs as $attr) {
if ($attr->name->toString() === $this->attributeName) {
return $attr;
if ($attr->name->toString() !== $this->attributeName) {
continue;
}

$arguments = [];
foreach ($attr->args as $arg) {
$nodeExpressionResolver->process($arg->value);
$arguments[] = $nodeExpressionResolver->getValue();
}

if ($arguments !== $this->arguments) {
continue;
}

return $attr;
}
}

Expand Down

0 comments on commit f62cbe6

Please sign in to comment.