/** * * @param \import\Token $new */ public function replaceToken(\import\Token $new) { $old = $this->tokens->item($new->getId() - 1); $new = $this->dom->importNode($new->getNode(), true); $old->parentNode->replaceChild($new, $old); }
/** * * @param \import\Token $new */ public function replaceToken(\import\Token $new) { if ($new->getId() != $this->token->getId()) { throw new \RuntimeException('Only current token can be replaced when you are using XMLReader token iterator'); } $old = $this->token->getNode(); $new = $old->ownerDocument->importNode($new->getNode(), true); $old->parentNode->replaceChild($new, $old); }