Skip to content

fix(extract): resolve prefixed PHP imports (#2659) - #2661

Closed
ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/issue-2659
Closed

ousamabenyounes wants to merge 1 commit into
Graphify-Labs:v8from
ousamabenyounes:fix/issue-2659

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Why

PHP use imports target a bare ID before namespace-aware resolution. When that ID has no sourceless stub node, the resolver cannot recover its label and leaves the import dangling instead of resolving the imported class.

Fixes #2659.

What changed

  • recover a missing PHP import label from the importing file's parsed use aliases
  • keep matching exact through the existing normalized target ID and FQN resolver
  • add a regression test with Pivot and three sibling classes whose names begin with Pivot
  • add the unreleased changelog entry

Why it is safe

The fallback runs only for imports edges without an existing stub label. Other PHP reference relations and non-namespaced legacy resolution are unchanged. External imports continue through the existing FQN stub path.

Test verification (RED → GREEN)

Upstream v8 without the production fix:

FAILED tests/test_php_type_resolution.py::test_php_import_resolves_when_target_name_prefixes_sibling_classes
E   AssertionError: assert 'pivot' == 'src_pivot_pivot'
1 failed in 0.23s

Patched branch:

tests/test_php_type_resolution.py ...... [100%]
6 passed in 0.27s
changed lines: [2874, 2875, 2876]
executed changed lines: [2874, 2875, 2876]
changed-line coverage: 100%

Full local CI replay:

  • Python 3.12: 4306 passed, 3 skipped; two pre-existing failures reproduced on unmodified v8
  • Python 3.10: 4306 passed, 3 skipped; same two pre-existing failures as baseline, with one additional passing regression test
  • generated skill checks, install smoke, and ruff check graphify tests: passed

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

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

This PR adds handling in the PHP type resolution logic so that imports relations can match a use alias by comparing the generated id (_make_id(alias)) against the edge target when no stub label is found. It moves the uses lookup earlier in the loop to support this. A new test verifies that a PHP use import resolves to the correct class even when that class name is a prefix of sibling class names, and the changelog is updated to note the fix (#2659).

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 1589 functions depend on the 317 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 434 callers, 41 callees

Verification — 1589 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: 829 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify \_resolve\_php\_type\_references.

The verifier did not have enough to check \_resolve\_php\_type\_references, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous

· 1 more finding(s) on lines outside this diff (see the check run).

@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.41 (graphifyy==0.9.41 on PyPI) (#2659). Credited in the release notes. Thanks @ousamabenyounes!

@safishamsi safishamsi closed this Aug 12, 2026
filipechagas added a commit to lawnstarter/graphify that referenced this pull request Aug 14, 2026
Resolves the PR conflicts against upstream v0.9.42 (upstream 7fe58b0),
refreshing the branch from the v0.9.40 state the last merge left it in.

CHANGELOG.md: upstream released 0.9.41 on 2026-08-12 while this PR was
open, and this PR's consolidated section claimed that same number - the
same collision the last refresh resolved one version down. The section is
renumbered to 0.9.43 (one patch above the higher of the two sides, per the
sync convention), its AST-cache-roll bullet follows it, and upstream's
0.9.42 (unreleased), 0.9.41 (2026-08-12) and re-dated 0.9.40 (2026-08-11)
sections are kept verbatim below it.

pyproject.toml: 0.9.41 (ours) vs 0.9.42 (upstream) -> 0.9.43.

uv.lock: regenerated for the bump. The committed lock had been stale since
before the last refresh - byte-identical to the 0.9.40 base while
pyproject.toml read 0.9.41 - so it did not previously appear in this PR's
delta at all. `uv lock --check` passes.

graphify/affected.py: two insertions at the same point in resolve_seed.
The fork's sourced-stub preference (#49/#54) is kept first and upstream's
repo-relative query_path (Graphify-Labs#2707) second; neither guards the other.

graphify/extractors/resolution.py: upstream's prefixed-use-import alias
fallback (Graphify-Labs#2661) is folded into the else-branch of the fork's
target_fqn-metadata restructure (#48), firing only when that path declines
and no stub label exists. Upstream Graphify-Labs#2661 also moved the
`uses = uses_by_file.get(ref_file, {})` binding into the region the fork
rewrote; the deletion at the moved-from site auto-merges silently, so the
binding is kept explicitly above the repoint block - without it the fork's
else-branch raises NameError on the first PHP repoint edge.

Delta audit: `git diff --name-only upstream/v8` covers the same 31 files as
the previous refresh plus uv.lock, with none dropped.

Tests on the merged tree: 4672 passed / 45 skipped / 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

PHP: a class whose name is a prefix of sibling class names loses all inbound imports edges

2 participants