Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 3.133.142.101
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
3 /
nikic /
php-parser /
doc /
component /
Delete
Unzip
Name
Size
Permission
Date
Action
AST_builders.markdown
5.24
KB
-rw-r--r--
2018-10-10 09:00
Constant_expression_evaluation.markdown
3.31
KB
-rw-r--r--
2018-10-10 09:00
Error_handling.markdown
2.69
KB
-rw-r--r--
2018-10-10 09:00
FAQ.markdown
2.06
KB
-rw-r--r--
2018-10-10 09:00
JSON_representation.markdown
3.4
KB
-rw-r--r--
2018-10-10 09:00
Lexer.markdown
7.55
KB
-rw-r--r--
2018-10-10 09:00
Name_resolution.markdown
4.04
KB
-rw-r--r--
2018-10-10 09:00
Performance.markdown
3.25
KB
-rw-r--r--
2018-10-10 09:00
Pretty_printing.markdown
4.1
KB
-rw-r--r--
2018-10-10 09:00
Walking_the_AST.markdown
11.3
KB
-rw-r--r--
2018-10-10 09:00
Save
Rename
Frequently Asked Questions ========================== * [How can the parent of a node be obtained?](#how-can-the-parent-of-a-node-be-obtained) * [How can the next/previous sibling of a node be obtained?](#how-can-the-nextprevious-sibling-of-a-node-be-obtained) How can the parent of a node be obtained? ----- The AST does not store parent nodes by default. However, it is easy to add a custom parent node attribute using a custom node visitor: ```php use PhpParser\Node; use PhpParser\NodeVisitorAbstract; class ParentConnector extends NodeVisitorAbstract { private $stack; public function beforeTraverse(array $nodes) { $this->stack = []; } public function enterNode(Node $node) { if (!empty($this->stack)) { $node->setAttribute('parent', $this->stack[count($this->stack)-1]); } $this->stack[] = $node; } public function leaveNode(Node $node) { array_pop($this->stack); } } ``` After running this visitor, the parent node can be obtained through `$node->getAttribute('parent')`. How can the next/previous sibling of a node be obtained? ----- Again, siblings are not stored by default, but the visitor from the previous entry can be easily extended to store the previous / next node with a common parent as well: ```php use PhpParser\Node; use PhpParser\NodeVisitorAbstract; class NodeConnector extends NodeVisitorAbstract { private $stack; private $prev; public function beforeTraverse(array $nodes) { $this->stack = []; $this->prev = null; } public function enterNode(Node $node) { if (!empty($this->stack)) { $node->setAttribute('parent', $this->stack[count($this->stack)-1]); } if ($this->prev && $this->prev->getAttribute('parent') == $node->getAttribute('parent')) { $node->setAttribute('prev', $this->prev); $this->prev->setAttribute('next', $node); } $this->stack[] = $node; } public function leaveNode(Node $node) { $this->prev = $node; array_pop($this->stack); } } ```