diff --git a/composer.json b/composer.json index 35f1df8..fcf710f 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": "~8.2.0 || ~8.3.0 || ~8.4.0", "ext-dom": "*", - "goetas-webservices/xsd-reader": "^0.4.6", + "goetas-webservices/xsd-reader": "^0.4.8", "php-soap/engine": "^2.13", "php-soap/wsdl": "^1.10", "php-soap/xml": "^1.8.0", diff --git a/src/Metadata/Converter/Types/Configurator/AnyElementConfigurator.php b/src/Metadata/Converter/Types/Configurator/AnyElementConfigurator.php new file mode 100644 index 0000000..2a11435 --- /dev/null +++ b/src/Metadata/Converter/Types/Configurator/AnyElementConfigurator.php @@ -0,0 +1,53 @@ +value(); + $targetNamespace = $xsdType->getSchema()->getTargetNamespace() ?? ''; + + $configure = pipe( + static fn (MetaType $metaType): MetaType => (new DocsConfigurator())($metaType, $xsdType, $context), + static fn (MetaType $metaType): MetaType => (new OccurrencesConfigurator())($metaType, $xsdType, $context), + ); + + return $configure( + $engineType + ->withXmlTargetNodeName('any') + ->withXmlTypeName('any') + ->withBaseType('anyXML') + ->withXmlNamespace($xsd) + ->withXmlNamespaceName($context->knownNamespaces->lookupNameFromNamespace($xsd)->unwrapOr('xsd')) + ->withXmlTargetNamespace($targetNamespace) + ->withXmlTargetNamespaceName( + $context->knownNamespaces->lookupNameFromNamespace($targetNamespace)->unwrapOr( + $engineType->getXmlNamespaceName() + ) + ) + ->withMeta( + static fn (TypeMeta $meta): TypeMeta => $meta + ->withRestriction([ + 'processXMLContent' => [ + ['value' => $xsdType->getProcessContents()->value], + ] + ]) + ->withIsElement(true) + ) + ); + } +} diff --git a/src/Metadata/Converter/Types/Visitor/ElementContainerVisitor.php b/src/Metadata/Converter/Types/Visitor/ElementContainerVisitor.php index b18acc2..5820f4b 100644 --- a/src/Metadata/Converter/Types/Visitor/ElementContainerVisitor.php +++ b/src/Metadata/Converter/Types/Visitor/ElementContainerVisitor.php @@ -39,6 +39,7 @@ private function parseElementItem(ElementItem $element, TypesConverterContext $c $typeName = $type?->getName() ?: $element->getName(); $configure = pipe( static fn (EngineType $engineType): EngineType => (new Configurator\ElementConfigurator())($engineType, $element, $context), + static fn (EngineType $engineType): EngineType => (new Configurator\AnyElementConfigurator())($engineType, $element, $context), ); return new PropertyCollection( diff --git a/tests/PhpCompatibility/schema1012.phpt b/tests/PhpCompatibility/schema1012.phpt new file mode 100644 index 0000000..533ec8e --- /dev/null +++ b/tests/PhpCompatibility/schema1012.phpt @@ -0,0 +1,29 @@ +--TEST-- +SOAP XML Schema 1001: Any elements +--FILE-- + + + + + + + + + +EOF; +test_schema($schema,'type="tns:GetCustomerDetailsRequest"'); +?> +--EXPECT-- +Methods: + > test(GetCustomerDetailsRequest $testParam): void + +Types: + > http://test-uri/:GetCustomerDetailsRequest { + string $customerId + ?string $countryCode + any $any + } +