1--TEST--
2Dom\Element::getInScopeNamespaces()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8function dump($dom, $name) {
9    echo "\n=== $name ===\n";
10    $list = $dom->getElementsByTagName($name)[0]->getInScopeNamespaces();
11    foreach ($list as $entry) {
12        echo "prefix: ";
13        var_dump($entry->prefix);
14        echo "namespaceURI: ";
15        var_dump($entry->namespaceURI);
16        echo "element->nodeName: ";
17        var_dump($entry->element->nodeName);
18        echo "---\n";
19    }
20}
21
22$dom = Dom\XMLDocument::createFromString(<<<XML
23<root xmlns="urn:a">
24    <child xmlns="">
25        <c:child xmlns:c="urn:c"/>
26    </child>
27    <b:sibling xmlns:b="urn:b" xmlns:d="urn:d" d:foo="bar">
28        <d:child xmlns:d="urn:d2"/>
29    </b:sibling>
30</root>
31XML);
32
33dump($dom, 'c:child');
34dump($dom, 'child');
35dump($dom, 'b:sibling');
36dump($dom, 'd:child');
37dump($dom, 'root');
38
39?>
40--EXPECT--
41=== c:child ===
42prefix: string(1) "c"
43namespaceURI: string(5) "urn:c"
44element->nodeName: string(7) "c:child"
45---
46
47=== child ===
48
49=== b:sibling ===
50prefix: NULL
51namespaceURI: string(5) "urn:a"
52element->nodeName: string(9) "b:sibling"
53---
54prefix: string(1) "b"
55namespaceURI: string(5) "urn:b"
56element->nodeName: string(9) "b:sibling"
57---
58prefix: string(1) "d"
59namespaceURI: string(5) "urn:d"
60element->nodeName: string(9) "b:sibling"
61---
62
63=== d:child ===
64prefix: NULL
65namespaceURI: string(5) "urn:a"
66element->nodeName: string(7) "d:child"
67---
68prefix: string(1) "b"
69namespaceURI: string(5) "urn:b"
70element->nodeName: string(7) "d:child"
71---
72prefix: string(1) "d"
73namespaceURI: string(6) "urn:d2"
74element->nodeName: string(7) "d:child"
75---
76
77=== root ===
78prefix: NULL
79namespaceURI: string(5) "urn:a"
80element->nodeName: string(4) "root"
81---
82