Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
*.log
.DS_Store
build/
dist/
2 changes: 1 addition & 1 deletion src/CodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/CodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*
Expand Down