mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

There were multiple things here since forever, see the GH thread [1] for discussion. There were already many fixes to this function previously, and as a consequence of one of those fixes this started throwing exceptions for a correct use-case. It turns out that even when reverting to the previous behaviour there are still bugs. Just fix all of them while we have the chance. [1] https://github.com/php/php-src/issues/12870 Closes GH-12888.
26 lines
982 B
PHP
26 lines
982 B
PHP
<?php
|
|
|
|
function test(?string $uri, string $qualifiedName) {
|
|
$uri_readable = is_null($uri) ? 'NULL' : "\"$uri\"";
|
|
echo "--- Testing $uri_readable, \"$qualifiedName\" ---\n";
|
|
$d = new DOMDocument();
|
|
$d->appendChild($d->createElement('root'));
|
|
try {
|
|
$attr = $d->createAttributeNS($uri, $qualifiedName);
|
|
$d->documentElement->setAttributeNodeNS($attr);
|
|
echo "Attr prefix: ";
|
|
var_dump($attr->prefix);
|
|
echo "Attr namespaceURI: ";
|
|
var_dump($attr->namespaceURI);
|
|
echo "Attr value: ";
|
|
var_dump($attr->value);
|
|
echo "root namespaceURI: ";
|
|
var_dump($d->documentElement->namespaceURI);
|
|
echo "Equality check: ";
|
|
$parts = explode(':', $qualifiedName);
|
|
var_dump($attr === $d->documentElement->getAttributeNodeNS($uri, $parts[count($parts) - 1]));
|
|
echo $d->saveXML(), "\n";
|
|
} catch (DOMException $e) {
|
|
echo "Exception: ", $e->getMessage(), "\n\n";
|
|
}
|
|
}
|