From f71a525c4757138d936965e3aee569a4faa6fc3c Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 8 Dec 2025 01:09:02 +0100 Subject: [PATCH] [fix] Fix ParamTypeByMethodCallTypeRector for nested call --- .../Fixture/avoid_nested_call.php.inc | 45 +++++++++++++++++++ .../ParamTypeByMethodCallTypeRector.php | 4 +- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Fixture/avoid_nested_call.php.inc diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Fixture/avoid_nested_call.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Fixture/avoid_nested_call.php.inc new file mode 100644 index 00000000000..bfe3e7573e9 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector/Fixture/avoid_nested_call.php.inc @@ -0,0 +1,45 @@ +someTypedService->run($value); + }; + } +} + +?> +----- +someTypedService->run($value); + }; + } +} + +?> diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php index fcc9ce4c1ee..3e19e31f613 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php @@ -111,8 +111,8 @@ public function refactor(Node $node): ?Node } /** @var array $callers */ - $callers = $this->betterNodeFinder->findInstancesOf( - $node, + $callers = $this->betterNodeFinder->findInstancesOfScoped( + [$node], [StaticCall::class, MethodCall::class, FuncCall::class] );