Skip to content

Commit ae2fee6

Browse files
committed
Skip xsi:type generation for anonymous complex types.
1 parent f90af5f commit ae2fee6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Xml/Writer/XsiAttributeBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public static function forEncodedValue(
3939
return children([]);
4040
}
4141

42+
// Skip xsi:type declaration for anonymous complexTypes : they don't have an accessible name.
43+
$meta = $context->type->getMeta();
44+
if ($meta->isLocal()->unwrapOr(false)) {
45+
return children([]);
46+
}
47+
4248
[$xsiType, $includeXsiTargetNamespace] = match(true) {
4349
$encoder instanceof Feature\XsiTypeCalculator => [
4450
$encoder->resolveXsiTypeForValue($context, $value),

tests/PhpCompatibility/Schema036Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function expectXml(): string
4949
<tns:test>
5050
<testParam xsi:type="tns:testType">
5151
<int xsi:type="xsd:int">123</int>
52-
<testType2 xsi:type="tns:testType2">
52+
<testType2>
5353
<int xsi:type="xsd:int">123</int>
5454
</testType2>
5555
</testParam>

0 commit comments

Comments
 (0)