Skip to content

feat(completion): complete Eloquent attribute arrays - #497

Open
shuvroroy wants to merge 6 commits into
PHPantom-dev:mainfrom
shuvroroy:feat/eloquent-attribute-array-completion
Open

shuvroroy wants to merge 6 commits into
PHPantom-dev:mainfrom
shuvroroy:feat/eloquent-attribute-array-completion

Conversation

@shuvroroy

Copy link
Copy Markdown
Contributor

Eloquent attribute-array keys now suggest the model's known columns. In calls such as User::create(['name' => $name, '…' => $value]), fillable attributes appear first and name is omitted from the remaining suggestions. Both arrays in lookup-or-create calls use the same completion.

Column completion also covers firstWhere(), both column operands of whereColumn(), aggregates, and the column-name PHP attributes available in the installed Laravel version. It follows model, builder, and relationship receivers through the shared type engine, including inherited columns and accessors. Values, operators, nested arrays, relation properties, and the guarded wildcard do not receive attribute suggestions.

Validation

Validated with Rust 1.99:

  • cargo +1.99 test — full suite passed.
  • cargo +1.99 llvm-cov test — full instrumented suite passed; all 408 changed instrumented source lines are covered locally.
  • cargo +1.99 clippy --fix --allow-dirty -- -D warnings
  • cargo +1.99 clippy --all-targets -- -D warnings
  • cargo +1.99 fmt and cargo +1.99 fmt --check
  • PHP playground syntax checks and runtime assertions passed.
  • Laravel demo syntax checks and all 294 runtime assertions passed.
  • Laravel project analysis reported exactly the three intentional errors on app/Demo.php lines 777 and 988.

Checklist

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, examples/)
  • I have updated the config schema (config-schema.json) — not applicable
  • 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.

Offer known model columns in attribute-array keys, preferring fillable
attributes and skipping keys already present in the same literal.
Extend scalar column arguments and installed model PHP attributes.

Resolve inherited columns and accessors through the shared type engine.
Parse the enclosing call for exact argument roles and reuse the lexical
scanner for comments, documents, and unfinished arrays. Exclude relation
properties and guarded wildcards from column candidates.
Exercise model, builder, and relationship receivers through the public
completion handler, including named arguments, sibling keys, incomplete
arrays, scalar operators, and version-gated model PHP attributes.

Verify replacement ranges and correct the shared cursor helper to count
UTF-16 units consistently with LSP positions.
Add attribute-array and scalar-column completion examples, a model PHP
attribute example, and runtime assertions for their Laravel behavior.
Describe the feature in the changelog and remove the completed backlog
entry from both todo documents.
@codecov-commenter

codecov-commenter commented Oct 12, 2026 •

Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 99.75248% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/completion/eloquent_model_attributes.rs 98.91% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@shuvroroy
shuvroroy marked this pull request as ready for review October 12, 2026 05:12

This branch has not been deployed

No deployments
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