/** * @param Node $node */ protected function setParent(Node $node) { if ($node && !$node instanceof self) { throw new \InvalidArgumentException('Parent of block must also be block (can not be inline)'); } parent::setParent($node); }
/** * @param Node $sibling */ public function insertBefore(Node $sibling) { $sibling->detach(); $sibling->previous = $this->previous; if ($sibling->previous) { $sibling->previous->next = $sibling; } $sibling->next = $this; $this->previous = $sibling; $sibling->setParent($this->parent); if (!$sibling->previous) { $sibling->parent->firstChild = $sibling; } }