From 3a0b3e066c03b18cdc6772aae486a8a9485bc3dc Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 04:03:41 +0700 Subject: [PATCH 1/5] Fix PHPStan @return unused type return.type on RectorInterface --- phpstan.neon | 2 -- src/Contract/Rector/RectorInterface.php | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5316d19e84e..d806fa171cd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -354,5 +354,3 @@ parameters: - path: rules/Renaming/Rector/Name/RenameClassRector.php identifier: return.type - - - '#Method Rector\\(.*?)Rector\:\:refactor\(\) never returns \d so it can be removed from the return type#' diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index ec1b71f4233..9068be9d78d 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -5,7 +5,6 @@ namespace Rector\Contract\Rector; use PhpParser\Node; -use PhpParser\NodeTraverser; use PhpParser\NodeVisitor; use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface; @@ -21,7 +20,7 @@ public function getNodeTypes(): array; /** * Process Node of matched type - * @return Node|Node[]|null|NodeTraverser::* + * @return Node|Node[]|null|int */ public function refactor(Node $node); } From 7e4260f4981711a2e798d35da91cb8e94757c540 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 04:04:09 +0700 Subject: [PATCH 2/5] Fix PHPStan @return unused type return.type on RectorInterface --- phpstan.neon | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index d806fa171cd..9f4e8e2777d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -350,7 +350,3 @@ parameters: - identifier: argument.type message: '#Parameter \#1 \$expr of method Rector\\CodeQuality\\Rector\\BooleanOr\\RepeatedOrEqualToInArrayRector\:\:matchComparedExprAndValueExpr\(\) expects PhpParser\\Node\\Expr\\BinaryOp\\Equal\|PhpParser\\Node\\Expr\\BinaryOp\\Identical, PhpParser\\Node\\Expr given#' - - - - path: rules/Renaming/Rector/Name/RenameClassRector.php - identifier: return.type From 3eca791a19356efbc1b6ac37dfd02cb44dd0bedf Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 04:12:30 +0700 Subject: [PATCH 3/5] add note --- src/Contract/Rector/RectorInterface.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index 9068be9d78d..0946486a7bc 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -21,6 +21,15 @@ public function getNodeTypes(): array; /** * Process Node of matched type * @return Node|Node[]|null|int + * + * For int return, choose: + * + * ✔️ To decorate current node and its children to not be traversed on current rule, return one of: + * - NodeVisitor::DONT_TRAVERSE_CHILDREN + * - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN + * + * ✔️ To remove node of Stmt and Param, return: + * - NodeVisitor::REMOVE_NODE to remove Stmt or Param */ public function refactor(Node $node); } From 14427365de9bcfc8286b1dc30547fb4955d2f139 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 04:13:23 +0700 Subject: [PATCH 4/5] add note --- src/Contract/Rector/RectorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index 0946486a7bc..76dd441a1c4 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -28,7 +28,7 @@ public function getNodeTypes(): array; * - NodeVisitor::DONT_TRAVERSE_CHILDREN * - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN * - * ✔️ To remove node of Stmt and Param, return: + * ✔️ To remove node of Node\Stmt or Node\Param, return: * - NodeVisitor::REMOVE_NODE to remove Stmt or Param */ public function refactor(Node $node); From e581dfa989f064041fc1feeb30caf8c55a96ec6c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Oct 2025 04:13:37 +0700 Subject: [PATCH 5/5] add note --- src/Contract/Rector/RectorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Contract/Rector/RectorInterface.php b/src/Contract/Rector/RectorInterface.php index 76dd441a1c4..d4c568c6cfe 100644 --- a/src/Contract/Rector/RectorInterface.php +++ b/src/Contract/Rector/RectorInterface.php @@ -29,7 +29,7 @@ public function getNodeTypes(): array; * - NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN * * ✔️ To remove node of Node\Stmt or Node\Param, return: - * - NodeVisitor::REMOVE_NODE to remove Stmt or Param + * - NodeVisitor::REMOVE_NODE */ public function refactor(Node $node); }