Skip to content

PHP: global function calls (event()-family) bare-matching method nodes cross-file — needs a resolution policy #52

Closed

Description

@filipechagas

Deferred out of #39 by explicit scope decision; the relative-scope half landed there (fork PR #51), this is the remaining family.

Measured (pinned api graph @ d2d4bed7ae, diagnosis in #39's 2026-08-07 triage comment): every Laravel event(...) global-helper call in production code — 848 edges — bound to GetProviderBillingEventsTest.event(), a unit-test helper method, because the unresolved raw call reaches the shared cross-file pass (graphify/extract.py label match) where the tie-break picked the method over the 3 Event classes.

Policy question for a maintainer: may a PHP function_call_expression (global helper) ever bare-match a method node cross-file? Refusing method candidates for function-call sites would kill this family, but interacts with legitimate global-function resolution — that interaction is why #39 refused to fold it in.

Post-0.9.38 note: the #46 fixes did not touch this path; re-measure on a current graph before speccing.

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

    Policy (maintainer call): a PHP function_call_expression (global helper call) never binds to a method node cross-file. In PHP, a bare name(...) can only invoke a global/namespaced function — a method requires $obj->, Class::, or callable syntax — so refusing method candidates at function-call sites is language-semantically sound, not a heuristic. Legitimate global-function resolution is unaffected: real function definitions remain candidates.

    Re-measured post-0.9.38 (graph built with v0.9.38 on the pinned api clone, cache/ast/v0.9.38/): unchanged — exactly 848 incoming calls edges on GetProviderBillingEventsTest.event(), 308 from non-test files, 368 distinct source files.

    Mechanism (from code reading, current v8 @ 18c17d8): the shared cross-file pass (graphify/extract.py:6104+) skips is_member_call sites but lets PHP function-call sites through. The label index normalizes labels with raw.strip("()").lstrip(".") (extract.py:6019-6025), so the method labeled .event() keys as exact-case event — the sole exact-case candidate for callee event (the three Event classes key as Event and the case-insensitive fallback only fires when exact-case is empty). Single candidate → immediate bind, INFERRED 0.8.

    Spec / acceptance criteria (red-first):

    1. A PHP fixture with event(...) in one file and a class method event() in another file must produce no calls edge between them (currently binds — red first).
    2. A PHP fixture with event(...) and a global function function event(...) in another file must still resolve (guard against killing legitimate global-function resolution).
    3. The exclusion applies to method candidates in both the exact-case and case-insensitive index paths, for PHP function-call sites only (other languages' behavior unchanged).
    4. Full suite green: uv run --frozen pytest tests/ -q --tb=short.
    5. Post-fix measurement on the pinned api graph: 0 calls edges into GetProviderBillingEventsTest.event() from event(...) call sites.
  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 a7fb03c, integrated as 9069df5), shipping in 0.9.39 via the cycle PR into v8.

    Policy landed (as triaged, then widened during review): a PHP function_call_expression site never binds to a method node cross-file — and, extended during the cycle by the same language-semantic argument, never to a class-like node (class/interface/enum/trait) either. Only plausible function targets survive, on both the exact-case index path and the case-insensitive folded retry.

    Measured on the rebuilt 46,636-node api graph (cold-then-warm cache, integrated code):

    • GetProviderBillingEventsTest.event() incoming calls edges: 848 → 2, and 0 cross-file (the 2 residuals are same-file in-file-pass binds, documented out of scope).
    • The same fix killed the rest of the family nobody had counted: config() −290, dispatch() −186, request() → class Request −15, plus sleep/view/mock — all 1,341 lost edges attributable to this family, zero collateral losses.
    • Regression caught by grading and fixed in rework 2: the CI-retry briefly created 7 report(...) → class Report INFERRED edges; final build has 0, and 0 INFERRED gains to any non-method target corpus-wide.

    Verification trail: 12 red-first tests (each rework round verified red on the exact commit carrying the defect it fixes); 3 adversarial review rounds, final verdict APPROVE with mutation testing (weakening the refusal to amendment-1 behavior makes exactly the 4 class-refusal tests fail, including the positive function-reachability guarantee) and 16 collateral probes (non-PHP Widget() → class binds intact in Python/Ruby; scoped calls and FCC unaffected). Full suite green: 4411 passed / 3 skipped on the integration branch.

    Requires re-extraction to take effect (raw_calls live in the version-namespaced AST cache); the 0.9.39 bump in this cycle's release commit rolls the namespace.

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