Skip to content

feat(ast): add PHP tree-sitter support#1087

Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom
yangxinxin-7:feat/code_php
Mar 30, 2026
Merged

feat(ast): add PHP tree-sitter support#1087
MaojiaSheng merged 1 commit intovolcengine:mainfrom
yangxinxin-7:feat/code_php

Conversation

@yangxinxin-7
Copy link
Copy Markdown
Collaborator

Summary

Add PHP AST skeleton extraction using tree-sitter, enabling .php files to be parsed into structured code skeletons (imports, classes/methods, functions, docstrings) for downstream indexing and summarization.

What’s included

  • PHP extractor (PhpExtractor) powered by tree-sitter-php
    • Parses use imports (including group use)
    • Extracts classes and methods, top-level functions
    • Collects docstrings with PHPDoc preference and adjacency checks
    • Captures class-internal trait use into class bases
    • Converts assigned closures/arrow functions ($x = function(...) {} / $x = fn(...) => ...) into pseudo top-level functions
    • Includes interface/trait/enum declarations in the skeleton output
  • AST dispatch updated to route .phpphp
  • Adds dependency: tree-sitter-php
  • Adds unit tests covering the PHP extractor behaviors

Files changed

  • openviking/parse/parsers/code/ast/extractor.py
  • openviking/parse/parsers/code/ast/languages/php.py
  • pyproject.toml
  • tests/parse/test_ast_extractor.py

How to test

python3 -m pip install -e ".[test]"
python3 -m pytest tests/parse/test_ast_extractor.py -v

- Add PhpExtractor (use/group use, docstrings, trait use, assigned closures)

- Register .php routing and add tree-sitter-php dependency

- Add PHP AST extractor tests
@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

@MaojiaSheng MaojiaSheng merged commit a046048 into volcengine:main Mar 30, 2026
11 of 12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants