Skip to content

feat: Named arguments follow the parameter they name - #548

Open
AbyssWaIker wants to merge 3 commits into
PHPantom-dev:mainfrom
AbyssWaIker:name_param
Open

AbyssWaIker wants to merge 3 commits into
PHPantom-dev:mainfrom
AbyssWaIker:name_param

Conversation

@AbyssWaIker

@AbyssWaIker AbyssWaIker commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

A named argument's label — name: in new SelectField(name: 'x'), in $field->render(name: 'x'), or in an attribute like #[Field(name: 'x')] — is the only place a parameter's name is written outside the parameter's own declaration. This PR makes it behave like that declaration everywhere the editor asks about a name.

Go-to-definition lands on the parameter's $name token, which for a promoted constructor parameter is where the property is declared. Hover shows the promoted property, or the parameter's signature with its type,
its & and ... marks, its default, and its @param text. Document highlights light up the declaration, its accesses, and the labels that fill it, in both directions. Find-references gathers the labels across the
workspace alongside the same-named accesses, and a search started from a label answers with its parameter's references; a promoted property whose only other spelling is a label at a constructor call is no longer a symbol
nothing uses. Rename moves every spelling together — $name, ->name, and the label at each call that passes it a value by name — while a label of the same name at a different callee stays put, and a property the parameter does not promote is left out.

The symbol map records each label as a NamedArgument span pointing back at its call site, and call_resolution/named_arguments.rs resolves the call's target to the parameter the label binds. Two labels name the same parameter when their declarations land on the same bytes, so an inherited constructor shares the parent's token while an override keeps its own; trait and interface methods resolve through their declaring class, and a
global helper called from namespaced code is found through PHP's own lookup fallback. This replaces the AttributeNamedArg member-access special case that attribute labels previously carried, and labels at a
built-in's stub — a declaration the engine reads but cannot show — hover and type as their parameter while declining navigation and rename rather than entering rename mode to produce no edits.

The unknown_named_argument check lands on the label spans and is rewired onto this resolution, refining main's version: a func_get_args() callee still rejects a label its signature does not declare, while a method routed through __call or synthesized from an @method tag, and a name read from a callable type, are exempt; at a built-in, a label that differs from a declared parameter only in case or underscores is forgiven, since the bundled stubs spell some parameters otherwise than the runtime's arginfo does. Extensions php-src does not ship remain unchecked until their stub names are corrected (D44).

A label that fills a deprecated promoted property now reports the deprecation the way ->name does.

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 have used AI tools, and I have reviewed what they produced and can explain
    the changes and why they are needed.
  • I have read through any AI-generated text, especially documentation,
    the changelog, and other user-facing content, and removed or corrected
    anything inaccurate, unclear, or unnecessary.

Renaming a variable no longer rewrites the labels of a parameter it
shadows: the parameter lookup now shares the variable search's
declaring-scope walk. Parameter label searches filter by callee name
before resolving, which removes a workspace-wide forward walk from
every parameter reference request. A label resolves its class by exact
FQN, so #[\Tag] next to a local App\Tag lands on the global one. The
deprecated-usage arm for labels, which could never fire, is gone.
Unknown named arguments are now reported for callees that read
func_get_args(), as PHP does. Filed B735 for find_class_file_uri's
short-name match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbyssWaIker
AbyssWaIker force-pushed the name_param branch 2 times, most recently from 84cf0df to fac1a6d Compare November 7, 2026 17:37
@AbyssWaIker

AbyssWaIker commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Sorry for all the force pushes.

Did not notice pressing "create PR" too early and thought I was still free to mess around with the branch (while rebasing it) without inconveniencing anyone

Should be ready now

@codecov-commenter

Copy link
Copy Markdown

@AJenbo AJenbo added this to the Sprint 9 milestone Nov 8, 2026

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.

3 participants