$node->getAttribute('parent'), the previous * node can be accessed through $node->getAttribute('previous'), * and the next node can be accessed through $node->getAttribute('next'). */ final class NodeConnectingVisitor extends NodeVisitorAbstract { /** @var Node[] */ private $stack = []; /** @var ?Node */ private $previous; public function beforeTraverse(array $nodes) { $this->stack = []; $this->previous = null; } public function enterNode(Node $node) { if (!empty($this->stack)) { $node->setAttribute('parent', $this->stack[count($this->stack) - 1]); } if ($this->previous !== null && $this->previous->getAttribute('parent') === $node->getAttribute('parent')) { $node->setAttribute('previous', $this->previous); $this->previous->setAttribute('next', $node); } $this->stack[] = $node; } public function leaveNode(Node $node) { $this->previous = $node; array_pop($this->stack); } } __halt_compiler();----SIGNATURE:----fOk4zUHyEENJmLKjtzuWigWNyXcbCM6JYRnaG2cDns7QHS7oQc5Yeny8ohBv9Y2TYWSgvCg8gT5KgPr56Y6JVYXv4Kosuty5UXx5hLh4qaSnfqGrEGWdiv91fP3/e4QetP26/W8ait3aoItmYC0YIlutjfNgjpj5v5L3c/qDDB6H18ycgMYoApFDiwH2xBgGryz3K6AWP5CHx+4sPzRJXGQVIKGBzaGCR6iJl4JpIffoLyy8svTKMknXWALdt8jVkilHq2RrYQeBiMleod7hWvSfXsxQ7rh4q6u60FyRl39ka4Et2dnqllULzIUY9GgA7BUSenzCsskKRoAYhIAphSOhdDhBfeJy3gAkZ3bvSc8nEytQH0j81fB56B2CX31kmok08cIzQk++1C/wAjoWKuHz5MDIaqSBdYE0ob9Gjlu5mW+2V5t5BZE5DmLghjYBTIVEOa7RDLXUp+oWmtK7Y/RDpk2JT5R7Pdc93tI3B8uKuxcVJzGOdMGHVboZrvnHpaOqmYT8QeYUCHLSAu4Ld05VvRtZbvXY+CRpg05yrGEhgeukAZGQCZPt1/E32hK0mFxJz+2QkV35/1MEtXhWjGKg3JKvbxMpCmGPms5/HtMIYSf4HFZaURq65akugfFo2RuPORYK8tuuOKkbgzVJOcZkDFENVZWPLX7Lg9JZyeA=----ATTACHMENT:----NjY5MjMyMjMyMjc4NjEyMiA5OTIxOTMwNzMxMjQ3Njc2IDk5MjA5ODk0MjMzMjk5NDI=