diff --git a/src/ReflectionAttribute.php b/src/ReflectionAttribute.php new file mode 100644 index 0000000..d3e4b4f --- /dev/null +++ b/src/ReflectionAttribute.php @@ -0,0 +1,43 @@ + + * + * This source file is subject to the license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Go\ParserReflection; + +use Go\ParserReflection\Traits\InternalPropertiesEmulationTrait; +use ReflectionAttribute as BaseReflectionAttribute; +use PhpParser\Node; +use Reflector; + +class ReflectionAttribute extends BaseReflectionAttribute +{ + use InternalPropertiesEmulationTrait; + + public function __construct( + string $attributeName, + private ?Node\Attribute $attributeNode = null, + private ?Node\Stmt\ClassLike $classLikeNode = null, + private ?Reflector $declaringReflector = null + ) { + $this->attributeNode ??= ReflectionEngine::parseAttribute($attributeName); + $this->classLikeNode ??= ReflectionEngine::parseClass($attributeName); + } + + public function __debugInfo(): array + { + return []; + } + + public function getNode(): Node\Attribute + { + return $this->attributeNode; + } +} diff --git a/src/ReflectionEngine.php b/src/ReflectionEngine.php index 645a4c1..1626476 100644 --- a/src/ReflectionEngine.php +++ b/src/ReflectionEngine.php @@ -11,6 +11,7 @@ namespace Go\ParserReflection; +use Exception; use Go\ParserReflection\Instrument\PathResolver; use Go\ParserReflection\NodeVisitor\RootNamespaceNormalizer; use InvalidArgumentException; @@ -141,6 +142,11 @@ public static function parseClass(string $fullClassName): ClassLike throw new InvalidArgumentException("Class $fullClassName was not found in the $classFileName"); } + public static function parseAttribute(string $attributeName): Node\Attribute + { + throw new Exception('to be implemented'); + } + /** * Loop through an array and find a ClassLike statement by the given class name. *