Skip to content

Commit

Permalink
create attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 1, 2024
1 parent 7539a25 commit c26dd19
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Traits/AttributeResolverTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
namespace Go\ParserReflection\Traits;

use Go\ParserReflection\ReflectionAttribute;
use Go\ParserReflection\ReflectionClass;
use Go\ParserReflection\ReflectionException;
use Go\ParserReflection\ReflectionFunction;
use Go\ParserReflection\ReflectionMethod;
use Go\ParserReflection\ReflectionProperty;
use ReflectionClassConstant;

trait AttributeResolverTrait
{
Expand All @@ -21,6 +27,22 @@ trait AttributeResolverTrait
*/
public function getAttributes(?string $name = null, int $flags = 0): array
{
throw new \Exception('need to be implemented');
if (
$this instanceof ReflectionClass ||
$this instanceof ReflectionFunction ||
$this instanceof ReflectionMethod ||
$this instanceof ReflectionProperty ||
$this instanceof ReflectionClassConstant
) {
$attributes = $this->getAttributes($name, $flags);
$reflectionAttributes = [];
foreach ($attributes as $attribute) {
$reflectionAttributes[] = new ReflectionAttribute($attribute->getName());
}

return $reflectionAttributes;
}

throw new ReflectionException('not yet supported');
}
}

0 comments on commit c26dd19

Please sign in to comment.