How to reach first parent of current node? #7764
-
QuestionI have some rows like this
Other like this
I'm creating a rule to refactore prev lines as
and
To do this I am creating a new node . Then I'd like to use NodesToAddCollector to add new node before the very first node of the current FuncCall I'am parsing. Can I identifiy the 'first' node? the parent of parent of parent ... node of a current node ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
There is BetterNodeFinder->resolveCurrentStatement() for that, see https://github.com/rectorphp/rector-src/blob/74bb7a0a7153e3b4423dd816da23c5de55875fc2/src/PhpParser/Node/BetterNodeFinder.php#L495 |
Beta Was this translation helpful? Give feedback.
There is BetterNodeFinder->resolveCurrentStatement() for that, see https://github.com/rectorphp/rector-src/blob/74bb7a0a7153e3b4423dd816da23c5de55875fc2/src/PhpParser/Node/BetterNodeFinder.php#L495