Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/XML/DOMDocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 1 addition & 9 deletions src/XML/SerializableElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 0 additions & 7 deletions src/XML/TestUtils/SchemaValidationTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace SimpleSAML\XML\TestUtils;

use Dom;
use SimpleSAML\XML\DOMDocumentFactory;

use function class_exists;

Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Helper/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
4 changes: 1 addition & 3 deletions tests/Helper/ExtendableAttributesElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
4 changes: 1 addition & 3 deletions tests/Helper/ExtendableElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions tests/resources/xml/ssp_ExtendableElement.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ssp:ExtendableElement xmlns:ssp="urn:x-simplesamlphp:namespace" xmlns:dummy="urn:custom:dummy">
<ssp:ExtendableElement xmlns:ssp="urn:x-simplesamlphp:namespace">
<ssp:Chunk>some</ssp:Chunk>
<dummy:Chunk>some</dummy:Chunk>
<dummy:Chunk xmlns:dummy="urn:custom:dummy">some</dummy:Chunk>
</ssp:ExtendableElement>
Loading