1--TEST--
2NodeList dimensions
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\XMLDocument::createFromString('<root><a/><b/><c/></root>');
9$children = $dom->documentElement->childNodes;
10
11$test_values = [-1, 0, 1, 2, 3, 1.0, 1.1, true, null, "0", "1", "", "foo"];
12
13foreach ($test_values as $value) {
14    echo "--- ", json_encode($value), " ---\n";
15    try {
16        var_dump($children[$value] ? $children[$value]->nodeName : "N/A", isset($children[$value]), empty($children[$value]));
17    } catch (Error $e) {
18        echo $e->getMessage(), "\n";
19    }
20}
21
22?>
23--EXPECTF--
24--- -1 ---
25string(3) "N/A"
26bool(false)
27bool(true)
28--- 0 ---
29string(1) "a"
30bool(true)
31bool(false)
32--- 1 ---
33string(1) "b"
34bool(true)
35bool(false)
36--- 2 ---
37string(1) "c"
38bool(true)
39bool(false)
40--- 3 ---
41string(3) "N/A"
42bool(false)
43bool(true)
44--- 1 ---
45string(1) "b"
46bool(true)
47bool(false)
48--- 1.1 ---
49
50Deprecated: Implicit conversion from float 1.1 to int loses precision in %s on line %d
51
52Deprecated: Implicit conversion from float 1.1 to int loses precision in %s on line %d
53
54Deprecated: Implicit conversion from float 1.1 to int loses precision in %s on line %d
55
56Deprecated: Implicit conversion from float 1.1 to int loses precision in %s on line %d
57string(1) "b"
58bool(true)
59bool(false)
60--- true ---
61Cannot access offset of type bool on Dom\NodeList
62--- null ---
63Cannot access offset of type null on Dom\NodeList
64--- "0" ---
65string(1) "a"
66bool(true)
67bool(false)
68--- "1" ---
69string(1) "b"
70bool(true)
71bool(false)
72--- "" ---
73Cannot access offset of type string on Dom\NodeList
74--- "foo" ---
75Cannot access offset of type string on Dom\NodeList
76