src/Traits/NodeTrait.php
protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
    {
        $this->nodeName = $name ?? spl_object_hash($this);

        if (!$parent) {
            $this->nodeRoot = $this;
            $this->nodeParent = $this;
        } else {
            $this->nodeRoot = $parent->getRoot();
            $this->nodeParent = $parent;
            /** @noinspection PhpParamsInspection */
            $parent->addChild($this);
        }
    }
protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
    {
        $this->nodeName = $name ?? spl_object_hash($this);

        if (!$parent) {
            $this->nodeRoot = $this;
            $this->nodeParent = $this;
        } else {
            $this->nodeRoot = $parent->getRoot();
            $this->nodeParent = $parent;
            /** @noinspection PhpParamsInspection */
            $parent->addChild($this);
        }
    }
protected function initNodeTrait ( ? NodeInterface $ parent = null , ? string $ name = null ) { $ this -> nodeName = $ name ?? spl_object_hash ( $ this ) ; if ( ! $ parent ) { $ this -> nodeRoot = $ this ; $ this -> nodeParent = $ this ; } else { $ this -> nodeRoot = $ parent -> getRoot ( ) ; $ this -> nodeParent = $ parent ; /** @noinspection PhpParamsInspection */ $ parent -> addChild ( $ this ) ; } }
Call this function in the constructor.

@param NodeInterface|null $parent
@param string|null        $name

@throws NodeOverwriteException
Call this function in the constructor .