diff --git a/composer.json b/composer.json index f462f87..b389049 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "ext-dom": "*", "goetas-webservices/xsd-reader": "^0.4.6", - "php-soap/engine": "^2.9", + "php-soap/engine": "^2.10.1", "php-soap/wsdl": "^1.4", "php-soap/xml": "^1.6.0", "veewee/xml": "^3.0", diff --git a/src/Metadata/Converter/Wsdl1ToMethodsConverter.php b/src/Metadata/Converter/Wsdl1ToMethodsConverter.php index aa5edc6..e7460b6 100644 --- a/src/Metadata/Converter/Wsdl1ToMethodsConverter.php +++ b/src/Metadata/Converter/Wsdl1ToMethodsConverter.php @@ -55,14 +55,13 @@ private function parseMethod(Wsdl1SelectedService $service, BindingOperation $bi [] ); - $void = XsdType::guess('void'); $returnType = $outputMessage->map($convertMessageToTypesDict)->mapOr( static fn (array $types): XsdType => match (count($types)) { - 0 => $void, + 0 => XsdType::void(), 1 => first($types), default => XsdType::guess('array') }, - $void + XsdType::void() ); $configure = pipe( diff --git a/src/Metadata/Predicate/IsOfType.php b/src/Metadata/Predicate/IsOfType.php new file mode 100644 index 0000000..970380a --- /dev/null +++ b/src/Metadata/Predicate/IsOfType.php @@ -0,0 +1,40 @@ +name); + $expectedNamespace = $normalize($this->namespace); + + if ($normalize($type->getXmlTypeName()) === $expectedName && $normalize($type->getXmlNamespace()) === $expectedNamespace) { + return true; + } + + $extends = $type->getMeta() + ->extends() + ->filter(static fn (array $extends): bool => $normalize($extends['type']) === $expectedName + && $normalize($extends['namespace']) === $expectedNamespace); + if ($extends->isSome()) { + return true; + } + + return false; + } +} diff --git a/tests/Unit/Metadata/Predicate/IsOfTypeTest.php b/tests/Unit/Metadata/Predicate/IsOfTypeTest.php new file mode 100644 index 0000000..9566b09 --- /dev/null +++ b/tests/Unit/Metadata/Predicate/IsOfTypeTest.php @@ -0,0 +1,120 @@ + [ + 'https://test', + 'test', + (new XsdType('')), + false, + ]; + yield 'invalid-type' => [ + 'https://test', + 'test', + (new XsdType('test')) + ->withXmlTypeName('invalid') + ->withXmlNamespace('https://test'), + false, + ]; + yield 'invalid-ns' => [ + 'https://test', + 'test', + (new XsdType('test')) + ->withXmlTypeName('test') + ->withXmlNamespace('invalid'), + false, + ]; + yield 'valid' => [ + 'https://test', + 'test', + (new XsdType('test')) + ->withXmlTypeName('test') + ->withXmlNamespace('https://test'), + true, + ]; + yield 'valid-case-insensitive' => [ + 'https://TEST', + 'TEST', + (new XsdType('test')) + ->withXmlTypeName('test') + ->withXmlNamespace('https://test'), + true, + ]; + yield 'invalid-extend-type' => [ + 'https://test', + 'test', + (new XsdType('')) + ->withMeta( + static fn (TypeMeta $meta) => $meta->withExtends([ + 'type' => 'invalid', + 'namespace' => 'https://test', + 'isSimple' => false, + ]) + ), + false, + ]; + yield 'invalid-extend-ns' => [ + 'https://test', + 'test', + (new XsdType('')) + ->withMeta( + static fn (TypeMeta $meta) => $meta->withExtends([ + 'type' => 'test', + 'namespace' => 'invalid', + 'isSimple' => false, + ]) + ), + false, + ]; + yield 'valid-extend' => [ + 'https://test', + 'test', + (new XsdType('')) + ->withMeta( + static fn (TypeMeta $meta) => $meta->withExtends([ + 'type' => 'test', + 'namespace' => 'https://test', + 'isSimple' => false, + ]) + ), + true, + ]; + yield 'valid-extend-case-insensitive' => [ + 'https://TEST', + 'TEST', + (new XsdType('')) + ->withMeta( + static fn (TypeMeta $meta) => $meta->withExtends([ + 'type' => 'test', + 'namespace' => 'https://test', + 'isSimple' => false, + ]) + ), + true, + ]; + } +}