Skip to content

PHP: _php_non_class_types receiver refusal is now redundant conservatism — recoverable member-call fan-in left unrealized #53

Closed

Description

@filipechagas

Surfaced during #47 (fork PR #51). Now that interfaces/traits/enums mint canonical declaration nodes, the _php_pre_scan_non_class_declarations marker (graphify/extractors/engine.py) still makes the member-call resolver REFUSE to bind a receiver typed with an interface/trait/enum name.

Measured during #47's review (probe, not speculation): App\Contracts\Notifier interface + private Notifier $n receiver + $this->n->send() → no calls edge on base AND on the fixed branch; the marker is still stamped. Not a regression — base had no node at all — but it is recoverable fan-in left on the table.

The original collision the pre-scan guarded against (App\Contracts\Notifier vs App\Support\Notifier) now presents two definitions and would be refused by the single-definition guard on its own.

Why it needs care: lifting it is a behavior change colliding with the #11/#12 test contracts, and upstream has no such pre-scan at all (see the port notes on fork PR #51 / upstream PR 2536) — so fork and upstream would diverge on PHP graph content until reconciled.

Activity

  1. added
    needs-triage
    on Aug 7, 2026
  2. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Triage decision (2026-08-07): accepted for the current fix cycle — lift the refusal, fork-first

    Scope call: remove the _php_non_class_types receiver refusal (graphify/extract.py:3485-3489) and let interface/enum-typed receivers resolve through the normal path. Rationale, verified on current v8 @ 18c17d8:

    Slice boundaries:

    Acceptance criteria (red-first):

    1. Fixture: interface Notifier with send() in one file, class with private Notifier $n + $this->n->send() in another → a calls edge onto the interface's send() declaration node (currently refused — red first).
    2. Same for an enum with a method; enum-typed receiver binds to the enum's method node.
    3. Collision fixture (two same-short-named types) → still no edge (single-definition guard).
    4. PHP interface refusal does not survive incremental rebuilds, minting a wrong edge (user stories 10 + 19) #11/PHP: enum- and trait-typed receivers bypass the interface refusal and bind an unrelated same-short-named class #12 contract tests updated, intent preserved (wrong-binding prevention), full suite green: uv run --frozen pytest tests/ -q --tb=short.
  3. added
    ready-for-agent
    and removed
    needs-triage
    on Aug 7, 2026
  4. filipechagas commented on Aug 7, 2026

    @filipechagas
    CollaboratorAuthor

    Fixed on the cycle branch fix/resolution-gaps-52-53-54 (final slice commit 3338523, integrated as 26f7b03), shipping in 0.9.39 via the cycle PR into v8.

    Scope landed (as triaged: lift, fork-first — plus one review-mandated extension): the _php_non_class_types receiver refusal is removed; interface/enum-typed receivers resolve through PhpNameResolver → single-definition guard → method_index. The marker channel (pre-scan, stamping, context replay) is kept intact but no longer drives resolution. The adversarial review found the refusal had been masking a real hole: _php_pre_scan_class_namespaces recorded FQNs for class_declaration only, so on incremental rebuilds a vendor use Illuminate\Contracts\...\Notifier import wrongly bound to a same-short-named in-corpus interface (full build refused — parity break, measured with the repo's own _full_then_incremental harness). Fixed by extending the pre-scan to all four declaration kinds through the existing php_class_fqns channel; mutation-tested (reverting only that line makes exactly the regression tests fail on the incremental assertion). Bonus from the same fix: a use-claimed in-corpus interface with a colliding class short name now resolves decisively to the interface (23 tests flipped red-first to the correct-edge expectation; every one still asserts the same-short-named stranger gets nothing).

    Measured on the rebuilt 46,636-node api graph: +2,398 calls edges net of the #52 family, ~2,071 of them onto methods — spot-verified in source as genuine interface-typed receiver bindings (e.g. interface DisputeCompletionRepository::creditDisputeCompletion, interface ScheduleRepository::getOngoingSchedulesForProperty), the rest EXTRACTED type-corroborated static/new binds enabled by the FQN/namespace extension. Zero stranger-bindings found in sampling; zero INFERRED gains to non-method targets.

    Verification trail: 2 review rounds (round 1 raised the major above), final verdict APPROVE; collateral check ran the amended source against the base test suite — every failure confined to the slice's own updated test files, so no class-resolution behavior shifted anywhere else the suite reaches. Full suite green: 4411 passed / 3 skipped on the integration branch. Follow-up #55 filed for a pre-existing short-name-conflict drop in the pre-scan whose trigger set this widened.

    Fork/upstream note: upstream has no such pre-scan; divergence recorded for the next port cycle rather than ported now. Requires re-extraction (version-namespaced AST cache); the 0.9.39 bump rolls the namespace.

  5. added 2 commits that reference this issue on Aug 7, 2026
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