Mercurial > hg > isophonics-drupal-site
diff vendor/nikic/php-parser/doc/component/Walking_the_AST.markdown @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
line wrap: on
line diff
--- a/vendor/nikic/php-parser/doc/component/Walking_the_AST.markdown Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/nikic/php-parser/doc/component/Walking_the_AST.markdown Thu Feb 28 13:21:36 2019 +0000 @@ -215,7 +215,7 @@ private $class = null; public function enterNode(Node $node) { if ($node instanceof Node\Stmt\Class_ && - $node->namespaceName->toString() === 'Foo\Bar\Baz' + $node->namespacedName->toString() === 'Foo\Bar\Baz' ) { $this->class = $node; return NodeTraverser::STOP_TRAVERSAL; @@ -235,7 +235,7 @@ $traverser = new NodeTraverser; $traverser->addVisitor($visitorA); $traverser->addVisitor($visitorB); -$stmts = $traverser->traverser($stmts); +$stmts = $traverser->traverse($stmts); ``` It is important to understand that if a traverser is run with multiple visitors, the visitors will @@ -281,6 +281,8 @@ * If *any* visitor returns `DONT_TRAVERSE_CHILDREN`, the children will be skipped for *all* visitors. + * If *any* visitor returns `DONT_TRAVERSE_CURRENT_AND_CHILDREN`, the children will be skipped for *all* + visitors, and all *subsequent* visitors will not visit the current node. * If *any* visitor returns `STOP_TRAVERSAL`, traversal is stopped for *all* visitors. * If a visitor returns a replacement node, subsequent visitors will be passed the replacement node, not the original one. @@ -305,7 +307,7 @@ $classes = $nodeFinder->findInstanceOf($stmts, Node\Stmt\Class_::class); // Find all classes that extend another class -$extendingClasses = $nodeFinder->findInstanceOf($stmts, function(Node $node) { +$extendingClasses = $nodeFinder->find($stmts, function(Node $node) { return $node instanceof Node\Stmt\Class_ && $node->extends !== null; }); @@ -332,4 +334,4 @@ certain property. PHP-Parser does not add parent (or sibling) references to nodes by itself, but you can easily -emulate this with a visitor. See the [FAQ](FAQ.markdown) for more information. \ No newline at end of file +emulate this with a visitor. See the [FAQ](FAQ.markdown) for more information.