Skip to content

Make named arguments passed to @no-named-arguments callables fixable - #6910

Merged
ondrejmirtes merged 3 commits into
2.3.xfrom
fixable-no-named-arguments
Nov 2, 2026
Merged

ondrejmirtes merged 3 commits into
2.3.xfrom
fixable-no-named-arguments

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The argument.named error reported for calls to @no-named-arguments functions, methods and constructors is now fixable: the fix removes the argument names, reorders the arguments by parameter position and fills skipped optional parameters with their default values.

foo(b: 5, a: 1); // foo(1, 5);
foo(1, c: 'c');  // foo(1, 2, 'c');

Not fixed: calls with unpacked arguments, named arguments collected by a variadic parameter, unknown or duplicate names, attributes, and skipped parameters that are by-reference or have a default that is not a scalar, null, bool or [].

Note that reordering changes the evaluation order of the argument expressions.

The fix passes the arguments positionally in parameter order and fills
skipped optional parameters with their default values.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19c14-ede5-7153-b7e4-e784ff94be68
…lizer

Also replaces the match expression the PHP 7.4 downgrade does not handle.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19c14-ede5-7153-b7e4-e784ff94be68
reorderArgs() is lenient for analysis purposes (appends unknown names,
drops duplicates, moves named variadic arguments), so the fix maps
arguments to parameter positions itself again. Keeps the if-chain that
replaced the match expression the PHP 7.4 downgrade does not handle.

Amp-Thread-ID: https://ampcode.com/threads/T-01a19c14-ede5-7153-b7e4-e784ff94be68
@ondrejmirtes
ondrejmirtes merged commit b2f452e into 2.3.x Nov 2, 2026
11 checks passed
@ondrejmirtes
ondrejmirtes deleted the fixable-no-named-arguments branch November 2, 2026 12:03
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.

1 participant