Skip to content

fix(php): capture interface/enum/trait heritage as class-like nodes - #1791

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/php-interface-enum-heritage
Closed

Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/php-interface-enum-heritage

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Bug

PHP interfaces, enums, and traits produce no node and no heritage edges. interface B extends A, enum E implements I, and trait T { use U; } are all silently dropped.

Root cause

_PHP_CONFIG.class_types only contained class_declaration, so the generic extractor never treated interface_declaration, enum_declaration, or trait_declaration nodes as class-like. They never became nodes, and the PHP heritage handler (which runs per class-like node) never fired for them.

Minimal repro

<?php
interface Identifiable {}
interface Nameable extends Identifiable {}
enum Suit: string implements Nameable {
    case Hearts = 'H';
    public function label(): string { return 'x'; }
}
trait Named {}
trait Greets { use Named; }

Before: no Nameable/Suit/Greets nodes, no inherits/implements/mixes_in edges.

Fix

  • Add interface_declaration, enum_declaration, and trait_declaration to _PHP_CONFIG.class_types.
  • Enums wrap members in an enum_declaration_list (not a declaration_list), so add it to body_fallback_child_types so enum methods/cases are walked.

After the fix the repro yields:

  • Nameable --inherits--> Identifiable
  • Suit --implements--> Nameable
  • Greets --mixes_in--> Named
  • Suit --method--> label (enum body now walked)

Testing

  • Added test_php_interface_enum_trait_heritage to tests/test_languages.py, mirroring the existing test_php_splits_inherits_implements_mixes_in assertion style. Fails before, passes after.
  • tests/test_languages.py: 315 passed, 13 skipped (was 314 + this new test).

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.
@Lautaroscu

Copy link
Copy Markdown

good job

safishamsi pushed a commit that referenced this pull request Aug 30, 2026
…1791)

Only class_declaration was treated as a class type, so PHP interfaces, enums, and traits
produced no node and no heritage edges. Add them as class-like containers (and walk the
enum body) so their extends/implements/use heritage is captured as inherits/implements/
mixes_in edges to the right targets.
safishamsi added a commit that referenced this pull request Aug 30, 2026
Ships two batches: the robot/defang/watch/semantic-guard set — Robot Framework extractor
(#3192), generalized control-token defang (#3183), watch unresolved-link preservation
(#3190), unverified-semantic-loss guard (#3203), hook-guard search detection (#3121),
stale-SKILL.md backup (#3144), report/wiki count fixes (#3148/#3127); and a rescued batch of
@Synvoya cross-language inheritance-edge corrections (JS #1790, PHP #1791, Scala #1792/#1794,
Kotlin #1793, C# #1817, Go #1818) that had been buried in the backlog for ~7 weeks.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.53 via authorship-preserving cherry-pick so you keep contributor-graph credit. Thanks @Synvoya — this was verified still-live on the current tree and landed as part of a cross-language heritage-edge batch. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.53

@safishamsi safishamsi closed this Aug 30, 2026
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.

3 participants