fix(php): capture interface/enum/trait heritage as class-like nodes#1791
Open
Synvoya wants to merge 1 commit into
Open
fix(php): capture interface/enum/trait heritage as class-like nodes#1791Synvoya wants to merge 1 commit into
Synvoya wants to merge 1 commit into
Conversation
Only class_declaration was registered as a PHP class type, so interface, enum, and trait declarations produced no node and their heritage edges (interface extends -> inherits, enum implements -> implements, trait use -> mixes_in) were dropped entirely. Add interface_declaration, enum_declaration, and trait_declaration to the PHP class_types. Enums wrap their members in an enum_declaration_list rather than a declaration_list, so also add it to body_fallback_child_types so enum methods/cases get walked. Adds a regression test covering interface extends, enum implements, trait use, and an enum-body method.
|
good job |
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
PHP interfaces, enums, and traits produce no node and no heritage edges.
interface B extends A,enum E implements I, andtrait T { use U; }are all silently dropped.Root cause
_PHP_CONFIG.class_typesonly containedclass_declaration, so the generic extractor never treatedinterface_declaration,enum_declaration, ortrait_declarationnodes as class-like. They never became nodes, and the PHP heritage handler (which runs per class-like node) never fired for them.Minimal repro
Before: no
Nameable/Suit/Greetsnodes, noinherits/implements/mixes_inedges.Fix
interface_declaration,enum_declaration, andtrait_declarationto_PHP_CONFIG.class_types.enum_declaration_list(not adeclaration_list), so add it tobody_fallback_child_typesso enum methods/cases are walked.After the fix the repro yields:
Nameable --inherits--> IdentifiableSuit --implements--> NameableGreets --mixes_in--> NamedSuit --method--> label(enum body now walked)Testing
test_php_interface_enum_trait_heritagetotests/test_languages.py, mirroring the existingtest_php_splits_inherits_implements_mixes_inassertion style. Fails before, passes after.tests/test_languages.py: 315 passed, 13 skipped (was 314 + this new test).