From 176548d958571c3a36125c4d67abf196795cb787 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Thu, 4 Dec 2025 11:40:51 +0100 Subject: [PATCH] Skip xsi:type generation for anonymous complex types. --- composer.json | 2 +- src/Xml/Writer/XsiAttributeBuilder.php | 6 ++++++ tests/PhpCompatibility/Schema036Test.php | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3e68f25..054cc26 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php-soap/engine": "^2.16", "php-soap/wsdl": "^1.14", "php-soap/xml": "^1.9", - "php-soap/wsdl-reader": "^0.27" + "php-soap/wsdl-reader": "^0.29" }, "require-dev": { "vimeo/psalm": "~6.13", diff --git a/src/Xml/Writer/XsiAttributeBuilder.php b/src/Xml/Writer/XsiAttributeBuilder.php index 1d62a41..639c397 100644 --- a/src/Xml/Writer/XsiAttributeBuilder.php +++ b/src/Xml/Writer/XsiAttributeBuilder.php @@ -39,6 +39,12 @@ public static function forEncodedValue( return children([]); } + // Skip xsi:type declaration for anonymous complexTypes : they don't have an accessible name. + $meta = $context->type->getMeta(); + if ($meta->isLocal()->unwrapOr(false)) { + return children([]); + } + [$xsiType, $includeXsiTargetNamespace] = match(true) { $encoder instanceof Feature\XsiTypeCalculator => [ $encoder->resolveXsiTypeForValue($context, $value), diff --git a/tests/PhpCompatibility/Schema036Test.php b/tests/PhpCompatibility/Schema036Test.php index 95e55df..5acd0e9 100644 --- a/tests/PhpCompatibility/Schema036Test.php +++ b/tests/PhpCompatibility/Schema036Test.php @@ -49,7 +49,7 @@ protected function expectXml(): string 123 - + 123