Repository navigation
fix(php): parse class constants named after reserved keywords - #46
Merged
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the pull request, @alexwrite. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug / Context
Closes #17. PHP lets any keyword be a class constant name (
public const string DEFAULT = ...). tree-sitter-php up to 0.25.1 rejects 61 keywords once the constant is typed (PHP 8.3) and 7 even untyped (VOID,TRUE, ...). Depending on error recovery, the whole class declaration becomes anERRORnode: the class vanishes from the graph and its importers land on a sourceless stub.Typed constants themselves were never the problem: the grammar supports them since tree-sitter/tree-sitter-php#205. The keyword bug is tree-sitter/tree-sitter-php#295, fixed by the open upstream PR tree-sitter/tree-sitter-php#307 (CI green, awaiting review, not released).
Fix
pyproject.toml:tree-sitter-phppinned to commit9678351ofalexwrite/tree-sitter-php, branchfix/keyword-constant-names= the Lack of NoneType handling in serve.py - causes AttributeError: 'NoneType' object has no attribute 'lower' Graphify-Labs/graphify#307 commits (author kept) + one corpus test for typed keyword-named constants (fails on upstream master, passes on Lack of NoneType handling in serve.py - causes AttributeError: 'NoneType' object has no attribute 'lower' Graphify-Labs/graphify#307; their suite: 157/157).uv.lock: only the two tree-sitter-php hunks (the rest of whatuv lockrewrites is pre-existing drift,uv lock --checkalready fails onmain).tests/test_php_keyword_constant_names.py: 7 keyword declarations parse withoutparse_errors; a constants-only class keeps its node and itsreferences_constantfan-in.pip builds the binding from the git URL (C compiler required, no subdirectory), checked in a clean venv with the same
pip install "... @ git+..."form the daily provisioning uses.Quality
Measure (private projects, code-only, before/after, exhaustive node/edge diff)
contains+ 8importsmoved off a sourceless stub); one constructor location corrected. Nothing else changed.Plan post-merge
Foo::BARedge needs another mention ofFoo).