Skip to content

[CodeQuality] Skip AddNameToBooleanArgumentRector and AddNameToNullArgumentRector on @no-named-arguments callee - #8508

Merged
TomasVotruba merged 1 commit into
rectorphp:mainfrom
Shoxcie:skip-no-named-arguments
Sep 19, 2026
Merged

TomasVotruba merged 1 commit into
rectorphp:mainfrom
Shoxcie:skip-no-named-arguments

Conversation

@Shoxcie

@Shoxcie Shoxcie commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Fixes rectorphp/rector#9907

AddNameToBooleanArgumentRector and AddNameToNullArgumentRector named arguments even when the callee is marked @no-named-arguments. For example, PhpCsFixer\Config::setRiskyAllowed(true) became setRiskyAllowed(isRiskyAllowed: true). PHPStan then reports argument.named, and removing the name by hand doesn't stick, because Rector adds it back.

CallLikeArgumentNameAdder, which both rules use, now returns early unless the callee's acceptsNamedArguments() is yes(). PHPStan exposes that on FunctionReflection and ExtendedMethodReflection, so the instanceof check narrows from MethodReflection to ExtendedMethodReflection. The method reflections that MethodReflectionResolver returns already are one, so nothing that worked before is skipped.

Each rule gets a skip_no_named_arguments fixture that covers a method call, a static call and new on a @no-named-arguments class.

…gumentRector on @no-named-arguments callee

CallLikeArgumentNameAdder now returns early unless the callee accepts named
arguments, so both rules leave calls to @no-named-arguments functions and
methods alone. Naming those arguments made PHPStan report argument.named.
@TomasVotruba
TomasVotruba merged commit 72d6525 into rectorphp:main Sep 19, 2026
45 checks passed
@TomasVotruba

Copy link
Copy Markdown
Member

Thanks

@Shoxcie
Shoxcie deleted the skip-no-named-arguments branch September 20, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

AddNameToBooleanArgumentRector and AddNameToNullArgumentRector add named arguments to @no-named-arguments APIs

2 participants