From 5ab804a172e91812698400c60a9cd2961c89a3f8 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sun, 31 May 2026 23:35:57 +0200 Subject: [PATCH 1/4] Migrate DOM-classes to PHP 8.4's new DOM-API --- composer.json | 2 +- src/Utils/XPath.php | 11 +++++------ src/XML/wsse/AbstractAttributedString.php | 10 +++++----- src/XML/wsse/AbstractBinarySecurityTokenType.php | 10 +++++----- src/XML/wsse/AbstractEmbeddedType.php | 10 +++++----- src/XML/wsse/AbstractEncodedString.php | 10 +++++----- src/XML/wsse/AbstractKeyIdentifierType.php | 10 +++++----- src/XML/wsse/AbstractPasswordString.php | 10 +++++----- src/XML/wsse/AbstractReferenceType.php | 10 +++++----- src/XML/wsse/AbstractSecurityHeaderType.php | 10 +++++----- src/XML/wsse/AbstractSecurityTokenReferenceType.php | 10 +++++----- src/XML/wsse/AbstractTransformationParametersType.php | 10 +++++----- src/XML/wsse/AbstractUsernameTokenType.php | 10 +++++----- src/XML/wsse11/AbstractEncryptedHeader.php | 6 +++--- src/XML/wsse11/AbstractSignatureConfirmation.php | 4 ++-- src/XML/wsse11/EncryptedHeader.php | 4 ++-- src/XML/wsse11/SignatureConfirmation.php | 4 ++-- src/XML/wsu/AbstractAttributedDateTime.php | 10 +++++----- src/XML/wsu/AbstractAttributedURI.php | 10 +++++----- src/XML/wsu/AbstractTimestamp.php | 10 +++++----- tests/Security/XML/wsse/BinarySecurityTokenTest.php | 9 +++++---- tests/Security/XML/wsse/EmbeddedTest.php | 9 +++++---- tests/Security/XML/wsse/KeyIdentifierTest.php | 9 +++++---- tests/Security/XML/wsse/NonceTest.php | 9 +++++---- tests/Security/XML/wsse/PasswordTest.php | 9 +++++---- tests/Security/XML/wsse/ReferenceTest.php | 9 +++++---- tests/Security/XML/wsse/SecurityTest.php | 9 +++++---- .../Security/XML/wsse/SecurityTokenReferenceTest.php | 9 +++++---- .../XML/wsse/TransformationParametersTest.php | 9 +++++---- tests/Security/XML/wsse/UsernameTest.php | 9 +++++---- tests/Security/XML/wsse/UsernameTokenTest.php | 9 +++++---- tests/Security/XML/wsse11/EncryptedHeaderTest.php | 9 +++++---- tests/Security/XML/wsse11/IterationTest.php | 9 +++++---- tests/Security/XML/wsse11/SaltTest.php | 9 +++++---- .../Security/XML/wsse11/SignatureConfirmationTest.php | 9 +++++---- tests/Security/XML/wsu/CreatedTest.php | 9 +++++---- tests/Security/XML/wsu/ExpiresTest.php | 9 +++++---- tests/Security/XML/wsu/TimestampTest.php | 9 +++++---- 38 files changed, 175 insertions(+), 158 deletions(-) diff --git a/composer.json b/composer.json index cc04c7f..83a1f10 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "simplesamlphp/simplesamlphp-test-framework": "~1.11", - "simplesamlphp/xml-soap": "~2.3" + "simplesamlphp/xml-soap": "dev-feature/dom-migration-php84" }, "autoload": { "psr-4": { diff --git a/src/Utils/XPath.php b/src/Utils/XPath.php index c01951b..8051fbb 100644 --- a/src/Utils/XPath.php +++ b/src/Utils/XPath.php @@ -4,8 +4,7 @@ namespace SimpleSAML\WebServices\Security\Utils; -use DOMNode; -use DOMXPath; +use Dom; use SimpleSAML\WebServices\Security\Constants as C; /** @@ -16,15 +15,15 @@ class XPath extends \SimpleSAML\XPath\XPath { /* - * Get a DOMXPath object that can be used to search for WS Security elements. + * Get a Dom\XPath object that can be used to search for WS Security elements. * - * @param \DOMNode $node The document to associate to the DOMXPath object. + * @param \Dom\Node $node The document to associate to the Dom\XPath object. * @param bool $autoregister Whether to auto-register all namespaces used in the document * - * @return \DOMXPath A DOMXPath object ready to use in the given document, with several + * @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several * ws-related namespaces already registered. */ - public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath + public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath { $xp = parent::getXPath($node, $autoregister); diff --git a/src/XML/wsse/AbstractAttributedString.php b/src/XML/wsse/AbstractAttributedString.php index f25d64c..df8c267 100644 --- a/src/XML/wsse/AbstractAttributedString.php +++ b/src/XML/wsse/AbstractAttributedString.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -61,12 +61,12 @@ public function __construct( /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -85,9 +85,9 @@ public static function fromXML(DOMElement $xml): static /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = $this->getContent()->getValue(); diff --git a/src/XML/wsse/AbstractBinarySecurityTokenType.php b/src/XML/wsse/AbstractBinarySecurityTokenType.php index 772ae7b..3dea65d 100644 --- a/src/XML/wsse/AbstractBinarySecurityTokenType.php +++ b/src/XML/wsse/AbstractBinarySecurityTokenType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -56,12 +56,12 @@ public function getValueType(): ?AnyURIValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -84,9 +84,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement $parent The element we should append this username token to. + * @param \Dom\Element $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/XML/wsse/AbstractEmbeddedType.php b/src/XML/wsse/AbstractEmbeddedType.php index d792156..8a4bce3 100644 --- a/src/XML/wsse/AbstractEmbeddedType.php +++ b/src/XML/wsse/AbstractEmbeddedType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -70,12 +70,12 @@ public function isEmptyElement(): bool /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -91,9 +91,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse/AbstractEncodedString.php b/src/XML/wsse/AbstractEncodedString.php index cbac834..631702e 100644 --- a/src/XML/wsse/AbstractEncodedString.php +++ b/src/XML/wsse/AbstractEncodedString.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -51,12 +51,12 @@ public function getEncodingType(): ?AnyURIValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -76,9 +76,9 @@ public static function fromXML(DOMElement $xml): static /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/XML/wsse/AbstractKeyIdentifierType.php b/src/XML/wsse/AbstractKeyIdentifierType.php index 8803b51..5b7c8f9 100644 --- a/src/XML/wsse/AbstractKeyIdentifierType.php +++ b/src/XML/wsse/AbstractKeyIdentifierType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -51,12 +51,12 @@ public function getValueType(): ?AnyURIValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -79,9 +79,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement $parent The element we should append this username token to. + * @param \Dom\Element $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/XML/wsse/AbstractPasswordString.php b/src/XML/wsse/AbstractPasswordString.php index 69a1657..244123f 100644 --- a/src/XML/wsse/AbstractPasswordString.php +++ b/src/XML/wsse/AbstractPasswordString.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -50,12 +50,12 @@ public function getType(): ?AnyURIValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -75,9 +75,9 @@ public static function fromXML(DOMElement $xml): static /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/XML/wsse/AbstractReferenceType.php b/src/XML/wsse/AbstractReferenceType.php index bac101b..6afc279 100644 --- a/src/XML/wsse/AbstractReferenceType.php +++ b/src/XML/wsse/AbstractReferenceType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -62,12 +62,12 @@ public function getURI(): ?AnyURIValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -83,9 +83,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse/AbstractSecurityHeaderType.php b/src/XML/wsse/AbstractSecurityHeaderType.php index d3abbef..394fa39 100644 --- a/src/XML/wsse/AbstractSecurityHeaderType.php +++ b/src/XML/wsse/AbstractSecurityHeaderType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -57,12 +57,12 @@ public function isEmptyElement(): bool /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -77,9 +77,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this SecurityHeaderType token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse/AbstractSecurityTokenReferenceType.php b/src/XML/wsse/AbstractSecurityTokenReferenceType.php index 36fbd45..eb10435 100644 --- a/src/XML/wsse/AbstractSecurityTokenReferenceType.php +++ b/src/XML/wsse/AbstractSecurityTokenReferenceType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -77,11 +77,11 @@ public function isEmptyElement(): bool /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -108,9 +108,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this SecurityTokenReferenceType token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse/AbstractTransformationParametersType.php b/src/XML/wsse/AbstractTransformationParametersType.php index 45b3fea..182c795 100644 --- a/src/XML/wsse/AbstractTransformationParametersType.php +++ b/src/XML/wsse/AbstractTransformationParametersType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\ExtendableElementTrait; @@ -56,12 +56,12 @@ public function isEmptyElement(): bool /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -76,9 +76,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse/AbstractUsernameTokenType.php b/src/XML/wsse/AbstractUsernameTokenType.php index a73bf88..c508521 100644 --- a/src/XML/wsse/AbstractUsernameTokenType.php +++ b/src/XML/wsse/AbstractUsernameTokenType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -79,12 +79,12 @@ public function getUsername(): Username /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -110,9 +110,9 @@ public static function fromXML(DOMElement $xml): static /** * Add this username token to an XML element. * - * @param \DOMElement|null $parent The element we should append this username token to. + * @param \Dom\Element|null $parent The element we should append this username token to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/XML/wsse11/AbstractEncryptedHeader.php b/src/XML/wsse11/AbstractEncryptedHeader.php index feb20f5..ce0d5be 100644 --- a/src/XML/wsse11/AbstractEncryptedHeader.php +++ b/src/XML/wsse11/AbstractEncryptedHeader.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse11; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Type\IDValue; use SimpleSAML\WebServices\Security\XML\wsu\IDTrait; @@ -75,9 +75,9 @@ public function getEncryptedData(): EncryptedData /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - final public function toXML(?DOMElement $parent = null): DOMElement + final public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/XML/wsse11/AbstractSignatureConfirmation.php b/src/XML/wsse11/AbstractSignatureConfirmation.php index 2961a2c..f15871a 100644 --- a/src/XML/wsse11/AbstractSignatureConfirmation.php +++ b/src/XML/wsse11/AbstractSignatureConfirmation.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse11; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Type\IDValue; use SimpleSAML\WebServices\Security\XML\wsu\IDTrait; use SimpleSAML\XMLSchema\Type\Base64BinaryValue; @@ -44,7 +44,7 @@ public function getValue(): Base64BinaryValue /** */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->setAttribute('Value', $this->getValue()->getValue()); diff --git a/src/XML/wsse11/EncryptedHeader.php b/src/XML/wsse11/EncryptedHeader.php index ccad8bf..8804b77 100644 --- a/src/XML/wsse11/EncryptedHeader.php +++ b/src/XML/wsse11/EncryptedHeader.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse11; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -31,7 +31,7 @@ final class EncryptedHeader extends AbstractEncryptedHeader implements SchemaVal * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); diff --git a/src/XML/wsse11/SignatureConfirmation.php b/src/XML/wsse11/SignatureConfirmation.php index 0a0c5a7..1e91fc6 100644 --- a/src/XML/wsse11/SignatureConfirmation.php +++ b/src/XML/wsse11/SignatureConfirmation.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsse11; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Constants as C; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -29,7 +29,7 @@ final class SignatureConfirmation extends AbstractSignatureConfirmation implemen * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); diff --git a/src/XML/wsu/AbstractAttributedDateTime.php b/src/XML/wsu/AbstractAttributedDateTime.php index 83c9684..292ea4f 100644 --- a/src/XML/wsu/AbstractAttributedDateTime.php +++ b/src/XML/wsu/AbstractAttributedDateTime.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsu; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Type\DateTimeValue; use SimpleSAML\WebServices\Security\Type\IDValue; @@ -58,12 +58,12 @@ public function getDateTime(): DateTimeValue /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -82,9 +82,9 @@ public static function fromXML(DOMElement $xml): static /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - final public function toXML(?DOMElement $parent = null): DOMElement + final public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = $this->getDateTime()->getValue(); diff --git a/src/XML/wsu/AbstractAttributedURI.php b/src/XML/wsu/AbstractAttributedURI.php index 4088e23..8b01564 100644 --- a/src/XML/wsu/AbstractAttributedURI.php +++ b/src/XML/wsu/AbstractAttributedURI.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsu; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Type\IDValue; use SimpleSAML\XML\ExtendableAttributesTrait; @@ -52,12 +52,12 @@ final protected function __construct( /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -72,9 +72,9 @@ public static function fromXML(DOMElement $xml): static /** - * @param \DOMElement|null $parent + * @param \Dom\Element|null $parent */ - final public function toXML(?DOMElement $parent = null): DOMElement + final public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = $this->getContent()->getValue(); diff --git a/src/XML/wsu/AbstractTimestamp.php b/src/XML/wsu/AbstractTimestamp.php index c57cd35..65d08fa 100644 --- a/src/XML/wsu/AbstractTimestamp.php +++ b/src/XML/wsu/AbstractTimestamp.php @@ -4,7 +4,7 @@ namespace SimpleSAML\WebServices\Security\XML\wsu; -use DOMElement; +use Dom; use SimpleSAML\WebServices\Security\Assert\Assert; use SimpleSAML\WebServices\Security\Type\IDValue; use SimpleSAML\XML\ExtendableAttributesTrait; @@ -95,12 +95,12 @@ public function isEmptyElement(): bool /** * Create an instance of this object from its XML representation. * - * @param \DOMElement $xml + * @param \Dom\Element $xml * * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -127,9 +127,9 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Timestamp to XML. * - * @param \DOMElement|null $parent The element we should append this class to. + * @param \Dom\Element|null $parent The element we should append this class to. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/tests/Security/XML/wsse/BinarySecurityTokenTest.php b/tests/Security/XML/wsse/BinarySecurityTokenTest.php index 26fc30e..bb11cd7 100644 --- a/tests/Security/XML/wsse/BinarySecurityTokenTest.php +++ b/tests/Security/XML/wsse/BinarySecurityTokenTest.php @@ -75,9 +75,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($binarySecurityToken), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($binarySecurityToken); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/EmbeddedTest.php b/tests/Security/XML/wsse/EmbeddedTest.php index 6342b4d..8060aa1 100644 --- a/tests/Security/XML/wsse/EmbeddedTest.php +++ b/tests/Security/XML/wsse/EmbeddedTest.php @@ -69,10 +69,11 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($embedded), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($embedded); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/Security/XML/wsse/KeyIdentifierTest.php b/tests/Security/XML/wsse/KeyIdentifierTest.php index e18c36e..38c6945 100644 --- a/tests/Security/XML/wsse/KeyIdentifierTest.php +++ b/tests/Security/XML/wsse/KeyIdentifierTest.php @@ -75,9 +75,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($keyIdentifier), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($keyIdentifier); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/NonceTest.php b/tests/Security/XML/wsse/NonceTest.php index e8e3621..3437305 100644 --- a/tests/Security/XML/wsse/NonceTest.php +++ b/tests/Security/XML/wsse/NonceTest.php @@ -70,9 +70,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($nonce), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($nonce); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/PasswordTest.php b/tests/Security/XML/wsse/PasswordTest.php index 4902e3c..bf4a320 100644 --- a/tests/Security/XML/wsse/PasswordTest.php +++ b/tests/Security/XML/wsse/PasswordTest.php @@ -64,9 +64,10 @@ public function testMarshalling(): void AnyURIValue::fromString('SomeType'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($password), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($password); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/ReferenceTest.php b/tests/Security/XML/wsse/ReferenceTest.php index 31a913c..1863c3b 100644 --- a/tests/Security/XML/wsse/ReferenceTest.php +++ b/tests/Security/XML/wsse/ReferenceTest.php @@ -65,9 +65,10 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($reference), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($reference); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/SecurityTest.php b/tests/Security/XML/wsse/SecurityTest.php index 933ee3a..cd64f99 100644 --- a/tests/Security/XML/wsse/SecurityTest.php +++ b/tests/Security/XML/wsse/SecurityTest.php @@ -117,10 +117,11 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($security), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($security); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/Security/XML/wsse/SecurityTokenReferenceTest.php b/tests/Security/XML/wsse/SecurityTokenReferenceTest.php index 934003f..04acd22 100644 --- a/tests/Security/XML/wsse/SecurityTokenReferenceTest.php +++ b/tests/Security/XML/wsse/SecurityTokenReferenceTest.php @@ -69,10 +69,11 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($securityTokenReference), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($securityTokenReference); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/Security/XML/wsse/TransformationParametersTest.php b/tests/Security/XML/wsse/TransformationParametersTest.php index b393e63..367b982 100644 --- a/tests/Security/XML/wsse/TransformationParametersTest.php +++ b/tests/Security/XML/wsse/TransformationParametersTest.php @@ -65,10 +65,11 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($transformationParameters), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($transformationParameters); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/Security/XML/wsse/UsernameTest.php b/tests/Security/XML/wsse/UsernameTest.php index c0758ce..6efcd82 100644 --- a/tests/Security/XML/wsse/UsernameTest.php +++ b/tests/Security/XML/wsse/UsernameTest.php @@ -60,9 +60,10 @@ public function testMarshalling(): void [$attr], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($username), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($username); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse/UsernameTokenTest.php b/tests/Security/XML/wsse/UsernameTokenTest.php index cb3d733..e70f773 100644 --- a/tests/Security/XML/wsse/UsernameTokenTest.php +++ b/tests/Security/XML/wsse/UsernameTokenTest.php @@ -75,9 +75,10 @@ public function testMarshalling(): void [$attr1], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($usernameToken), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($usernameToken); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse11/EncryptedHeaderTest.php b/tests/Security/XML/wsse11/EncryptedHeaderTest.php index eec6382..0e0bfce 100644 --- a/tests/Security/XML/wsse11/EncryptedHeaderTest.php +++ b/tests/Security/XML/wsse11/EncryptedHeaderTest.php @@ -99,9 +99,10 @@ public function testMarshalling(): void [$mustUnderstand->toAttribute(), $actor->toAttribute()], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($encryptedHeader), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($encryptedHeader); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse11/IterationTest.php b/tests/Security/XML/wsse11/IterationTest.php index 4646dcd..781f2f7 100644 --- a/tests/Security/XML/wsse11/IterationTest.php +++ b/tests/Security/XML/wsse11/IterationTest.php @@ -52,9 +52,10 @@ public function testMarshalling(): void { $iteration = Iteration::fromString('5'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($iteration), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($iteration); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse11/SaltTest.php b/tests/Security/XML/wsse11/SaltTest.php index 7125d39..e8d78c1 100644 --- a/tests/Security/XML/wsse11/SaltTest.php +++ b/tests/Security/XML/wsse11/SaltTest.php @@ -54,9 +54,10 @@ public function testMarshalling(): void $salt = Salt::fromString($content); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($salt), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($salt); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsse11/SignatureConfirmationTest.php b/tests/Security/XML/wsse11/SignatureConfirmationTest.php index 35e9e4a..55ef9e7 100644 --- a/tests/Security/XML/wsse11/SignatureConfirmationTest.php +++ b/tests/Security/XML/wsse11/SignatureConfirmationTest.php @@ -59,9 +59,10 @@ public function testMarshalling(): void IDValue::fromString('phpunit'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($signatureConfirmation), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($signatureConfirmation); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsu/CreatedTest.php b/tests/Security/XML/wsu/CreatedTest.php index 7846f2a..8fa9dea 100644 --- a/tests/Security/XML/wsu/CreatedTest.php +++ b/tests/Security/XML/wsu/CreatedTest.php @@ -55,9 +55,10 @@ public function testMarshalling(): void { $created = new Created(DateTimeValue::fromString('2001-09-13T08:42:00Z')); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($created), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($created); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsu/ExpiresTest.php b/tests/Security/XML/wsu/ExpiresTest.php index e5ee5e0..5895ec5 100644 --- a/tests/Security/XML/wsu/ExpiresTest.php +++ b/tests/Security/XML/wsu/ExpiresTest.php @@ -55,9 +55,10 @@ public function testMarshalling(): void { $expires = new Expires(DateTimeValue::fromString('2001-10-13T09:00:00Z')); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($expires), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($expires); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/Security/XML/wsu/TimestampTest.php b/tests/Security/XML/wsu/TimestampTest.php index d7918cc..a5e0eac 100644 --- a/tests/Security/XML/wsu/TimestampTest.php +++ b/tests/Security/XML/wsu/TimestampTest.php @@ -61,10 +61,11 @@ public function testMarshalling(): void $timestamp = new Timestamp($created, $expires, IDValue::fromString('abc123'), [], []); $this->assertFalse($timestamp->isEmptyElement()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($timestamp), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($timestamp); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } From ce1f0e72ff2839f28e23137fbbadaa775dd8b503 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sun, 31 May 2026 23:53:35 +0200 Subject: [PATCH 2/4] Attempted fix --- src/XML/wsu/AbstractAttributedDateTime.php | 14 +++++++++++++- src/XML/wsu/AbstractAttributedURI.php | 13 ++++++++++++- src/XML/wsu/AbstractTimestamp.php | 13 ++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/XML/wsu/AbstractAttributedDateTime.php b/src/XML/wsu/AbstractAttributedDateTime.php index 292ea4f..6ed38cc 100644 --- a/src/XML/wsu/AbstractAttributedDateTime.php +++ b/src/XML/wsu/AbstractAttributedDateTime.php @@ -89,7 +89,19 @@ final public function toXML(?Dom\Element $parent = null): Dom\Element $e = $this->instantiateParentElement($parent); $e->textContent = $this->getDateTime()->getValue(); - $this->getId()?->toAttribute()->toXML($e); + if ($this->getId() !== null) { + if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { + $namespace = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + $this->getId()->getNamespacePrefix()->getValue(), + $this->getId()->getNamespaceURI(), + ); + $namespace->toXML($parent); + } + + $this->getId()->toAttribute()->toXML($e); + } foreach ($this->getAttributesNS() as $attr) { $attr->toXML($e); diff --git a/src/XML/wsu/AbstractAttributedURI.php b/src/XML/wsu/AbstractAttributedURI.php index 8b01564..cf4781c 100644 --- a/src/XML/wsu/AbstractAttributedURI.php +++ b/src/XML/wsu/AbstractAttributedURI.php @@ -79,7 +79,18 @@ final public function toXML(?Dom\Element $parent = null): Dom\Element $e = $this->instantiateParentElement($parent); $e->textContent = $this->getContent()->getValue(); - $this->getId()?->toAttribute()->toXML($e); + if ($this->getId() !== null) { + if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { + $namespace = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + $this->getId()->getNamespacePrefix()->getValue(), + $this->getId()->getNamespaceURI(), + ); + } + + $this->getId()?->toAttribute()->toXML($e); + } foreach ($this->getAttributesNS() as $attr) { $attr->toXML($e); diff --git a/src/XML/wsu/AbstractTimestamp.php b/src/XML/wsu/AbstractTimestamp.php index 65d08fa..56250d6 100644 --- a/src/XML/wsu/AbstractTimestamp.php +++ b/src/XML/wsu/AbstractTimestamp.php @@ -133,7 +133,18 @@ public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); - $this->getId()?->toAttribute()->toXML($e); + if ($this->getId() !== null) { + if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { + $namespace = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + $this->getId()->getNamespacePrefix()->getValue(), + $this->getId()->getNamespaceURI(), + ); + } + + $this->getId()?->toAttribute()->toXML($e); + } foreach ($this->getAttributesNS() as $attr) { $attr->toXML($e); From ce61040f3375dc22b298a2d0c82cd940bad200a2 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 4 Jun 2026 10:35:56 +0200 Subject: [PATCH 3/4] Migrate DOM-classes to PHP 8.4's new DOM-API --- tests/resources/xml/wsse/Security.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/resources/xml/wsse/Security.xml b/tests/resources/xml/wsse/Security.xml index 072c31c..448bb37 100644 --- a/tests/resources/xml/wsse/Security.xml +++ b/tests/resources/xml/wsse/Security.xml @@ -1,5 +1,5 @@ - - /CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI= + + /CTj03d1DB5e2t7CTo9BEzCf5S9NRzwnBgZRlm32REI= From ec024c7bf997b950b4d78959caa5a978cdbf0ac4 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 4 Jun 2026 10:50:04 +0200 Subject: [PATCH 4/4] Migrate DOM-classes to PHP 8.4's new DOM-API --- src/XML/wsu/AbstractAttributedDateTime.php | 10 ---------- src/XML/wsu/AbstractAttributedURI.php | 11 +---------- src/XML/wsu/AbstractTimestamp.php | 11 +---------- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/XML/wsu/AbstractAttributedDateTime.php b/src/XML/wsu/AbstractAttributedDateTime.php index 6ed38cc..eb6abc2 100644 --- a/src/XML/wsu/AbstractAttributedDateTime.php +++ b/src/XML/wsu/AbstractAttributedDateTime.php @@ -90,16 +90,6 @@ final public function toXML(?Dom\Element $parent = null): Dom\Element $e->textContent = $this->getDateTime()->getValue(); if ($this->getId() !== null) { - if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { - $namespace = new XMLAttribute( - C::NS_XMLNS, - 'xmlns', - $this->getId()->getNamespacePrefix()->getValue(), - $this->getId()->getNamespaceURI(), - ); - $namespace->toXML($parent); - } - $this->getId()->toAttribute()->toXML($e); } diff --git a/src/XML/wsu/AbstractAttributedURI.php b/src/XML/wsu/AbstractAttributedURI.php index cf4781c..3dd287b 100644 --- a/src/XML/wsu/AbstractAttributedURI.php +++ b/src/XML/wsu/AbstractAttributedURI.php @@ -80,16 +80,7 @@ final public function toXML(?Dom\Element $parent = null): Dom\Element $e->textContent = $this->getContent()->getValue(); if ($this->getId() !== null) { - if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { - $namespace = new XMLAttribute( - C::NS_XMLNS, - 'xmlns', - $this->getId()->getNamespacePrefix()->getValue(), - $this->getId()->getNamespaceURI(), - ); - } - - $this->getId()?->toAttribute()->toXML($e); + $this->getId()->toAttribute()->toXML($e); } foreach ($this->getAttributesNS() as $attr) { diff --git a/src/XML/wsu/AbstractTimestamp.php b/src/XML/wsu/AbstractTimestamp.php index 56250d6..d9216cd 100644 --- a/src/XML/wsu/AbstractTimestamp.php +++ b/src/XML/wsu/AbstractTimestamp.php @@ -134,16 +134,7 @@ public function toXML(?Dom\Element $parent = null): Dom\Element $e = $this->instantiateParentElement($parent); if ($this->getId() !== null) { - if ($parent !== null && !$parent->lookupPrefix($this->getId()->getNamespacePrefix()->getValue())) { - $namespace = new XMLAttribute( - C::NS_XMLNS, - 'xmlns', - $this->getId()->getNamespacePrefix()->getValue(), - $this->getId()->getNamespaceURI(), - ); - } - - $this->getId()?->toAttribute()->toXML($e); + $this->getId()->toAttribute()->toXML($e); } foreach ($this->getAttributesNS() as $attr) {