Question
Rector 0.17.1 removed effectively removed removeNode. In some of our custom rules we have some code that looks like this:
$this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $subNode) : ?Node {
if(someConditionThatWeDecide()) {
$this->removeNode($subNode);
}
});
What is the best way moving forward for code like this? When changing the traverseNodesWithCallable into a foreach($node->stmts as $key => $subNode) we obviously get less subnodes to process and have to add some extra code to get the nodes that we want. Is this the correct way?