Skip to content

Commit 675c339

Browse files
committed
improve DOMDocument phpdoc usage reasoning
1 parent b21a8cf commit 675c339

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/XML/SchemaValidatableElementTrait.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ public static function schemaValidate(Dom\Document $document, ?string $schemaFil
5151
throw new \LogicException('Schema validation requires an instance of Dom\\XMLDocument.');
5252
}
5353

54-
/**
55-
* Validates using a legacy \DOMDocument round-trip (serialize + re-parse) before running schema validation.
56-
* This avoids false negatives seen with Dom\Document::schemaValidate(), especially around xs:QName
57-
* prefix scope. Validation is performed against the exact serialized XML that would be
58-
* exchanged externally.
59-
*/
6054
$root = $document->documentElement;
6155
if ($root === null) {
6256
throw new SchemaViolationException('The document has no document element.');
@@ -67,6 +61,14 @@ public static function schemaValidate(Dom\Document $document, ?string $schemaFil
6761
throw new SchemaViolationException('Could not serialize XML for schema validation.');
6862
}
6963

64+
/**
65+
* Validates using a legacy \DOMDocument round-trip (serialize + re-parse) before running schema validation.
66+
* This avoids false negatives seen with Dom\Document::schemaValidate(), especially around xs:QName
67+
* prefix scope. Validation is performed against the exact serialized XML that would be
68+
* exchanged externally.
69+
* TODO: Revisit when Dom\Document::schemaValidate() reliably handles xs:QName prefix scope
70+
* (avoid legacy \DOMDocument round-trip).
71+
*/
7072
$legacy = new \DOMDocument('1.0', 'UTF-8');
7173
$legacy->preserveWhiteSpace = true;
7274
$legacy->formatOutput = false;

0 commit comments

Comments
 (0)