--TEST-- GH-9142 (DOMChildNode replaceWith() double-free error when replacing elements not separated by any whitespace) --EXTENSIONS-- dom --FILE-- OneTwo'; ($dom = new DOMDocument('1.0', 'UTF-8'))->loadHTML($document); foreach ((new DOMXPath($dom))->query('//var') as $var) { $var->replaceWith($dom->createElement('p', $var->nodeValue)); } var_dump($dom->saveHTML()); ?> --EXPECT-- string(154) "

One

Two

"