1--TEST--
2setAttributeNodeNS with same URI but different prefix
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7// Spec doesn't require to remove redundant namespace declarations.
8// This means that when appending a new attribute the old namespace declaration is reused, hence the prefix stays "foo".
9// Firefox cleans up the old namespace declaration, so there the prefix does change.
10// Chrome doesn't clean it up, so there the prefix doesn't change.
11// Our behaviour is the same as Chrome's due to implementation difficulties.
12$doc = new DOMDocument();
13$doc->appendChild($doc->createElement('container'));
14$attribute = $doc->createAttributeNS('http://php.net/ns1', 'foo:hello');
15$attribute->nodeValue = '1';
16var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue);
17echo $doc->saveXML(), "\n";
18$attribute = $doc->createAttributeNS('http://php.net/ns1', 'bar:hello');
19$attribute->nodeValue = '2';
20var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue);
21echo $doc->saveXML(), "\n";
22$attribute = $doc->createAttributeNS('http://php.net/ns1', 'hello');
23$attribute->nodeValue = '3';
24var_dump($doc->documentElement->setAttributeNodeNS($attribute)?->nodeValue);
25echo $doc->saveXML(), "\n";
26?>
27--EXPECT--
28NULL
29<?xml version="1.0"?>
30<container xmlns:foo="http://php.net/ns1" foo:hello="1"/>
31
32string(1) "1"
33<?xml version="1.0"?>
34<container xmlns:foo="http://php.net/ns1" foo:hello="2"/>
35
36string(1) "2"
37<?xml version="1.0"?>
38<container xmlns:foo="http://php.net/ns1" foo:hello="3"/>
39