From 0f003993df13e628e60debbb2eab175d5d5ae173 Mon Sep 17 00:00:00 2001 From: Shoxcie Date: Sat, 19 Sep 2026 21:05:22 +0300 Subject: [PATCH] [CodeQuality] Skip AddNameToBooleanArgumentRector and AddNameToNullArgumentRector 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. --- .../Fixture/skip_no_named_arguments.php.inc | 12 ++++++++++ .../Source/NoNamedArgumentsService.php | 24 +++++++++++++++++++ .../Fixture/skip_no_named_arguments.php.inc | 12 ++++++++++ .../Source/NoNamedArgumentsService.php | 24 +++++++++++++++++++ .../CallLikeArgumentNameAdder.php | 8 +++++-- 5 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Fixture/skip_no_named_arguments.php.inc create mode 100644 rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Source/NoNamedArgumentsService.php create mode 100644 rules-tests/CodeQuality/Rector/CallLike/AddNameToNullArgumentRector/Fixture/skip_no_named_arguments.php.inc create mode 100644 rules-tests/CodeQuality/Rector/CallLike/AddNameToNullArgumentRector/Source/NoNamedArgumentsService.php diff --git a/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Fixture/skip_no_named_arguments.php.inc b/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Fixture/skip_no_named_arguments.php.inc new file mode 100644 index 00000000000..09b1af74748 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Fixture/skip_no_named_arguments.php.inc @@ -0,0 +1,12 @@ +configure($value, true); + NoNamedArgumentsService::create($value, true); + new NoNamedArgumentsService($value, true); +}; diff --git a/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Source/NoNamedArgumentsService.php b/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Source/NoNamedArgumentsService.php new file mode 100644 index 00000000000..9776baf1376 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/CallLike/AddNameToBooleanArgumentRector/Source/NoNamedArgumentsService.php @@ -0,0 +1,24 @@ +configure($value, null); + NoNamedArgumentsService::create($value, null); + new NoNamedArgumentsService($value, null); +}; diff --git a/rules-tests/CodeQuality/Rector/CallLike/AddNameToNullArgumentRector/Source/NoNamedArgumentsService.php b/rules-tests/CodeQuality/Rector/CallLike/AddNameToNullArgumentRector/Source/NoNamedArgumentsService.php new file mode 100644 index 00000000000..2e71fbfe244 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/CallLike/AddNameToNullArgumentRector/Source/NoNamedArgumentsService.php @@ -0,0 +1,24 @@ +reflectionResolver->resolveFunctionLikeReflectionFromCall($callLike); - if (! $reflection instanceof FunctionReflection && ! $reflection instanceof MethodReflection) { + if (! $reflection instanceof FunctionReflection && ! $reflection instanceof ExtendedMethodReflection) { + return null; + } + + if (! $reflection->acceptsNamedArguments()->yes()) { return null; }