xref: /PHP-8.2/ext/spl/tests/bug54971.phpt (revision 7f2f0c00)
1--TEST--
2Bug #54971 (Wrong result when using iterator_to_array with use_keys on true)
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$source = <<<XML
9<root>
10<node>val1</node>
11<node>val2</node>
12</root>
13XML;
14
15
16$doc = new DOMDocument();
17$doc->loadXML($source);
18
19$xpath = new DOMXPath($doc);
20$items = $xpath->query('//node');
21
22print_r(array_map('get_class', iterator_to_array($items, false)));
23print_r(array_map('get_class', iterator_to_array($items, true)));
24?>
25--EXPECT--
26Array
27(
28    [0] => DOMElement
29    [1] => DOMElement
30)
31Array
32(
33    [0] => DOMElement
34    [1] => DOMElement
35)
36