From 0200720158a13a7c97170a68631d4da8cfd07818 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Oct 2025 22:41:24 +0700 Subject: [PATCH 1/2] [CodingStyle][Php81] Skip used by caller variable on FunctionLikeToFirstClassCallableRector --- .../Fixture/skip_used_by_caller_variable.php.inc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 rules-tests/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector/Fixture/skip_used_by_caller_variable.php.inc diff --git a/rules-tests/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector/Fixture/skip_used_by_caller_variable.php.inc b/rules-tests/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector/Fixture/skip_used_by_caller_variable.php.inc new file mode 100644 index 00000000000..a37ea7c689f --- /dev/null +++ b/rules-tests/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector/Fixture/skip_used_by_caller_variable.php.inc @@ -0,0 +1,12 @@ + From 4cb8bcd134c4c81f6a998b0efea61d1fc4a96fdc Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Oct 2025 22:47:15 +0700 Subject: [PATCH 2/2] fix --- .../FunctionLike/FunctionLikeToFirstClassCallableRector.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php b/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php index e8beda1aa68..f20beac1236 100644 --- a/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php +++ b/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Arg; +use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\CallLike; use PhpParser\Node\Expr\Closure; @@ -133,6 +134,11 @@ private function extractCallLike(Closure|ArrowFunction $node): FuncCall|MethodCa return null; } + // dynamic name? skip + if ($callLike->name instanceof Expr) { + return null; + } + return $callLike; }