Skip to content

PHP use-import map 1/5: capture use FQN/alias metadata on imports edges #19

Closed

Description

@filipechagas

Parent

Spec: #18 (ticket 1/5). Fixes nothing user-visible on its own; foundation for #16's fix.

What to build

Enrich PHP imports edges with the facts today's capture throws away, mirroring _import_csharp (extract.py:577-605):

  • Extract the already-correct use-parser from _resolve_php_type_references (graphify/extractors/resolution.py:2476-2517: _record_use_clause + the namespace_use_declaration walk) into a shared helper.
  • Have both _resolve_php_type_references and the PHP import capture consume it. Replace the lossy raw.split("\\")[-1] in _import_php (extract.py:664-681).
  • Emit imports edge metadata: target_fqn, alias (when use X as Y;), use_kind.

Constraints

  • No behavior change to any resolver — metadata additions only. Existing suites must pass byte-identical except for the new metadata keys.
  • use function / use const must not enter the class-name map (parser already rejects, resolution.py:2479-2480 — keep that on extraction).
  • Do not widen _PHP_CONFIG.import_types (extract.py:926) to namespace_use_declaration: trait use inside a class body is a different node and must not become an import.
  • Keep the casefold convention from resolution.py.

Acceptance criteria

  • use A\B\C; → imports edge metadata target_fqn: "A\\B\\C", no alias
  • use A\B\C as D; → alias: "D", target_fqn: "A\\B\\C"
  • Group use use A\{B, C as X}; → two edges with correct FQNs and the alias on the right one
  • use function A\f; and use const A\K; produce no class-map entries
  • Trait use T; inside a class body produces no imports edge
  • _resolve_php_type_references behavior unchanged (its existing suites pass)
  • All tests through the public extract() seam
  • Full suite green (baseline v8 @ 102ae79: 4024 passed / 36 skipped)

Blocked by

None.

Activity

  1. added
    ready-for-agent
    on Aug 5, 2026
  2. filipechagas commented on Aug 5, 2026

    @filipechagas
    CollaboratorAuthor

    Discovered while implementing this ticket and filed separately as #26: group-form use function A\{f, g}; / use const A\{K}; put the keyword on the declaration, not the clause, so _resolve_php_type_references never sees it and those names enter the class-name map as claimed class names.

    Not fixed here — this ticket is metadata-only under a strict no-behavior-change-to-any-resolver constraint. The shared helper _php_use_declaration_facts reads the declaration-level keyword and reports the correct use_kind (the new imports-edge capture uses it that way today); _resolve_php_type_references is the sole caller passing apply_declaration_kind=False purely to preserve legacy behavior byte-for-byte. #26 is "drop that argument, delete the flag, cover it with a test".

    Pre-existing, not a regression: the repro in #26 produces identical output at 102ae79 and at this ticket's commit. Worth landing before #21 — a wrongly claimed short name would become a wrongly decisive refusal there.

  3. added a commit that references this issue on Aug 5, 2026
  4. filipechagas commented on Aug 5, 2026

    @filipechagas
    CollaboratorAuthor

    Closed by PR #29 (merge commit e188ff6). Orchestrator gate evidence: independent full-suite runs reproduced 4032/36 at branch head (pre-merge baseline 4024/36 + 8 new tests) and 4057/36 on the merged tree (post-#9/#15/#10 baseline 4049/36 + 8). No-behavior-change additionally evidenced by a byte-identical metadata-stripped extract() diff over an 8-form use-statement corpus, and the v8 merge was triple-verified against both parents. Discovery #26 filed and sequenced before #21. v8 baseline is now 4057/36. #20 and #26 are unblocked.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions