diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f2d475 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +*.log +.DS_Store +build/ +dist/ diff --git a/src/CodeParser.php b/src/CodeParser.php index 6a282a3..7777b2a 100644 --- a/src/CodeParser.php +++ b/src/CodeParser.php @@ -35,7 +35,7 @@ public function parseCode(string $code, string $modifiedLines, string $fileType) $modifiedLineRanges = $this->parseModifiedLines($modifiedLines); // Create parser - $parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7); + $parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP8); try { // Parse code diff --git a/src/CodeVisitor.php b/src/CodeVisitor.php index 4a02fdc..7226185 100644 --- a/src/CodeVisitor.php +++ b/src/CodeVisitor.php @@ -252,8 +252,16 @@ public function enterNode(Node $node) */ private function extractAnnotations(string $docString) { - // PHP doesn't have decorators like Python, so returning an empty array - return []; + $annotations = []; + + // Match annotations in the format @annotationName or @annotationName(params) + preg_match_all('/@(\\w+)(?:\\([^)]*\\))?/', $docString, $matches); + + if (isset($matches[1]) && is_array($matches[1])) { + $annotations = $matches[1]; + } + + return $annotations; // Original implementation commented out below /*