Lines Matching refs:is

4 The most common way to work with the AST is by using a node traverser and one or more node visitors.
54 The `enterNode()` method is called when a node is first encountered, before its children are
55 processed ("preorder"). The `leaveNode()` method is called after all children have been visited
91 A common pattern is that `enterNode` is used to collect some information and then `leaveNode`
92 performs modifications based on that. At the time when `leaveNode` is called, all the code inside
95 As you usually do not want to implement all four methods, it is recommended that you extend
103 and simplest is to simply change AST properties inside the visitor:
114 The second is to replace a node entirely by returning a new node:
125 Doing this is supported both inside enterNode and leaveNode. However, you have to be mindful about
126 where you perform the replacement: If a node is replaced in enterNode, then the recursive traversal
140 only) child of `!($a && $b)`, which is `$a && $b`. The transformation applies again and we end up
143 Finally, there are three special replacement types. The first is removal of a node:
154 Node removal only works if the parent structure is an array. This means that usually it only makes
158 On the other hand, removing a `Node\Expr` does not make sense: If you have `$a * $b`, there is no
175 that `var_dump($a);` will be removed, but `if (var_dump($a))` will not be removed (and there is no
178 Another way to remove nodes is to replace them with `null`. For example, all `else` statements could
189 This is only safe to do if the subnode the node is stored in is nullable. `Node\Stmt\Else_` only
190 occurs inside `Node\Stmt\If_::$else`, which is nullable, so this particular replacement is safe.
192 Next to removing nodes, it is also possible to replace one node with multiple nodes. This
193 only works if the parent structure is an array.
212 especially if you have more than one visitor. In some cases, it is possible to avoid a full
216 anonymous classes), you know that once you've seen a class declaration, there is no point in also
230 Of course, this option is only available in enterNode, because it's already too late by the time
231 leaveNode is reached.
233 If you are only looking for one specific node, it is also possible to abort the traversal entirely
265 It is important to understand that if a traverser is run with multiple visitors, the visitors will
289 That is, when visiting a node, `enterNode()` and `leaveNode()` will always be called for all
292 once. However, it is not always possible to write visitors in a way that allows interleaved
304 When using multiple visitors, it is important to understand how they interact with the various
311 * If *any* visitor returns `STOP_TRAVERSAL`, traversal is stopped for *all* visitors.
322 While the node visitor mechanism is very flexible, creating a node visitor can be overly cumbersome
323 for minor tasks. For this reason a `NodeFinder` is provided, which can find AST nodes that either
357 The node visitor mechanism is somewhat rigid, in that it prescribes an order in which nodes should