diff --git a/src/XML/DOMDocumentFactory.php b/src/XML/DOMDocumentFactory.php index dbf6be87..759a89c0 100644 --- a/src/XML/DOMDocumentFactory.php +++ b/src/XML/DOMDocumentFactory.php @@ -182,6 +182,7 @@ public static function create(string $version = '1.0', string $encoding = 'UTF-8 * @return \Dom\XMLDocument The same document instance, potentially modified. If the document has no root element * or no namespace declarations to normalize, it is returned unchanged. */ + #[\Deprecated(message: "Not safe to use; will be removed in a new major release", since: "3.2.0")] public static function normalizeDocument(Dom\Document $doc): Dom\Document { $root = $doc->documentElement; diff --git a/src/XML/SerializableElementTrait.php b/src/XML/SerializableElementTrait.php index 47ea269c..a32a67e9 100644 --- a/src/XML/SerializableElementTrait.php +++ b/src/XML/SerializableElementTrait.php @@ -34,17 +34,9 @@ public function __toString(): string /** @var \Dom\XMLDocument $doc */ $doc = $xml->ownerDocument; - $doc = Dom\XMLDocument::createFromString($doc->saveXml($doc->documentElement)); - - if (static::getNormalization() === true) { - $normalized = DOMDocumentFactory::normalizeDocument($doc); - $normalized->formatOutput = $this->formatOutput; - return $normalized->saveXml($normalized->documentElement); - } - - // Non-normalized path $doc->formatOutput = $this->formatOutput; $doc = Dom\XMLDocument::createFromString($doc->saveXml($doc->documentElement)); + return $doc->saveXml($doc->documentElement); } diff --git a/src/XML/TestUtils/SchemaValidationTestTrait.php b/src/XML/TestUtils/SchemaValidationTestTrait.php index 15326419..8a21570e 100644 --- a/src/XML/TestUtils/SchemaValidationTestTrait.php +++ b/src/XML/TestUtils/SchemaValidationTestTrait.php @@ -5,7 +5,6 @@ namespace SimpleSAML\XML\TestUtils; use Dom; -use SimpleSAML\XML\DOMDocumentFactory; use function class_exists; @@ -53,12 +52,6 @@ public function testSchemaValidation(): void // Validate after serialization self::$testedClass::schemaValidate($serializedClass->ownerDocument, self::$schemaFile); - // Validate after normalization - if (self::$testedClass::getNormalization() === true) { - $normalizedDoc = DOMDocumentFactory::normalizeDocument($serializedClass->ownerDocument); - self::$testedClass::schemaValidate($normalizedDoc, self::$schemaFile); - } - // If we got this far and no exceptions were thrown, consider this test passed! $this->addToAssertionCount(1); } diff --git a/tests/Helper/Element.php b/tests/Helper/Element.php index d6b1a2dc..db046d71 100644 --- a/tests/Helper/Element.php +++ b/tests/Helper/Element.php @@ -7,7 +7,6 @@ use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XML\AbstractElement; -use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Type\BooleanValue; use SimpleSAML\XMLSchema\Type\IntegerValue; @@ -132,7 +131,6 @@ public function toXML(?Dom\Element $parent = null): Dom\Element $e->setAttribute('otherText', strval($this->getOtherString())); } - // @phpstan-ignore argument.type, return.type - return DOMDocumentFactory::normalizeDocument($e->ownerDocument)->documentElement; + return $e; } } diff --git a/tests/Helper/ExtendableAttributesElement.php b/tests/Helper/ExtendableAttributesElement.php index d271ca58..facef4fb 100644 --- a/tests/Helper/ExtendableAttributesElement.php +++ b/tests/Helper/ExtendableAttributesElement.php @@ -7,7 +7,6 @@ use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XML\AbstractElement; -use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\ExtendableAttributesTrait; use SimpleSAML\XML\SchemaValidatableElementInterface; use SimpleSAML\XML\SchemaValidatableElementTrait; @@ -81,7 +80,6 @@ public function toXML(?Dom\Element $parent = null): Dom\Element $attr->toXML($e); } - // @phpstan-ignore argument.type, return.type - return DOMDocumentFactory::normalizeDocument($e->ownerDocument)->documentElement; + return $e; } } diff --git a/tests/Helper/ExtendableElement.php b/tests/Helper/ExtendableElement.php index b70e49cf..83e8e2fe 100644 --- a/tests/Helper/ExtendableElement.php +++ b/tests/Helper/ExtendableElement.php @@ -6,7 +6,6 @@ use Dom; use SimpleSAML\XML\AbstractElement; -use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\ExtendableElementTrait; use SimpleSAML\XML\SchemaValidatableElementInterface; use SimpleSAML\XML\SchemaValidatableElementTrait; @@ -80,7 +79,6 @@ public function toXML(?Dom\Element $parent = null): Dom\Element } } - // @phpstan-ignore argument.type, return.type - return DOMDocumentFactory::normalizeDocument($e->ownerDocument)->documentElement; + return $e; } } diff --git a/tests/resources/xml/ssp_ExtendableElement.xml b/tests/resources/xml/ssp_ExtendableElement.xml index d6df75f2..ad055412 100644 --- a/tests/resources/xml/ssp_ExtendableElement.xml +++ b/tests/resources/xml/ssp_ExtendableElement.xml @@ -1,4 +1,4 @@ - + some - some + some