xref: /PHP-8.2/ext/dom/tests/bug47430.phpt (revision bd9f4fa6)
1--TEST--
2Bug #47430 (Errors after writing to nodeValue parameter of an absent previousSibling).
3--EXTENSIONS--
4dom
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    try {
15        $i->previousSibling->nodeValue = '';
16    } catch (Error $e) {
17        echo $e->getMessage(), "\n";
18    }
19}
20
21$arr = array();
22$arr[0] = 'Value';
23
24print_r($arr);
25
26?>
27--EXPECT--
28Attempt to assign property "nodeValue" on null
29Attempt to assign property "nodeValue" on null
30Array
31(
32    [0] => Value
33)
34