tempRoot}>" . $convertedSource . "tempRoot}>", $options); } /** * Strip the temporarily added root element */ private function unwrapTempRoot(string $output): string { if ($this->firstChild->nodeName === $this->tempRoot) { return substr($output, strlen($this->tempRoot) + 2, -strlen($this->tempRoot) - 4); } return $output; } /** * Dump the internal document into a HTML string */ #[\ReturnTypeWillChange] public function saveHTML(DOMNode|null $node = null, bool $entities = false): string|false { $html = parent::saveHTML($node); if ($entities === false) { $html = html_entity_decode($html); } if ($node === null) { $html = $this->unwrapTempRoot($html); } return $html; } }