PHP 8.2.31
Preview: ParentConnectingVisitor.php Size: 861 B
/opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php

<?php

declare (strict_types=1);
namespace PhpParser\NodeVisitor;

use function array_pop;
use function count;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
/**
 * Visitor that connects a child node to its parent node.
 *
 * On the child node, the parent node can be accessed through
 * <code>$node->getAttribute('parent')</code>.
 */
final class ParentConnectingVisitor extends NodeVisitorAbstract
{
    /**
     * @var Node[]
     */
    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);
    }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
506 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.11 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.21 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
9.67 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.36 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
861 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).