Skip to content

fix(laravel): preserve relation callback context - #454

Open
shuvroroy wants to merge 9 commits into
PHPantom-dev:mainfrom
shuvroroy:fix/l61-relation-callback-context
Open

shuvroroy wants to merge 9 commits into
PHPantom-dev:mainfrom
shuvroroy:fix/l61-relation-callback-context

Conversation

@shuvroroy

@shuvroroy shuvroroy commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Relation callbacks could discard model alternatives, lose custom relationship bindings, or replace a callback type declared by the application. Complete L61 by retaining the full receiver and relationship context, respecting application overrides, and inferring inline eager-loading array callbacks through the shared forward walker.

The shared relation-chain resolver follows custom ancestry and union branches without erasing instantiated members. Generic ancestor projection now lives in the inheritance layer and binds the receiver's own arguments; the type resolver preserves different generic instantiations of the same class. Method matching follows PHP's case-insensitive rules. Both cursor-driven editor requests and diagnostics consume the same eager-array context, including nested paths, named arguments, and legacy arrays.

Calls containing only eager-load names skip callback context resolution. Cached classes and shared method metadata are retained, and repeated related models are deduplicated without dropping distinct relationship types.

Adds regressions for all 13 review failures and their interactions: 157 type assertions total, 20 completion/diagnostic cases with positive and negative member checks, navigation checks, and a plain PHP generic-union regression. Updates both demo projects and their runtime assertions; Laravel has 222 passing runtime checks.

Stack: depends on #453 (L60), above #452, #451, #450, #449, #448, and #447. This stacked follow-up targets upstream main, so its diff includes the unmerged dependencies. The commits after L60 contain L61; merge the dependencies first.

Validation: full cargo test (14,852 passed), both required clippy runs, formatting, PHP syntax/runtime checks, and Laravel analysis with exactly the three intentional diagnostics. The plain PHP demo retains its existing 109 diagnostics with no added or removed messages.

Coverage follow-up: adds regression tests for unresolved relations, absent framework stubs, stale declaration/cache metadata, ancestry cycles, trait precedence, generic related models, nested union keys, and dynamic callbacks. Parser-backed unit tests assert outside the parser panic boundary so assertion failures cannot be swallowed. Simplifies two unreachable fallthroughs without changing inference behavior.

A clean LLVM coverage run reports 100% cumulative patch line coverage (947/947 changed executable lines) against main, including the uncovered paths inherited from L60. All 14,851 instrumented tests pass; the regular suite passes 14,852 tests including its doctest. Coverage configuration and exclusions are unchanged.

Complete L60 by resolving relation-name variables, unions, and relation objects through the shared type engine. Retain custom builders for relation shortcuts and concrete relations for direct eager callbacks.

Cover callback types, completion, diagnostics, navigation, and Laravel runtime behavior. Keep this follow-up separate from L59.
@codecov-commenter

codecov-commenter commented Sep 20, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Cover fallback and recovery paths across the stacked L61 diff, including missing stubs, stale metadata, ancestry cycles, union paths, and dynamic callbacks.

Simplify unreachable relation-chain and eager-call fallthroughs. Keep assertions outside the parser panic boundary so failures cannot be swallowed.

Verify 947 of 947 changed executable lines against main with a clean LLVM coverage run, plus the full tests and required lint checks.
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.

2 participants