Skip to content

fix(php): extract interface, trait, and enum definitions - #3024

Open
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/php-interface-trait-enum
Open

fix(php): extract interface, trait, and enum definitions#3024
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/php-interface-trait-enum

Conversation

@rajatnagda45

Copy link
Copy Markdown
Contributor

Problem

The PHP class_types listed only class_declaration, so interface_declaration, trait_declaration, and enum_declaration were all dropped as definitions. Worse — because the type wasn't 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 across the PHP ecosystem (Laravel, Symfony, every PSR), so this erased a large slice of the graph.

Before (this input)

interface Logger { public function log(string $m): void; }
trait Timestamps { public function touch(): void { /* … */ } }
enum Status { case Active; case Inactive; }
class Service implements Logger { use Timestamps; /* … */ }
  • Logger, Timestamps, Status → no definition nodes
  • log(), touch() → attached to the file as free functions
  • Service implements Logger / use Timestamps → point at sourceless stubs

Fix

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/use/calls resolve 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_in resolve to the real nodes. Fails before, passes after; all 18 existing PHP language tests and the PHP type-resolution suite still pass.

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.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant