Skip to content

PHP: docblock-typed property assigned in the constructor body binds no receiver type — missing calls edge (co-cause 2 of #37) #38

Closed

Description

@filipechagas

Problem

BalanceCustomerAccountService::handle() calls $this->chargeCustomerService->handle(...) (app/Services/Billing/BalanceCustomerAccountService.php:37 in api.lawnstarter.com @ d2d4bed7ae), yet the graph has no calls edge from it to ChargeCustomerService — measured 2026-08-06 on the pinned repro graph (48,529 nodes): the only inbound call-context edge on BalanceCustomerAccountService is CustomerController.update() → .handle().

Root cause

The receiver property is declared untyped with only a @var docblock, and assigned in the constructor body from a typed param:

/** @var ChargeCustomerService */
protected $chargeCustomerService;          // L14-15
public function __construct(
    ChargeCustomerService $chargeCustomerService   // L18
) {
    $this->chargeCustomerService = $chargeCustomerService;  // L20

_resolve_php_member_calls binds this.<prop> receivers only from "the class's typed properties and constructor-promoted params" (graphify/extract.py:3346). Docblock receivers were explicitly Out of Scope in #1's spec; constructor-body assignment of a typed param is not covered either. The two sibling callers resolve fine because they use the covered forms: ChargeCustomerCancellationFee (promoted protected readonly param) and BillingCharge (typed method param, #4).

Proposed enhancement

Bind a property's type from a constructor-body assignment $this->prop = $param; where $param is a typed constructor parameter (classic pre-promotion Laravel idiom, common in this corpus). Same refusal discipline as #4: poison on reassignment with a different/unknown type. Whether to also read @var docblocks is a separate, riskier decision (docblocks lie more often than signatures) — the ctor-assignment form alone covers this measured case without touching docblocks.

Context

Discovered as co-cause 2 in #37's step-through: it makes "Who calls ChargeCustomerService?" unable to reach 3/3 ground-truth callers by call-filtered traversal alone. #37's fix works around it via unfiltered fallback; this issue is the extraction-side fix.

Activity

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

    @filipechagas
    CollaboratorAuthor

    Triage (2026-08-07)

    Labeling ready-for-agent.

  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 fork feature branch fix/stub-shadowing-46 (commit 293d57e, cherry-picked from fix/38-ctor-body-receiver), headed for the single PR into v8.

    What landed: _php_ctor_assigned_field_types binds a property's receiver type from a constructor-body assignment $this->prop = $param; where $param is a typed constructor parameter (the classic pre-promotion Laravel idiom). Declared property types and promoted params keep precedence (setdefault). The refusal discipline is property-scoped, not just constructor-scoped: any write to the property from any non-constructor method of the class (plain/augmented/reference/list-destructuring/foreach targets, and deferred writes such as closures) poisons the binding — refusal over guessing, mirroring #4.

    Acceptance criteria:

    • Red-first fixture mirroring the measured case (untyped property + @var docblock + ctor-body assignment from typed param + $this->prop->method()): no calls edge on base; INFERRED/0.8 edge to the param's type after.
    • Poison paths: 20+ refusal tests; review mutation-tested the battery twice — final round 8/8 mutations killed, including the cross-class over-refusal mutant (a write in another class does NOT poison).
    • Covered sibling forms regression-locked (promoted param, typed method param, declared typed property — the declared path correctly needs no sweep since PHP fatals on incompatible writes to typed properties).
    • Full suite green: 4371 passed / 3 skipped on the integrated branch.
    • Corpus-scale check (the missing BalanceCustomerAccountService.handle() → ChargeCustomerService edge) — deferred to Stub-shadow fix 4/4: release + acceptance grading on the pinned api corpus #50's grading rebuild; review grep-verified the ground-truth file writes the property exactly once (in the ctor), so the sweep leaves that binding standing.

    Hard scope limit honored: no docblock parsing — verified structurally (no comment-node traversal in the diff) and empirically (a lying docblock changes nothing; signature wins). @var support remains a separate policy decision, as specced.

    Review history: first round found a major — a setter reassigning the property to a different/untypable type left the ctor binding minting a confidently-wrong edge; the rework made refusal property-scoped, with controls proving no over-refusal (same-file second class, anonymous classes, read-only methods, other-property writes all unaffected). Deliberate documented trade: even a same-typed setter write refuses (can only suppress edges, never mint wrong ones). Final verdict: APPROVE.

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