xref: /PHP-7.4/ext/dom/tests/bug47430.phpt (revision 782352c5)
1--TEST--
2Bug #47430 (Errors after writing to nodeValue parameter of an absent previousSibling).
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7$xml = '<?xml
8version="1.0"?><html><p><i>Hello</i></p><p><i>World!</i></p></html>';
9$dom = new DOMDocument();
10$dom->loadXML($xml);
11
12$elements = $dom->getElementsByTagName('i');
13foreach ($elements as $i) {
14  $i->previousSibling->nodeValue = '';
15}
16
17$arr = array();
18$arr[0] = 'Value';
19
20print_r($arr);
21
22?>
23--EXPECTF--
24Warning: Creating default object from empty value in %s on line %d
25
26Warning: Creating default object from empty value in %s on line %d
27Array
28(
29    [0] => Value
30)
31