Home
last modified time | relevance | path

Searched refs:visitor (Results 1 – 18 of 18) sorted by relevance

/PHP-Parser/test/PhpParser/NodeVisitor/
H A DFirstFindingVisitorTest.php12 $visitor = new FirstFindingVisitor(function (Node $node) {
15 $traverser->addVisitor($visitor);
21 $this->assertSame($assign->var, $visitor->getFoundNode());
26 $visitor = new FirstFindingVisitor(function (Node $node) {
29 $traverser->addVisitor($visitor);
35 $this->assertNull($visitor->getFoundNode());
H A DFindingVisitorTest.php12 $visitor = new FindingVisitor(function (Node $node) {
15 $traverser->addVisitor($visitor);
27 ], $visitor->getFoundNodes());
32 $visitor = new FindingVisitor(function (Node $node) {
35 $traverser->addVisitor($visitor);
50 ], $visitor->getFoundNodes());
/PHP-Parser/lib/PhpParser/
H A DNodeTraverser.php44 * @param NodeVisitor $visitor Visitor to add
46 public function addVisitor(NodeVisitor $visitor): void { argument
47 $this->visitors[] = $visitor;
53 public function removeVisitor(NodeVisitor $visitor): void { argument
54 $index = array_search($visitor, $this->visitors);
70 foreach ($this->visitors as $visitor) {
79 $visitor = $this->visitors[$i];
107 $return = $visitor->enterNode($subNode);
140 $return = $visitor->leaveNode($subNode);
184 $return = $visitor->enterNode($node);
[all …]
H A DNodeFinder.php26 $visitor = new FindingVisitor($filter);
28 $traverser = new NodeTraverser($visitor);
31 return $visitor->getFoundNodes();
67 $visitor = new FirstFindingVisitor($filter);
69 $traverser = new NodeTraverser($visitor);
72 return $visitor->getFoundNode();
H A DNodeTraverserInterface.php9 * @param NodeVisitor $visitor Visitor to add
11 public function addVisitor(NodeVisitor $visitor): void; argument
16 public function removeVisitor(NodeVisitor $visitor): void; argument
/PHP-Parser/test/PhpParser/
H A DNodeTraverserTest.php18 $visitor = new NodeVisitorForTesting();
20 $traverser->addVisitor($visitor);
32 ], $visitor->trace);
89 $traverser->addVisitor($visitor);
112 $traverser->addVisitor($visitor);
137 $traverser->addVisitor($visitor);
276 ], $visitor->trace);
290 ], $visitor->trace);
305 ], $visitor->trace);
323 ], $visitor->trace);
[all …]
/PHP-Parser/tools/fuzzing/
H A Dtarget.php28 $visitor = new class extends PhpParser\NodeVisitorAbstract { variable
101 $traverser->addVisitor($visitor);
103 …t(function(string $input) use($lexer, $parser, $prettyPrinter, $nodeDumper, $visitor, $traverser) {
107 $visitor->setTokens($lexer->getTokens());
109 if ($visitor->hasProblematicConstruct) {
119 $visitor->setTokens($lexer->getTokens());
/PHP-Parser/doc/component/
H A DName_resolution.markdown8 visitor (NameResolver) based on it.
10 The NameResolver visitor
13 The `NameResolver` visitor can (and for nearly all uses of the AST, should) be applied to resolve n…
85 as class names inside doc comments. A visitor running in parallel with the name resolver can access
86 the name context using `$nameResolver->getNameContext()`. Alternatively a visitor can use an
H A DWalking_the_AST.markdown39 Each node visitor implements an interface with following four methods:
102 There are a number of ways in which the AST can be modified from inside a node visitor. The first
103 and simplest is to simply change AST properties inside the visitor:
212 especially if you have more than one visitor. In some cases, it is possible to avoid a full
307 * If *any* visitor returns `DONT_TRAVERSE_CHILDREN`, the children will be skipped for *all*
311 * If *any* visitor returns `STOP_TRAVERSAL`, traversal is stopped for *all* visitors.
312 * If a visitor returns a replacement node, subsequent visitors will be passed the replacement node,
314 * If a visitor returns `REMOVE_NODE`, subsequent visitors will not see this node.
315 * If a visitor returns `REPLACE_WITH_NULL`, subsequent visitors will not see this node.
322 While the node visitor mechanism is very flexible, creating a node visitor can be overly cumbersome
[all …]
H A DFAQ.markdown26 After running this visitor, the parent node can be obtained through `$node->getAttribute('parent')`.
48 After running this visitor, the parent node can be obtained through `$node->getAttribute('parent')`,
H A DLexer.markdown97 …use of this function, you will have to provide the tokens from the lexer to your node visitor using
116 $visitor = new MyNodeVisitor();
117 $traverser = new PhpParser\NodeTraverser($visitor);
121 $visitor->setTokens($parser->getTokens());
H A DError_handling.markdown60 The `NameResolver` visitor also accepts an `ErrorHandler` as a constructor argument.
/PHP-Parser/doc/
H A DREADME.md15 * Modifying the AST from a visitor
H A D2_Usage_of_basic_components.markdown291 // add your visitor
312 The corresponding node visitor might look like this:
327 The above node visitor would change all string literals in the program to `'foo'`.
370 The NameResolver node visitor
373 One visitor that is already bundled with the package is `PhpParser\NodeVisitor\NameResolver`. This
385 unqualified function and constant names. These are resolved at runtime and thus the visitor can't
419 $traverser->addVisitor(new NamespaceConverter); // our own node visitor
H A D0_Introduction.markdown93 * A node visitor for resolving namespaced names.
/PHP-Parser/
H A DREADME.md199 * Modifying the AST from a visitor
H A DUPGRADE-3.0.md141 * `$cloneNodes` argument of `NodeTraverser::__construct()`. Explicitly clone nodes in the visitor
H A DCHANGELOG.md114 * Use visitor to assign comments. This fixes the long-standing issue where comments were assigned
774 is a utility to avoid custom node visitor implementations for simple search operations.

Completed in 32 milliseconds