public function replaceChild(ContextInterface $context, AbstractBlock $original, AbstractBlock $replacement) { if (($index = $this->children->indexOf($original)) !== false) { $this->children->remove($index); $replacement->setParent($this); $this->children->set($index, $replacement); } else { $this->addChild($replacement); } if ($context->getTip() === $original) { $context->setTip($replacement); } }