1--TEST-- 2Element::setAttribute() without namespace 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8require __DIR__ . "/dump_attr.inc"; 9 10$dom = Dom\HTMLDocument::createEmpty(); 11$container = $dom->appendChild($dom->createElement("container")); 12 13$attrs = []; 14 15function setAttribute($container, string $name, string $value): Dom\Attr { 16 $container->setAttribute($name, $value); 17 return $container->getAttributeNode($name); 18} 19 20$attrs[] = setAttribute($container, "foo:bar", "&hello1"); 21echo $dom->saveHtml($container), "\n"; 22$attrs[] = setAttribute($container, "foo:bar", "&hello2"); 23echo $dom->saveHtml($container), "\n"; 24$attrs[] = setAttribute($container, "bar", "&hello3"); 25echo $dom->saveHtml($container), "\n"; 26$attrs[] = setAttribute($container, "xmlns", "&hello4"); 27echo $dom->saveHtml($container), "\n"; 28$attrs[] = setAttribute($container, "XMLns", "&hello5"); 29echo $dom->saveHtml($container), "\n"; 30$attrs[] = setAttribute($container, "BAR", "&hello6"); 31echo $dom->saveHtml($container), "\n"; 32 33// Dump at the end to check whether they influenced each other 34foreach ($attrs as $attr) { 35 dumpAttr($attr); 36} 37 38?> 39--EXPECT-- 40<container foo:bar="&hello1"></container> 41<container foo:bar="&hello2"></container> 42<container foo:bar="&hello2" bar="&hello3"></container> 43<container foo:bar="&hello2" bar="&hello3" xmlns="&hello4"></container> 44<container foo:bar="&hello2" bar="&hello3" xmlns="&hello5"></container> 45<container foo:bar="&hello2" bar="&hello6" xmlns="&hello5"></container> 46Attr: foo:bar 47NULL 48string(7) "foo:bar" 49NULL 50Attr: foo:bar 51NULL 52string(7) "foo:bar" 53NULL 54Attr: bar 55NULL 56string(3) "bar" 57NULL 58Attr: xmlns 59NULL 60string(5) "xmlns" 61NULL 62Attr: xmlns 63NULL 64string(5) "xmlns" 65NULL 66Attr: bar 67NULL 68string(3) "bar" 69NULL 70