fix(php): extract interface, trait, and enum definitions - #3024
fix(php): extract interface, trait, and enum definitions#3024rajatnagda45 wants to merge 1 commit into
Conversation
The PHP class_types listed only class_declaration, so interface_declaration, trait_declaration and enum_declaration were dropped as definitions. Worse, because the type was not recognized as a container, its method_declaration children were re-attributed to the FILE as free-standing functions instead of methods of the interface/trait, and a class's `implements`/`use` resolved to a sourceless stub rather than the real type. Interfaces and traits are load-bearing in the PHP ecosystem (Laravel, Symfony, every PSR), so this erased a large slice of the graph. All three share class_declaration's name + declaration_list body contract, so add them to class_types — mirroring Java's interface/enum handling. Methods now attribute to their type, and implements/uses/calls resolve to the real nodes. Adds a regression test.
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
Adds PHP interface, trait, and enum declarations to the recognized class types in _PHP_CONFIG, so they're now emitted as sourced definitions with their methods attributed to the type (rather than being dropped and their methods re-attributed to the file as free functions). Class implements/use relationships now resolve to those real type nodes instead of sourceless stubs. Covers the behavior with a new test exercising interface, trait, and enum definitions plus implements/mixes_in edge resolution.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1936 functions depend on the 735 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 490 callers, 42 callees - new:
_rebuild_code()— 98 callers, 50 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
dispatch_command()— 2 callers, 122 callees - new:
extract_js()— 80 callers, 3 callees - new:
_get_extractor()— 26 callers, 6 callees - new:
run_pipeline()— 8 callers, 13 callees - new:
collect_files()— 17 callers, 6 callees - …and 23 more — each is listed as a finding
Verification — 1936 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1785 function(s) in the blast radius were not formally verified this run
· 31 more finding(s) on lines outside this diff (see the check run).
Problem
The PHP
class_typeslisted onlyclass_declaration, sointerface_declaration,trait_declaration, andenum_declarationwere all dropped as definitions. Worse — because the type wasn't recognized as a container, itsmethod_declarationchildren were re-attributed to the FILE as free-standing functions instead of methods of the interface/trait, and a class'simplements/useresolved to a sourceless stub rather than the real type.Interfaces and traits are load-bearing across the PHP ecosystem (Laravel, Symfony, every PSR), so this erased a large slice of the graph.
Before (this input)
Logger,Timestamps,Status→ no definition nodeslog(),touch()→ attached to the file as free functionsService implements Logger/use Timestamps→ point at sourceless stubsFix
All three share
class_declaration's name +declaration_listbody contract, so add them toclass_types— mirroring Java's interface/enum handling. Methods now attribute to their type, andimplements/use/callsresolve to the real nodes.Test
Adds a regression test asserting each type is a real sourced definition, that interface/trait methods attribute to the type (not the file), and that
implements/mixes_inresolve to the real nodes. Fails before, passes after; all 18 existing PHP language tests and the PHP type-resolution suite still pass.