Skip to content

Commit 68e205e

Browse files
committed
Use constant
1 parent 8ab3e55 commit 68e205e

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/XML/Attribute.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Dom;
88
use SimpleSAML\XML\Assert\Assert;
9+
use SimpleSAML\XML\Constants as C;
910
use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface;
1011
use SimpleSAML\XMLSchema\Type\StringValue;
1112

@@ -99,7 +100,7 @@ public function toXML(Dom\Element $parent): Dom\Element
99100
{
100101
if ($this->getNamespaceURI() !== null && !$parent->lookupPrefix($this->getNamespacePrefix())) {
101102
$parent->setAttributeNS(
102-
'http://www.w3.org/2000/xmlns/',
103+
C::NS_XMLNS,
103104
'xmlns:' . $this->getNamespacePrefix(),
104105
$this->getNamespaceURI(),
105106
);

src/XML/TypedTextContentTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Dom;
88
use SimpleSAML\XML\Assert\Assert;
9+
use SimpleSAML\XML\Constants as C;
910
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1011
use SimpleSAML\XMLSchema\Exception\InvalidValueTypeException;
1112
use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface;
@@ -101,7 +102,7 @@ public function toXML(?Dom\Element $parent = null): Dom\Element
101102
if ($this->getTextContentType() === QNameValue::class) {
102103
if (!$e->lookupPrefix($this->getContent()->getNamespaceURI()->getValue())) {
103104
$e->setAttributeNS(
104-
'http://www.w3.org/2000/xmlns/',
105+
C::NS_XMLNS,
105106
'xmlns:' . $this->getContent()->getNamespacePrefix()->getValue(),
106107
$this->getContent()->getNamespaceURI()->getValue(),
107108
);

tests/XPath/XPathTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPUnit\Framework\Attributes\CoversClass;
1010
use PHPUnit\Framework\Attributes\DataProvider;
1111
use PHPUnit\Framework\TestCase;
12+
use SimpleSAML\XML\Constants as C;
1213
use SimpleSAML\XML\DOMDocumentFactory;
1314
use SimpleSAML\XPath\XPath;
1415

@@ -265,7 +266,7 @@ public function testXmlnsPrefixedDeclarationRegistersNamespaceViaAttributeBranch
265266
$doc->appendChild($root);
266267

267268
// Add xmlns:foo on the root (attribute-branch should detect and register)
268-
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:foo', 'https://example.org/foo');
269+
$root->setAttributeNS(C::NS_XMLNS, 'xmlns:foo', 'https://example.org/foo');
269270

270271
// Deep subtree that uses foo prefix but the context node itself is unprefixed
271272
$ctx = $doc->createElement('ctx');

0 commit comments

Comments
 (0)