1--TEST--
2NamedNodeMap dimensions
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\XMLDocument::createFromString('<root a="1" b="2" c="3"></root>');
9$attributes = $dom->documentElement->attributes;
10
11$test_values = [-1, 0, 1, 2, 3, 1.0, 1.1, true, null, "0", "", "1", "8", "a", "b", "c", "d"];
12
13foreach ($test_values as $value) {
14    echo "--- ", json_encode($value), " ---\n";
15    try {
16        var_dump($attributes[$value] ? $attributes[$value]->nodeName : "N/A", isset($attributes[$value]), empty($attributes[$value]));
17    } catch (Error $e) {
18        echo $e->getMessage(), "\n";
19    }
20}
21
22?>
23--EXPECTF--
24--- -1 ---
25string(1) "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\NamedNodeMap
62--- null ---
63Cannot access offset of type null on Dom\NamedNodeMap
64--- "0" ---
65string(1) "a"
66bool(true)
67bool(false)
68--- "" ---
69string(3) "N/A"
70bool(false)
71bool(true)
72--- "1" ---
73string(1) "b"
74bool(true)
75bool(false)
76--- "8" ---
77string(3) "N/A"
78bool(false)
79bool(true)
80--- "a" ---
81string(1) "a"
82bool(true)
83bool(false)
84--- "b" ---
85string(1) "b"
86bool(true)
87bool(false)
88--- "c" ---
89string(1) "c"
90bool(true)
91bool(false)
92--- "d" ---
93string(3) "N/A"
94bool(false)
95bool(true)
96