Skip to content

Resolve morph aliases in type-column comparisons - #432

Open
shuvroroy wants to merge 1 commit into
PHPantom-dev:mainfrom
shuvroroy:feat/laravel-morph-column-aliases
Open

Resolve morph aliases in type-column comparisons#432
shuvroroy wants to merge 1 commit into
PHPantom-dev:mainfrom
shuvroroy:feat/laravel-morph-column-aliases

Conversation

@shuvroroy

Copy link
Copy Markdown
Contributor

Morph-map aliases in polymorphic column comparisons now support completion, hover, go-to-definition, find-references, and unknown-alias diagnostics when the map is enforced. For example, Comment::where('commentable_type', 'post') and $comment->commentable_type === 'post' resolve post through the morph map when the model declares that relationship.

Receiver types come from the shared type engine, and parsed morphTo() metadata identifies the effective column through inheritance and traits. This also corrects shared resolution of parent names and generic arguments through custom builders. Confirmation is cached and shared across array values, with invalidation when model metadata or source changes.

Depends on #431. The Blade slot fix is excluded from this PR. Until it merges, Laravel analysis on main reports its known extra mismatched-tag diagnostic at resources/views/welcome.blade.php:131, in addition to the three intentional demo errors. With #431 applied, the complete validation pipeline passes with exactly the expected three diagnostics.

Validation:

  • Full Cargo tests, library and all-target Clippy, formatting, PHP lint, and both runtime assertion suites pass.
  • Changed executable Rust line coverage: 823/823 (100%), excluding test and benchmark code; measured with the prerequisite applied, with L47 source unchanged after separation.
  • Regression coverage includes custom and inherited columns, typed builders, negative matches, cross-file references, cache invalidation, nested queries, and duplicate aliases.
  • Criterion benchmarks cover first and cached completion requests with 1 and 128 alias values.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, examples/)
  • I have updated the config schema (config-schema.json)
  • I have added/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    an eye towards deleting anything that is irrelevant, clarifying anything
    that is confusing, and adding details that are relevant. This includes,
    for example, commit descriptions, PR descriptions, and code comments.

Recognize alias literals in query filters and property comparisons when
the receiver model declares the column through a morphTo relationship.
Use the shared type engine and relation metadata to provide completion,
hover, navigation, references, and enforced-map diagnostics.

Preserve inherited and trait-defined columns, and resolve parent names
and custom builder generics through the shared resolution path. Cache
confirmed spans with source and model invalidation, and check each query
column once for all values in an array.

Add regression tests, Laravel demos and runtime assertions, completion
benchmarks, architecture notes, and a changelog entry. Remove the completed
morph-column item from the backlog.

The independent named Blade slot closer fix remains in PR PHPantom-dev#431; the
Laravel demo diagnostic baseline requires that prerequisite to merge.
@shuvroroy
shuvroroy marked this pull request as ready for review September 9, 2026 07:03
@shuvroroy shuvroroy changed the title feat: resolve morph aliases in type-column comparisons Resolve morph aliases in type-column comparisons Sep 9, 2026
@codecov-commenter

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!

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