From cc9b67f116502d8fc555fc360fbe408469327b7f Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Mon, 10 Jun 2024 14:29:10 +0200 Subject: [PATCH] Prepare soap-client for new php-soap/encoding package --- README.md | 9 +- UPGRADING.md | 3 +- composer.json | 6 +- docs/cli/generate-classmap.md | 10 +- docs/cli/generate-clientfactory.md | 51 ++-- docs/cli/generate-types.md | 2 - docs/code-generation/configuration.md | 18 +- docs/drivers/metadata.md | 42 ++-- docs/known-issues/ext-soap.md | 116 --------- .../CodeGenerator/ClientGeneratorSpec.php | 4 +- .../CodeGenerator/Model/ParameterSpec.php | 3 +- .../CodeGenerator/Model/PropertySpec.php | 3 +- .../CodeGenerator/Model/ReturnTypeSpec.php | 3 +- .../CodeGenerator/Model/TypeMapSpec.php | 5 +- .../CodeGenerator/Model/TypeSpec.php | 11 +- .../Rules/IsAbstractTypeRuleSpec.php | 8 +- .../Rules/IsExtendingTypeRuleSpec.php | 8 +- .../CodeGenerator/Rules/IsRequestRuleSpec.php | 8 +- .../CodeGenerator/Rules/IsResultRuleSpec.php | 8 +- .../Rules/PropertynameMatchesRuleSpec.php | 7 +- .../CodeGenerator/Rules/TypeMapRuleSpec.php | 15 +- .../Rules/TypenameMatchesRuleSpec.php | 9 +- .../CodeGenerator/TypeGeneratorSpec.php | 9 +- .../Assembler/ClassMapAssembler.php | 9 +- .../CodeGenerator/ClientFactoryGenerator.php | 26 +- .../CodeGenerator/Config/Config.php | 23 ++ .../CodeGenerator/Config/ConfigInterface.php | 4 + .../CodeGenerator/ConfigGenerator.php | 12 +- .../CodeGenerator/Model/Parameter.php | 21 +- .../CodeGenerator/Model/Property.php | 15 +- .../CodeGenerator/Model/ReturnType.php | 14 +- .../SoapClient/CodeGenerator/Model/Type.php | 15 +- .../Console/Command/GenerateTypesCommand.php | 6 +- .../Exception/InvalidArgumentException.php | 42 +--- .../Soap/CodeGeneratorEngineFactory.php | 67 ----- .../SoapClient/Soap/DefaultEngineFactory.php | 60 +++-- src/Phpro/SoapClient/Soap/EngineOptions.php | 155 ++++++++++++ .../Detector/DuplicateTypeNamesDetector.php | 2 +- .../IntersectDuplicateTypesStrategy.php | 2 +- .../RemoveDuplicateTypesStrategy.php | 4 +- .../Functional/Client/ClientTest.php | 20 +- .../ExtSoap/AbstractSoapTestCase.php | 41 --- .../Encoding/DuplicateTypenamesTest.php | 237 ------------------ .../Functional/ExtSoap/Encoding/EnumTest.php | 174 ------------- .../Assembler/AbstractClassAssemblerTest.php | 2 +- .../Assembler/ClassMapAssemblerTest.php | 12 +- .../Assembler/ClientMethodAssemblerTest.php | 14 +- .../Assembler/ConstructorAssemblerTest.php | 6 +- .../Assembler/ExtendAssemblerTest.php | 2 +- .../Assembler/ExtendingTypeAssemblerTest.php | 11 +- .../Assembler/FinalClassAssemblerTest.php | 2 +- .../Assembler/FluentSetterAssemblerTest.php | 8 +- .../Assembler/GetterAssemblerTest.php | 6 +- .../ImmutableSetterAssemblerTest.php | 6 +- .../Assembler/InterfaceAssemblerTest.php | 4 +- .../Assembler/IteratorAssemblerTest.php | 2 +- .../JsonSerializableAssemblerTest.php | 2 +- .../Assembler/PropertyAssemblerTest.php | 8 +- .../Assembler/RequestAssemblerTest.php | 2 +- .../Assembler/ResultAssemblerTest.php | 2 +- .../Assembler/ResultProviderAssemblerTest.php | 2 +- .../Assembler/SetterAssemblerTest.php | 6 +- .../Assembler/TraitAssemblerTest.php | 3 +- .../Assembler/UseAssemblerTest.php | 6 +- .../ClientFactoryGeneratorTest.php | 23 +- .../CodeGenerator/ConfigGeneratorTest.php | 16 +- .../Unit/CodeGenerator/Model/PropertyTest.php | 2 +- .../DuplicateTypeNamesDetectorTest.php | 4 +- .../IntersectDuplicateTypesStrategyTest.php | 4 +- .../RemoveDuplicateTypesStrategyTest.php | 4 +- ...online.com_POST_calculator.asmx_7c968.txt} | 4 +- 71 files changed, 560 insertions(+), 910 deletions(-) delete mode 100644 docs/known-issues/ext-soap.md delete mode 100644 src/Phpro/SoapClient/Soap/CodeGeneratorEngineFactory.php create mode 100644 src/Phpro/SoapClient/Soap/EngineOptions.php rename src/Phpro/SoapClient/Soap/{ExtSoap => }/Metadata/Detector/DuplicateTypeNamesDetector.php (93%) rename src/Phpro/SoapClient/Soap/{ExtSoap => }/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php (96%) rename src/Phpro/SoapClient/Soap/{ExtSoap => }/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php (83%) delete mode 100644 test/PhproTest/SoapClient/Functional/ExtSoap/AbstractSoapTestCase.php delete mode 100644 test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/DuplicateTypenamesTest.php delete mode 100644 test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/EnumTest.php rename test/PhproTest/SoapClient/Unit/Soap/{ExtSoap => }/Metadata/Detector/DuplicateTypeNamesDetectorTest.php (90%) rename test/PhproTest/SoapClient/Unit/Soap/{ExtSoap => }/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php (93%) rename test/PhproTest/SoapClient/Unit/Soap/{ExtSoap => }/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php (91%) rename test/fixtures/vcr/client/{www.dneonline.com_POST_calculator.asmx_fd199.txt => www.dneonline.com_POST_calculator.asmx_7c968.txt} (87%) diff --git a/README.md b/README.md index a322a728..3fb91d8b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Want more information about the future of this project? Check out this list of t You can choose what HTTP client you want to use. This package expects some PSR implementations to be present in order to be installed: +* PSR-6: `psr/cache-implementation` like `symfony/cache` or `cache/*-adapter` * PSR-7: `psr/http-message-implementation` like `nyholm/psr7` or `guzzlehttp/psr7` * PSR-17: `psr/http-factory-implementation` like `nyholm/psr7` or `guzzlehttp/psr7` * PSR-18: `psr/http-client-implementation` like `symfony/http-client` or `guzzlehttp/guzzle` @@ -73,8 +74,8 @@ You can customize the generated code based on the manual installation pages in t - [Get in control of the soap-client](https://github.com/php-soap/engine) - [Psr-18 HTTP Transport](https://github.com/php-soap/psr18-transport/) - [Configure one or multiple HTTP middlewares.](https://github.com/php-soap/psr18-transport/#middleware) - - [Customize how ext-soap behaves](https://github.com/php-soap/ext-soap-engine/) - - [Select a WSDL Provider](https://github.com/php-soap/ext-soap-engine/#wsdlprovider) + - [Customize how the encoding behaves](https://github.com/php-soap/encoding) + - [Select a WSDL loader](https://github.com/php-soap/wsdl#wsdl-loader) - [Manipulate the metadata](docs/drivers/metadata.md) @@ -88,10 +89,6 @@ For more advanced configuration, you can check the documentation inside the php- - [Specify generation `Rules`](docs/code-generation/rules.md) - [Generate code through `Assemblers`](docs/code-generation/assemblers.md) -## Known issues - -- [ext-soap](docs/known-issues/ext-soap.md) - # Why this soap client was made By default, the SoapClient works with a mix of arrays, stdClasses and other scalar types. diff --git a/UPGRADING.md b/UPGRADING.md index e48cacdb..6f0162b7 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -254,7 +254,8 @@ Full example on how you can personalize your factory class: use Http\Client\Common\PluginClient; use Http\Discovery\Psr18ClientDiscovery; use Phpro\SoapClient\Soap\DefaultEngineFactory; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy;use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorChain; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorChain; use Phpro\SoapClient\Soap\Metadata\MetadataOptions; use Soap\ExtSoapEngine\ExtSoapOptions; use Soap\ExtSoapEngine\Wsdl\Naming\Md5Strategy; diff --git a/composer.json b/composer.json index a3674f00..686e2af7 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,9 @@ "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "azjezz/psl": "^2.1", "laminas/laminas-code": "^4.8.0", + "php-soap/cached-engine": "^0.1", "php-soap/engine": "^2.7", - "php-soap/ext-soap-engine": "^1.4", + "php-soap/encoding": "^0.2", "php-soap/psr18-transport": "^1.3", "php-soap/wsdl-reader": "~0.6", "psr/event-dispatcher": "^1.0", @@ -36,7 +37,8 @@ "phpspec/prophecy-phpunit": "^2.0.1", "phpstan/phpstan": "^1.10.15", "phpunit/phpunit": "~9.5", - "squizlabs/php_codesniffer": "^3.7.1" + "squizlabs/php_codesniffer": "^3.7.1", + "symfony/cache": "^6.4 || ^7.0" }, "config": { "sort-packages": true, diff --git a/docs/cli/generate-classmap.md b/docs/cli/generate-classmap.md index 81b3c382..111ab78b 100644 --- a/docs/cli/generate-classmap.md +++ b/docs/cli/generate-classmap.md @@ -44,8 +44,8 @@ Example output: namespace Myapp\Example\Classmap; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMapCollection; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMap; +use Soap\Encoding\ClassMap\ClassMapCollection; +use Soap\Encoding\ClassMap\ClassMap; class OrderClassMap { @@ -53,9 +53,9 @@ class OrderClassMap public static function getCollection() : ClassMapCollection { return new ClassMapCollection( - new ClassMap('CreateOrder', Type\Example1::class), - new ClassMap('CardOrder', Type\Example2::class), - new ClassMap('OrderDetails', Type\Example3::class) + new ClassMap('http://namespace', 'CreateOrder', Type\Example1::class), + new ClassMap('http://namespace', 'CardOrder', Type\Example2::class), + new ClassMap('http://namespace', 'OrderDetails', Type\Example3::class) ); } } diff --git a/docs/cli/generate-clientfactory.md b/docs/cli/generate-clientfactory.md index e25f5dfc..db56179e 100644 --- a/docs/cli/generate-clientfactory.md +++ b/docs/cli/generate-clientfactory.md @@ -1,6 +1,8 @@ # Generate a base client factory To make things a little easier to get started a client factory generator method is available. +The generated factory can be seen as a good starting point to initialize the client. +It can be customized to your needs. ```bash vendor/bin/soap-client generate:clientfactory @@ -33,31 +35,50 @@ More advanced client factory: use Http\Client\Common\PluginClient; use Http\Discovery\Psr18ClientDiscovery; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; +use Phpro\SoapClient\Caller\EngineCaller; +use Phpro\SoapClient\Caller\EventDispatchingCaller; +use Phpro\SoapClient\Soap\EngineOptions; +use Phpro\SoapClient\Soap\ExtSoap\DefaultEngineFactory; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; use Phpro\SoapClient\Soap\Metadata\MetadataOptions; +use Soap\CachedEngine\CacheConfig; +use Soap\Encoding\EncoderRegistry; +use Soap\ExtSoapEngine\ExtSoapOptions; use Soap\Psr18Transport\Psr18Transport; +use Soap\Psr18Transport\Wsdl\Psr18Loader; +use Soap\Wsdl\Loader\FlatteningLoader; +use Soap\WsdlReader\Model\Definitions\SoapVersion; +use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\EventDispatcher\EventDispatcher; -use Phpro\SoapClient\Soap\ExtSoap\DefaultEngineFactory; -use Soap\ExtSoapEngine\ExtSoapOptions; -use Phpro\SoapClient\Caller\EventDispatchingCaller; -use Phpro\SoapClient\Caller\EngineCaller; class CalculatorClientFactory { public static function factory(string $wsdl) : CalculatorClient { $engine = DefaultEngineFactory::create( - ExtSoapOptions::defaults($wsdl, []) - ->withClassMap(CalculatorClassmap::getCollection()), - Psr18Transport::createForClient( - new PluginClient( - Psr18ClientDiscovery::find(), - [$plugin1, $plugin2] + EngineOptions::defaults($wsdl) + ->withEncoderRegistry( + EncoderRegistry::default() + ->addClassMapCollection(CalculatorClassmap::getCollection()) + ) + ->withTransport( + Psr18Transport::createForClient( + new PluginClient( + Psr18ClientDiscovery::find(), + [$plugin1, $plugin2] + ) + ) + ) + ->withWsdlLoader( + new FlatteningLoader( + new Psr18Loader(Psr18ClientDiscovery::find()) + ) + ) + ->withCache( + new RedisAdapter(RedisAdapter::createConnection('redis://localhost')), + new CacheConfig('my-wsdl-cache-key', ttlInSeconds: 3600) ) - ), - MetadataOptions::empty()->withTypesManipulator( - new IntersectDuplicateTypesStrategy() - ) + ->withPreferredSoapVersion(SoapVersion::SOAP_12) ); $eventDispatcher = new EventDispatcher(); diff --git a/docs/cli/generate-types.md b/docs/cli/generate-types.md index 205f1626..39f873b4 100644 --- a/docs/cli/generate-types.md +++ b/docs/cli/generate-types.md @@ -10,7 +10,6 @@ Usage: Options: --config=CONFIG The location of the soap code-generator config file - ``` This generator will read all XSD types from the provided WSDL and convert it to PHP classes. @@ -27,7 +26,6 @@ Keep in mind that the WSDL must provide all XSD types for the generation of valu Options: - **config**: A [configuration file](../code-generation/configuration.md) is required to build the types. -- **overwrite**: The soap-client overrides a file that cannot be patched without asking for confirmation. When the value objects are generated, you will still need to customize them. diff --git a/docs/code-generation/configuration.md b/docs/code-generation/configuration.md index a40590a6..c495a3ad 100644 --- a/docs/code-generation/configuration.md +++ b/docs/code-generation/configuration.md @@ -9,15 +9,17 @@ The code generation commands require a configuration file to determine how the S use Phpro\SoapClient\CodeGenerator\Config\Config; use Phpro\SoapClient\CodeGenerator\Rules; use Phpro\SoapClient\CodeGenerator\Assembler; -use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory; -use Soap\ExtSoapEngine\ExtSoapOptions; +use Phpro\SoapClient\Soap\DefaultEngineFactory; +use Phpro\SoapClient\Soap\EngineOptions; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\MetadataOptions; use Soap\Wsdl\Loader\FlatteningLoader; use Soap\Wsdl\Loader\StreamWrapperLoader; return Config::create() - ->setEngine(CodeGeneratorEngineFactory::create( - 'wsdl.xml', - new FlatteningLoader(new StreamWrapperLoader()) + ->setEngine(DefaultEngineFactory::create( + EngineOptions::defaults('wsdl.xml') + ->withWsdlLoader(new FlatteningLoader(new StreamWrapperLoader())) )) ->setTypeDestination('src/SoapTypes') ->setTypeNamespace('SoapTypes') @@ -27,6 +29,10 @@ return Config::create() ->setClassMapNamespace('Acme\\Classmap') ->setClassMapDestination('src/acme/classmap') ->setClassMapName('AcmeClassmap') + ->setTypeMetadataOptions( + MetadataOptions::empty() + ->withTypesManipulator(new IntersectDuplicateTypesStrategy()) + ) ->addRule(new Rules\AssembleRule(new Assembler\GetterAssembler( (new Assembler\GetterAssemblerOptions()) ->withReturnType() @@ -52,7 +58,7 @@ Execute `vendor/bin/soap-client generate:config` to start the interactive config Specify how the code generation tool can talk to SOAP. By default, we push a custom engine that deeply parses the WSDL for code generation purpose. -For loading the WSDL, a PSR-18 based WSDL loader is being used in 'flattening' mode. +For loading the WSDL, a stream based WSDL loader is being used in 'flattening' mode. It is possible to change this to any other configuration you want to use and provide additional options like the preferred SOAP version. diff --git a/docs/drivers/metadata.md b/docs/drivers/metadata.md index 0c5ac1d2..5277829c 100644 --- a/docs/drivers/metadata.md +++ b/docs/drivers/metadata.md @@ -1,19 +1,33 @@ # Driver metadata -## Dealing with ext-soap issues - ### Duplicate types -Ext-soap does not add any namespace or unique identifier to the types it knows. -You can read more about this in the [known ext-soap issues](../known-issues/ext-soap.md#duplicate-typenames) section. -Therefore, we added some strategies to deal with duplicate types: +XSDs can have both internal and external types making that the names of the type can be non-unique in a given XML namespace. +It might not be possible to generate unique types for all types in the WSDL. +Therefore, we added some strategies to deal with duplicate types. + +This can be configured in the [client configuration](/docs/code-generation/configuration.md): **IntersectDuplicateTypesStrategy** -Enabled by default when using `DefaultEngineFactory::create()`. +Enabled by default when using `Config::create()`. This duplicate types strategy will merge all duplicate types into one big type which contains all properties. + +```php +use Phpro\SoapClient\CodeGenerator\Config\Config; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\MetadataOptions; + +return Config::create() + //... + ->setTypeMetadataOptions( + MetadataOptions::empty()->withTypesManipulator(new IntersectDuplicateTypesStrategy()) + ) + // ... +``` + **RemoveDuplicateTypesStrategy** This duplicate types strategy will remove all duplicate types it finds. @@ -21,16 +35,14 @@ This duplicate types strategy will remove all duplicate types it finds. You can overwrite the strategy on the `DefaultEngineFactory` object inside the client factory: ```php -withTypesManipulator( - new RemoveDuplicateTypesStrategy() +return Config::create() + //... + ->setTypeMetadataOptions( + MetadataOptions::empty()->withTypesManipulator(new RemoveDuplicateTypesStrategy()) ) -); + // ... ``` diff --git a/docs/known-issues/ext-soap.md b/docs/known-issues/ext-soap.md deleted file mode 100644 index ea099f1c..00000000 --- a/docs/known-issues/ext-soap.md +++ /dev/null @@ -1,116 +0,0 @@ -# Known issues in ext-soap - -- [Duplicate typenames](#duplicate-typenames) -- [Enumerations](#enumerations) - -Isn't your issue listed below? Feel free to provide additional issues in a functional test. - - -**[Find out how you can help out here 💚](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md)** - - -## Duplicate typenames - -When there are 2 types with the same name in different XML namespaces, -ext-soap is not able to link those types to 2 different PHP objects. -This package will generate the code for the last detected type in the WSDL. - -Suggested workaround: - -1. Use one of [the built-in duplicate types strategies](../drivers/metadata.md#duplicate-types) -2. Manually determine type converters for the various classes: - - Manually create the missing classes. - - Determine which is the most important type and use that one in the classmap. - - You can use the type converters for the other type(s) with the same name. - - You'll need to manually parse the XML and link it to an object. - -```php -$soapOptions = [ - 'classmap' => [ - 'Store' => MostImportantStore::class, - ], - 'typemap' => [ - [ - 'type_name' => 'Store', - 'type_ns' => 'http://......lessimportantstore', - 'from_xml' => function($xml) { - $data = simplexml_load_string($xml); - - return LessImportantStore::fromXml($data); - }, - ], - ], -]; -``` - -Alternative workaround: - -- Merge all properties of all types in one big class. -- Map the master class to the xsd type in the classmap -- This might be a bad idea of the objects are not very similar. - -More information: - -- [Code in php-src](https://github.com/php/php-src/blob/php-7.2.10/ext/soap/php_encoding.c#L468) -- [Functional test](../../test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/DuplicateTypenamesTest.php) - - -**[Find out how you can help out here 💚](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md)** - -## Enumerations - -It is possible that the WSDL file contains `xsd:enumeration` elements. -Since PHP does not have an internal `enum` type, -ext-soap will transform the data to the type that is determined in the `xsd:restriction` section. -The soap client will never try to validate the input against the configured enumerations inside the WSDL. - -We've added basic support for enumerations in this package so that issues can be resolved at static analysis level. -However, during runtime, it is not possible to validate these enumerations without creating a custom typemap. - -For example: -```xml - - - - - - - -``` - -- It is perfectly possible to pass a value of "InvalidData" to the server through the soap-client. -- Internally, ext-soap will typehint this enum as a string so there is no complex type available. -- You won't be able to access the available options without manually parsing the WSDL file. -- If you do want to use a custom class for the enumerations type, you can create a type converter like this: - -```php -enum PhoneTypeEnum : string { - case HOME = 'Home'; - case GSM = 'Gsm'; - case OFFICE = 'Office'; -} - -$soapOptions = [ - 'typemap' => [ - [ - 'type_name' => 'PhoneTypeEnum', - 'type_ns' => 'http://soapinterop.org/xsd', - 'from_xml' => function($xml) { - $doc = new \DOMDocument(); - $doc->loadXML($xml); - - return PhoneTypeEnum::from($doc->textContent); - }, - 'to_xml' => function(PhoneTypeEnum $enum) { - return sprintf('%s', $enum->value); - }, - ], - ], -]; -``` - -More information: -- [Functional test](../../test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/EnumTest.php) -- [Lack of validation in php-src](https://github.com/php/php-src/blob/php-7.2.10/ext/soap/php_encoding.c#L3172-L3200) - -**[Find out how you can help out here 💚](https://github.com/php-soap/.github/blob/main/HELPING_OUT.md)** diff --git a/spec/Phpro/SoapClient/CodeGenerator/ClientGeneratorSpec.php b/spec/Phpro/SoapClient/CodeGenerator/ClientGeneratorSpec.php index fc26926f..83865caf 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/ClientGeneratorSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/ClientGeneratorSpec.php @@ -50,7 +50,7 @@ function it_generates_clients(RuleSetInterface $ruleSet, FileGenerator $file, Cl { $method = new ClientMethod( 'Test', - [new Parameter('parameters', 'Test', '', new TypeMeta())], + [new Parameter('parameters', 'Test', '', XsdType::create('Test'))], ReturnType::fromMetaData('', XsdType::create('TestResponse')), '', new MethodMeta() @@ -74,7 +74,7 @@ private function it_generates_clients_for_file_without_classes(RuleSetInterface { $method = new ClientMethod( 'Test', - [new Parameter('parameters', 'Test', '', new TypeMeta())], + [new Parameter('parameters', 'Test', '', XsdType::create('Test'))], ReturnType::fromMetaData('', XsdType::create('TestResponse')), '', new MethodMeta() diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/ParameterSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/ParameterSpec.php index 92cf233d..99b02323 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/ParameterSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/ParameterSpec.php @@ -5,6 +5,7 @@ use Phpro\SoapClient\CodeGenerator\Model\Parameter; use PhpSpec\ObjectBehavior; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class ParameterSpec @@ -16,7 +17,7 @@ class ParameterSpec extends ObjectBehavior { function let() { - $this->beConstructedWith('MyParameter', 'MyParameterType', 'MyNamespace', new TypeMeta()); + $this->beConstructedWith('MyParameter', 'MyParameterType', 'MyNamespace', XsdType::create('MyParameter')); } function it_is_initializable() diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/PropertySpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/PropertySpec.php index dc79fdbe..236fecf8 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/PropertySpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/PropertySpec.php @@ -6,6 +6,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class PropertySpec @@ -17,7 +18,7 @@ class PropertySpec extends ObjectBehavior { function let() { - $this->beConstructedWith('name', 'Type', 'My\Namespace', new TypeMeta()); + $this->beConstructedWith('name', 'Type', 'My\Namespace', XsdType::create('Type')); } function it_is_initializable() diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/ReturnTypeSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/ReturnTypeSpec.php index 013010c5..fa026b29 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/ReturnTypeSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/ReturnTypeSpec.php @@ -6,6 +6,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class ReturnTypeSpec @@ -17,7 +18,7 @@ class ReturnTypeSpec extends ObjectBehavior { function let() { - $this->beConstructedWith('Type', 'My\Namespace', new TypeMeta()); + $this->beConstructedWith('Type', 'My\Namespace', XsdType::create('Type')); } function it_is_initializable() diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php index 2fdbf83b..eb590423 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php @@ -8,6 +8,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TypeMapSpec @@ -21,8 +22,8 @@ function let() { $this->beConstructedWith($namespace = 'MyNamespace', [ new Type($namespace, 'type1', [ - new Property('prop1', 'string', $namespace, new TypeMeta()) - ], new TypeMeta()) + new Property('prop1', 'string', $namespace, XsdType::create('string')) + ], XsdType::create('MyType')) ]); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php index 20630652..fd8c61f0 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php @@ -7,6 +7,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TypeSpec @@ -21,8 +22,8 @@ function let() $this->beConstructedWith( $namespace = 'MyNamespace', 'myType', - [new Property('prop1', 'string', $namespace, new TypeMeta())], - new TypeMeta() + [new Property('prop1', 'string', $namespace, XsdType::create('string'))], + XsdType::create('MyType') ); } @@ -57,7 +58,7 @@ function it_has_meta() function it_should_not_replace_underscores_in_paths() { - $this->beConstructedWith('MyNamespace', 'my_type_3_2', ['prop1' => 'string'], new TypeMeta()); + $this->beConstructedWith('MyNamespace', 'my_type_3_2', ['prop1' => 'string'], XsdType::create('MyType')); $this->getFileInfo('my/some_dir')->getPathname()->shouldReturn('my/some_dir/MyType32.php'); } @@ -66,8 +67,8 @@ function it_should_prefix_reserved_keywords() $this->beConstructedWith( $namespace = 'MyNamespace', 'Final', - [new Property('xor', 'string', $namespace, new TypeMeta())], - new TypeMeta() + [new Property('xor', 'string', $namespace, XsdType::create('string'))], + XsdType::create('MyType') ); $this->getFileInfo('my/some_dir')->getPathname()->shouldReturn('my/some_dir/FinalType.php'); diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php index 6f1cd751..83f17429 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php @@ -58,28 +58,28 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context(RuleInterface $subRule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_type(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'NotAbstract', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'NotAbstract', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsExtendingTypeRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsExtendingTypeRuleSpec.php index 4c0de21a..adf6ef20 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsExtendingTypeRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsExtendingTypeRuleSpec.php @@ -61,28 +61,28 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context(RuleInterface $subRule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_type(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'NotExtending', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'NotExtending', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsRequestRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsRequestRuleSpec.php index 3565c865..c9872f9d 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsRequestRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsRequestRuleSpec.php @@ -56,28 +56,28 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context(RuleInterface $subRule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_type(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsResultRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsResultRuleSpec.php index 6b738eac..1115c67c 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsResultRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsResultRuleSpec.php @@ -56,28 +56,28 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context(RuleInterface $subRule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_type(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRuleSpec.php index 78ac5499..1516ac51 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRuleSpec.php @@ -12,6 +12,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class PropertynameMatchesRuleSpec @@ -44,21 +45,21 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_property_context( RuleInterface $subRule, PropertyContext $context) { - $context->getProperty()->willReturn(new Property('myProperty', 'string', 'ns1', new TypeMeta())); + $context->getProperty()->willReturn(new Property('myProperty', 'string', 'ns1', XsdType::create('string'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_regex(RuleInterface $subRule, PropertyContext $context) { - $context->getProperty()->willReturn(new Property('InvalidTypeName', 'string', 'ns1', new TypeMeta())); + $context->getProperty()->willReturn(new Property('InvalidTypeName', 'string', 'ns1', XsdType::create('string'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, PropertyContext $context) { - $context->getProperty()->willReturn(new Property('MyProperty', 'string', 'ns1', new TypeMeta())); + $context->getProperty()->willReturn(new Property('MyProperty', 'string', 'ns1', XsdType::create('string'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php index b6de27a3..095edf14 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php @@ -12,6 +12,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TypeMapRuleSpec @@ -47,48 +48,48 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $rule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], XsdType::create('MyType'))); $rule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context(RuleInterface $rule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], XsdType::create('MyType'))); $rule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_the_default_assembler_to_unknown_types(RuleInterface $defaultRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', [], XsdType::create('MyType'))); $defaultRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_to_knwon_types_with_no_rule(TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'NullType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'NullType', [], XsdType::create('MyType'))); $this->appliesToContext($context)->shouldReturn(false); } function it_can_not_apply_if_rule_does_not_apply(RuleInterface $rule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], XsdType::create('MyType'))); $rule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } function it_applies_a_specified_rule_to_known_types(RuleInterface $rule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', [], XsdType::create('MyType'))); $rule->apply($context)->shouldBeCalled(); $this->apply($context); } function it_applies_the_default_rule_to_unknown_types(RuleInterface $defaultRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', [], XsdType::create('MyType'))); $defaultRule->apply($context)->shouldBeCalled(); $this->apply($context); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php index 0318d603..ff67c859 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php @@ -11,6 +11,7 @@ use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TypenameMatchesRuleSpec @@ -43,28 +44,28 @@ function it_can_not_apply_to_regular_context(ContextInterface $context) function it_can_apply_to_type_context(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_apply_to_property_context( RuleInterface $subRule, PropertyContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(true); } function it_can_not_apply_on_invalid_regex(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(true); $this->appliesToContext($context)->shouldReturn(false); } function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context) { - $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], new TypeMeta())); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', [], XsdType::create('MyType'))); $subRule->appliesToContext($context)->willReturn(false); $this->appliesToContext($context)->shouldReturn(false); } diff --git a/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php b/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php index 03d587ed..e9a74e33 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php @@ -17,6 +17,7 @@ use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\FileGenerator; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TypeGeneratorSpec @@ -47,8 +48,8 @@ function it_generates_types(RuleSetInterface $ruleSet, FileGenerator $file, Clas $type = new Type( $namespace = 'MyNamespace', 'MyType', - [new Property('prop1', 'string', $namespace, new TypeMeta())], - new TypeMeta() + [new Property('prop1', 'string', $namespace, XsdType::create('string'))], + XsdType::create('MyType') ); $property = $type->getProperties()[0]; @@ -71,8 +72,8 @@ function it_generates_types_for_file_without_classes(RuleSetInterface $ruleSet, $type = new Type( $namespace = 'MyNamespace', 'MyType', - [new Property('prop1', 'string', $namespace, new TypeMeta())], - new TypeMeta() + [new Property('prop1', 'string', $namespace, XsdType::create('string'))], + XsdType::create('MyType') ); $property = $type->getProperties()[0]; diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php index 2d843055..4e5d2690 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php @@ -8,8 +8,8 @@ use Phpro\SoapClient\Exception\AssemblerException; use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\MethodGenerator; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMap; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMapCollection; +use Soap\Encoding\ClassMap\ClassMap; +use Soap\Encoding\ClassMap\ClassMapCollection; use Soap\WsdlReader\Metadata\Predicate\IsConsideredScalarType; /** @@ -85,9 +85,10 @@ private function assembleClassMap(TypeMap $typeMap, string $linefeed, string $in } $classMap[] = sprintf( - '%snew ClassMap(\'%s\', %s::class),', + '%snew ClassMap(\'%s\', \'%s\', %s::class),', $indentation, - $type->getXsdName(), + $type->getXsdType()->getXmlNamespace(), + $type->getXsdType()->getXmlTypeName(), 'Type\\'.$type->getName() ); } diff --git a/src/Phpro/SoapClient/CodeGenerator/ClientFactoryGenerator.php b/src/Phpro/SoapClient/CodeGenerator/ClientFactoryGenerator.php index 9af05a52..fa099b4d 100644 --- a/src/Phpro/SoapClient/CodeGenerator/ClientFactoryGenerator.php +++ b/src/Phpro/SoapClient/CodeGenerator/ClientFactoryGenerator.php @@ -6,7 +6,8 @@ use Phpro\SoapClient\Caller\EventDispatchingCaller; use Phpro\SoapClient\CodeGenerator\Context\ClientFactoryContext; use Phpro\SoapClient\Soap\DefaultEngineFactory; -use Soap\ExtSoapEngine\ExtSoapOptions; +use Phpro\SoapClient\Soap\EngineOptions; +use Soap\Encoding\EncoderRegistry; use Symfony\Component\EventDispatcher\EventDispatcher; use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\FileGenerator; @@ -21,8 +22,20 @@ class ClientFactoryGenerator implements GeneratorInterface { const BODY = <<withClassMap(%2\$s::getCollection()) + EngineOptions::defaults(\$wsdl) + ->withEncoderRegistry( + EncoderRegistry::default()->addClassMapCollection( + %2\$s::getCollection() + ) + ) + // If you want to enable WSDL caching: + // ->withCache() + // If you want to use Alternate HTTP settings: + // ->withWsdlLoader() + // ->withTransport() + // If you want specific SOAP setting: + // ->withWsdlParserContext() + // ->withPreferredSoapVersion() ); \$eventDispatcher = new EventDispatcher(); @@ -46,9 +59,10 @@ public function generate(FileGenerator $file, $context): string $class->addUse($context->getClassmapFqcn()); $class->addUse(EventDispatcher::class); $class->addUse(DefaultEngineFactory::class); - $class->addUse(ExtSoapOptions::class); + $class->addUse(EngineOptions::class); $class->addUse(EventDispatchingCaller::class); $class->addUse(EngineCaller::class); + $class->addUse(EncoderRegistry::class); $class->addMethodFromGenerator( MethodGenerator::fromArray( [ @@ -62,6 +76,10 @@ public function generate(FileGenerator $file, $context): string 'type' => 'string', ], ], + 'docblock' => [ + 'shortdescription' => 'This factory can be used as a starting point '. + 'to create your own specialized factory. Feel free to modify.', + ], ] ) ); diff --git a/src/Phpro/SoapClient/CodeGenerator/Config/Config.php b/src/Phpro/SoapClient/CodeGenerator/Config/Config.php index b8a6a70f..75e181e8 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Config/Config.php +++ b/src/Phpro/SoapClient/CodeGenerator/Config/Config.php @@ -9,6 +9,8 @@ use Phpro\SoapClient\CodeGenerator\Rules\RuleSetInterface; use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use Phpro\SoapClient\Exception\InvalidArgumentException; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\MetadataOptions; use Soap\Engine\Engine; /** @@ -48,6 +50,8 @@ final class Config implements ConfigInterface */ protected $typeDestination = ''; + protected MetadataOptions $typeMetadataOptions; + /** * @var RuleSetInterface */ @@ -70,6 +74,12 @@ final class Config implements ConfigInterface public function __construct() { + $this->typeMetadataOptions = MetadataOptions::empty()->withTypesManipulator( + // Working with duplicate types is hard (see FAQ). + // Therefore, we decided to combine all duplicate types into 1 big intersected type by default instead. + // The resulting type will always be usable, but might contain some additional empty properties. + new IntersectDuplicateTypesStrategy() + ); $this->ruleSet = new RuleSet([ new Rules\AssembleRule(new Assembler\PropertyAssembler()), new Rules\AssembleRule(new Assembler\ClassMapAssembler()), @@ -249,6 +259,19 @@ public function setTypeDestination($typeDestination): self return $this; } + public function getTypeMetadataOptions(): MetadataOptions + { + return $this->typeMetadataOptions; + } + + public function setTypeMetadataOptions(MetadataOptions $typeMetadataOptions): self + { + $this->typeMetadataOptions = $typeMetadataOptions; + + return $this; + } + + /** * @return string */ diff --git a/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php b/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php index 701e7628..a1b6599a 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php +++ b/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php @@ -3,6 +3,7 @@ namespace Phpro\SoapClient\CodeGenerator\Config; use Phpro\SoapClient\CodeGenerator\Rules\RuleSetInterface; +use Phpro\SoapClient\Soap\Metadata\MetadataOptions; use Soap\Engine\Engine; /** @@ -28,6 +29,9 @@ public function getClientDestination(); */ public function getTypeDestination(); + public function getTypeMetadataOptions(): MetadataOptions; + + /** * @return RuleSetInterface */ diff --git a/src/Phpro/SoapClient/CodeGenerator/ConfigGenerator.php b/src/Phpro/SoapClient/CodeGenerator/ConfigGenerator.php index 89c020b7..26113b5c 100644 --- a/src/Phpro/SoapClient/CodeGenerator/ConfigGenerator.php +++ b/src/Phpro/SoapClient/CodeGenerator/ConfigGenerator.php @@ -5,8 +5,8 @@ use Phpro\SoapClient\CodeGenerator\Config\Config; use Phpro\SoapClient\CodeGenerator\Context\ConfigContext; use Laminas\Code\Generator\FileGenerator; -use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory; -use Soap\ExtSoapEngine\ExtSoapOptions; +use Phpro\SoapClient\Soap\DefaultEngineFactory; +use Phpro\SoapClient\Soap\EngineOptions; /** * Class ConfigGenerator @@ -32,8 +32,8 @@ class ConfigGenerator implements GeneratorInterface RULESET; const ENGINE_BOILERPLATE = <<setEngine(\$engine = CodeGeneratorEngineFactory::create( - '%s' +->setEngine(\$engine = DefaultEngineFactory::create( + EngineOptions::defaults('%s') )) EOENGINE; @@ -75,8 +75,8 @@ public function generate(FileGenerator $file, $context): string $file->setUse('Phpro\\SoapClient\\CodeGenerator\\Assembler'); $file->setUse('Phpro\\SoapClient\\CodeGenerator\\Rules'); $file->setUse(Config::class); - $file->setUse(ExtSoapOptions::class); - $file->setUse(CodeGeneratorEngineFactory::class); + $file->setUse(EngineOptions::class); + $file->setUse(DefaultEngineFactory::class); $body .= $this->parseEngine($file, $context->getWsdl()); foreach ($context->getSetters() as $name => $value) { diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php b/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php index 6a4afc31..94424e3a 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php @@ -6,6 +6,7 @@ use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use Soap\Engine\Metadata\Model\Parameter as MetadataParameter; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; use function Psl\Type\non_empty_string; class Parameter @@ -25,6 +26,8 @@ class Parameter */ private string $namespace; + private XsdType $xsdType; + private TypeMeta $meta; /** @@ -34,12 +37,13 @@ class Parameter * @param non-empty-string $type * @param non-empty-string $namespace */ - public function __construct(string $name, string $type, string $namespace, TypeMeta $meta) + public function __construct(string $name, string $type, string $namespace, XsdType $xsdType) { $this->name = Normalizer::normalizeProperty($name); $this->type = Normalizer::normalizeDataType($type); $this->namespace = Normalizer::normalizeNamespace($namespace); - $this->meta = $meta; + $this->xsdType = $xsdType; + $this->meta = $xsdType->getMeta(); } /** @@ -48,14 +52,13 @@ public function __construct(string $name, string $type, string $namespace, TypeM public static function fromMetadata(string $parameterNamespace, MetadataParameter $parameter): Parameter { $type = $parameter->getType(); - $meta = $type->getMeta(); $typeName = (new TypeNameCalculator())($type); return new self( non_empty_string()->assert($parameter->getName()), non_empty_string()->assert($typeName), $parameterNamespace, - $meta + $type ); } @@ -92,6 +95,16 @@ public function toArray(): array ]; } + public function getNamespace(): string + { + return $this->namespace; + } + + public function getXsdType(): XsdType + { + return $this->xsdType; + } + public function getMeta(): TypeMeta { return $this->meta; diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php index 367faa9b..4a789426 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php @@ -9,6 +9,7 @@ use Soap\Engine\Metadata\Metadata; use Soap\Engine\Metadata\Model\Property as MetadataProperty; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; use function Psl\Type\non_empty_string; /** @@ -33,6 +34,8 @@ class Property */ private $namespace; + private XsdType $xsdType; + private TypeMeta $meta; private TypeEnhancer $typeEnhancer; @@ -44,12 +47,13 @@ class Property * @param non-empty-string $type * @param non-empty-string $namespace */ - public function __construct(string $name, string $type, string $namespace, TypeMeta $meta) + public function __construct(string $name, string $type, string $namespace, XsdType $xsdType) { $this->name = Normalizer::normalizeProperty($name); $this->type = Normalizer::normalizeDataType($type); $this->namespace = Normalizer::normalizeNamespace($namespace); - $this->meta = $meta; + $this->xsdType = $xsdType; + $this->meta = $xsdType->getMeta(); $this->typeEnhancer = new MetaTypeEnhancer($this->meta); } @@ -66,7 +70,7 @@ public static function fromMetaData(string $namespace, MetadataProperty $propert non_empty_string()->assert($property->getName()), non_empty_string()->assert($typeName), $namespace, - $meta + $type ); } @@ -122,6 +126,11 @@ public function setterName(): string return Normalizer::generatePropertyMethod('set', $this->getName()); } + public function getXsdType(): XsdType + { + return $this->xsdType; + } + public function getMeta(): TypeMeta { return $this->meta; diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php b/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php index 86d43b9d..619504c8 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php @@ -22,6 +22,8 @@ final class ReturnType */ private string $namespace; + private XsdType $xsdType; + private TypeMeta $meta; /** @@ -30,11 +32,12 @@ final class ReturnType * @param non-empty-string $type * @param non-empty-string $namespace */ - public function __construct(string $type, string $namespace, TypeMeta $meta) + public function __construct(string $type, string $namespace, XsdType $xsdType) { $this->type = Normalizer::normalizeDataType($type); $this->namespace = Normalizer::normalizeNamespace($namespace); - $this->meta = $meta; + $this->xsdType = $xsdType; + $this->meta = $xsdType->getMeta(); } /** @@ -47,7 +50,7 @@ public static function fromMetaData(string $namespace, XsdType $returnType): sel return new self( non_empty_string()->assert($typeName), $namespace, - $returnType->getMeta() + $returnType ); } /** @@ -62,6 +65,11 @@ public function getType(): string return '\\'.$this->namespace.'\\'.Normalizer::normalizeClassname($this->type); } + public function getXsdType(): XsdType + { + return $this->xsdType; + } + public function getMeta(): TypeMeta { return $this->meta; diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php index b93bd629..ad35facc 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php @@ -6,6 +6,7 @@ use Soap\Engine\Metadata\Model\Property as MetadataProperty; use Soap\Engine\Metadata\Model\Type as MetadataType; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; use SplFileInfo; use function Psl\Type\non_empty_string; @@ -36,6 +37,8 @@ class Type */ private $properties = []; + private XsdType $xsdType; + private TypeMeta $meta; /** @@ -45,13 +48,14 @@ class Type * @param non-empty-string $xsdName * @param Property[] $properties */ - public function __construct(string $namespace, string $xsdName, array $properties, TypeMeta $meta) + public function __construct(string $namespace, string $xsdName, array $properties, XsdType $xsdType) { $this->namespace = Normalizer::normalizeNamespace($namespace); $this->xsdName = $xsdName; $this->name = Normalizer::normalizeClassname($xsdName); $this->properties = $properties; - $this->meta = $meta; + $this->xsdType = $xsdType; + $this->meta = $xsdType->getMeta(); } /** @@ -71,7 +75,7 @@ function (MetadataProperty $property) use ($namespace) { }, iterator_to_array($type->getProperties()) ), - $type->getXsdType()->getMeta(), + $type->getXsdType(), ); } @@ -130,6 +134,11 @@ public function getProperties(): array return $this->properties; } + public function getXsdType(): XsdType + { + return $this->xsdType; + } + public function getMeta(): TypeMeta { return $this->meta; diff --git a/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php index e6b00426..5a69055f 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php @@ -6,6 +6,7 @@ use Phpro\SoapClient\CodeGenerator\Model\TypeMap; use Phpro\SoapClient\CodeGenerator\TypeGenerator; use Phpro\SoapClient\Console\Helper\ConfigHelper; +use Phpro\SoapClient\Soap\Metadata\MetadataFactory; use Phpro\SoapClient\Util\Filesystem; use Soap\WsdlReader\Metadata\Predicate\IsConsideredScalarType; use SplFileInfo; @@ -74,7 +75,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $config = $this->getConfigHelper()->load($input); $typeMap = TypeMap::fromMetadata( non_empty_string()->assert($config->getTypeNamespace()), - $config->getEngine()->getMetadata()->getTypes() + MetadataFactory::manipulated( + $config->getEngine()->getMetadata(), + $config->getTypeMetadataOptions() + )->getTypes() ); $generator = new TypeGenerator($config->getRuleSet()); diff --git a/src/Phpro/SoapClient/Exception/InvalidArgumentException.php b/src/Phpro/SoapClient/Exception/InvalidArgumentException.php index 8ee4e971..a3e63a79 100644 --- a/src/Phpro/SoapClient/Exception/InvalidArgumentException.php +++ b/src/Phpro/SoapClient/Exception/InvalidArgumentException.php @@ -16,73 +16,47 @@ public static function engineNotConfigured(): self return new static('You did not configure a soap engine'); } - /** - * @return InvalidArgumentException - */ public static function destinationConfigurationIsMissing(): self { return new static('You did not configure a destination.'); } - /** - * @return InvalidArgumentException - */ public static function invalidConfigFile(): self { return new static('You have to provide a code-generator config file which returns a ConfigInterface.'); } - /** - * @return InvalidArgumentException - */ - public static function clientNamespaceIsMissing() + public static function clientNamespaceIsMissing(): self { return new static('You did not configure a client namespace.'); } - /** - * @return InvalidArgumentException - */ - public static function typeNamespaceIsMissing() + public static function typeNamespaceIsMissing(): self { return new static('You did not configure a type namespace.'); } - /** - * @return InvalidArgumentException - */ - public static function clientDestinationIsMissing() + public static function clientDestinationIsMissing(): self { return new static('You did not configure a client destination.'); } - /** - * @return InvalidArgumentException - */ - public static function typeDestinationIsMissing() + public static function typeDestinationIsMissing(): self { return new static('You did not configure a type destination.'); } - /** - * @return InvalidArgumentException - */ - public static function classmapNameMissing() + public static function classmapNameMissing(): self { return new static('You did not configure a classmap name.'); } - /** - * @return InvalidArgumentException - */ - public static function classmapNamespaceMissing() + public static function classmapNamespaceMissing(): self { return new static('You did not configure a classmap namespace.'); } - /** - * @return InvalidArgumentException - */ - public static function classmapDestinationMissing() + + public static function classmapDestinationMissing(): self { return new static('You did not configure a classmap destination.'); } diff --git a/src/Phpro/SoapClient/Soap/CodeGeneratorEngineFactory.php b/src/Phpro/SoapClient/Soap/CodeGeneratorEngineFactory.php deleted file mode 100644 index 00a06215..00000000 --- a/src/Phpro/SoapClient/Soap/CodeGeneratorEngineFactory.php +++ /dev/null @@ -1,67 +0,0 @@ -withTypesManipulator( - // Ext-soap is not able to work with duplicate types (see FAQ) - // Therefore, we decided to combine all duplicate types into 1 big intersected type by default instead. - // Therefore it will always be usable, but might contain some empty properties. - // It has it's limitations but it is workable until ext-soap handles XSD namespaces properly. - new IntersectDuplicateTypesStrategy() - ); - - return new LazyEngine(static function () use ( - $wsdlLocation, - $loader, - $metadataOptions, - $parserContext, - $preferredSoapVersion - ) { - $wsdl = (new Wsdl1Reader($loader))($wsdlLocation, $parserContext); - $metadataProvider = new Wsdl1MetadataProvider( - $wsdl, - ServiceSelectionCriteria::defaults() - ->withAllowHttpPorts(false) - ->withPreferredSoapVersion($preferredSoapVersion) - ); - - return new SimpleEngine( - new PartialDriver( - metadata: MetadataFactory::manipulated($metadataProvider->getMetadata(), $metadataOptions), - ), - new NoopTransport() - ); - }); - } -} diff --git a/src/Phpro/SoapClient/Soap/DefaultEngineFactory.php b/src/Phpro/SoapClient/Soap/DefaultEngineFactory.php index 191f798c..9f8d3821 100644 --- a/src/Phpro/SoapClient/Soap/DefaultEngineFactory.php +++ b/src/Phpro/SoapClient/Soap/DefaultEngineFactory.php @@ -3,46 +3,44 @@ namespace Phpro\SoapClient\Soap; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; -use Phpro\SoapClient\Soap\Metadata\MetadataFactory; -use Phpro\SoapClient\Soap\Metadata\MetadataOptions; +use Soap\CachedEngine\CachedEngine; +use Soap\Encoding\Driver; use Soap\Engine\Engine; use Soap\Engine\LazyEngine; use Soap\Engine\SimpleEngine; -use Soap\Engine\Transport; -use Soap\ExtSoapEngine\AbusedClient; -use Soap\ExtSoapEngine\ExtSoapDriver; -use Soap\ExtSoapEngine\ExtSoapMetadata; -use Soap\ExtSoapEngine\ExtSoapOptions; -use Soap\Psr18Transport\Psr18Transport; +use Soap\WsdlReader\Wsdl1Reader; final class DefaultEngineFactory { public static function create( - ExtSoapOptions $options, - ?Transport $transport = null, - ?MetadataOptions $metadataOptions = null + EngineOptions $options ): Engine { - $transport ??= Psr18Transport::createWithDefaultClient(); - $metadataOptions ??= MetadataOptions::empty()->withTypesManipulator( - // Ext-soap is not able to work with duplicate types (see FAQ) - // Therefore, we decided to combine all duplicate types into 1 big intersected type by default instead. - // Therefore it will always be usable, but might contain some empty properties. - // It has it's limitations but it is workable until ext-soap handles XSD namespaces properly. - new IntersectDuplicateTypesStrategy() + + $cache = $options->getCache(); + $factory = static fn(): Engine => self::configureEngine($options); + + return match (true) { + $cache->isSome() => new CachedEngine($cache->unwrap(), $options->getCacheConfig(), $factory), + default => new LazyEngine($factory), + }; + } + + private static function configureEngine(EngineOptions $options): Engine + { + $wsdl = (new Wsdl1Reader($options->getWsdlLoader()))( + $options->getWsdl(), + $options->getWsdlParserContext() ); - return new LazyEngine(static function () use ($options, $transport, $metadataOptions) { - $client = AbusedClient::createFromOptions($options); - $driver = ExtSoapDriver::createFromClient( - $client, - MetadataFactory::manipulated( - new ExtSoapMetadata($client), - $metadataOptions - ) - ); - - return new SimpleEngine($driver, $transport); - }); + $driver = Driver::createFromWsdl1( + $wsdl, + $options->getWsdlServiceSelectionCriteria(), + $options->getEncoderRegistry() + ); + + return new SimpleEngine( + $driver, + $options->getTransport() + ); } } diff --git a/src/Phpro/SoapClient/Soap/EngineOptions.php b/src/Phpro/SoapClient/Soap/EngineOptions.php new file mode 100644 index 00000000..44ba9c16 --- /dev/null +++ b/src/Phpro/SoapClient/Soap/EngineOptions.php @@ -0,0 +1,155 @@ +wsdl = $wsdl; + } + + /** + * @param non-empty-string $wsdl + * @return self + */ + public static function defaults(string $wsdl): self + { + return new self($wsdl); + } + + public function withCache(CacheItemPoolInterface $cache, ?CacheConfig $config = null): self + { + $clone = clone $this; + $clone->cache = $cache; + $clone->cacheConfig = $config; + + return $clone; + } + + public function withWsdlLoader(WsdlLoader $loader): self + { + $clone = clone $this; + $clone->wsdlLoader = $loader; + + return $clone; + } + + public function withWsdlParserContext(ParserContext $parserContext): self + { + $clone = clone $this; + $clone->wsdlParserContext = $parserContext; + + return $clone; + } + + public function withTransport(Transport $transport): self + { + $clone = clone $this; + $clone->transport = $transport; + + return $clone; + } + + public function withPreferredSoapVersion(SoapVersion $preferredSoapVersion): self + { + $clone = clone $this; + $clone->preferredSoapVersion = $preferredSoapVersion; + + return $clone; + } + + public function withEncoderRegistry(EncoderRegistry $registry): self + { + $clone = clone $this; + $clone->encoderRegistry = $registry; + + return $clone; + } + + /** + * @return non-empty-string + */ + public function getWsdl(): string + { + return $this->wsdl; + } + + public function getWsdlLoader(): WsdlLoader + { + return $this->wsdlLoader ?? new FlatteningLoader(new StreamWrapperLoader()); + } + + public function getWsdlParserContext(): ParserContext + { + return $this->wsdlParserContext ?? ParserContext::defaults(); + } + + public function getTransport(): Transport + { + return $this->transport ?? Psr18Transport::createWithDefaultClient(); + } + + /** + * @return Option + */ + public function getCache(): Option + { + return from_nullable($this->cache); + } + + public function getCacheConfig(): CacheConfig + { + return $this->cacheConfig ?? new CacheConfig('soap-engine-'.md5($this->wsdl)); + } + + /** + * @return Option + */ + public function getPreferredSoapVersion(): Option + { + return from_nullable($this->preferredSoapVersion); + } + + public function getWsdlServiceSelectionCriteria(): ServiceSelectionCriteria + { + return ServiceSelectionCriteria::defaults() + ->withAllowHttpPorts(false) + ->withPreferredSoapVersion($this->preferredSoapVersion); + } + + public function getEncoderRegistry(): EncoderRegistry + { + return $this->encoderRegistry ?? EncoderRegistry::default(); + } +} diff --git a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetector.php b/src/Phpro/SoapClient/Soap/Metadata/Detector/DuplicateTypeNamesDetector.php similarity index 93% rename from src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetector.php rename to src/Phpro/SoapClient/Soap/Metadata/Detector/DuplicateTypeNamesDetector.php index 911a4b26..47d7f4ce 100644 --- a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetector.php +++ b/src/Phpro/SoapClient/Soap/Metadata/Detector/DuplicateTypeNamesDetector.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Phpro\SoapClient\Soap\ExtSoap\Metadata\Detector; +namespace Phpro\SoapClient\Soap\Metadata\Detector; use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use Soap\Engine\Metadata\Collection\TypeCollection; diff --git a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php b/src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php similarity index 96% rename from src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php rename to src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php index fc51d12a..07e82a7c 100644 --- a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php +++ b/src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategy.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes; +namespace Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes; use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorInterface; diff --git a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php b/src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php similarity index 83% rename from src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php rename to src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php index c1810ff1..c6805a8d 100644 --- a/src/Phpro/SoapClient/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php +++ b/src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategy.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes; +namespace Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes; use Phpro\SoapClient\CodeGenerator\Util\Normalizer; +use Phpro\SoapClient\Soap\Metadata\Detector\DuplicateTypeNamesDetector; use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorInterface; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Detector\DuplicateTypeNamesDetector; use Soap\Engine\Metadata\Collection\TypeCollection; use Soap\Engine\Metadata\Model\Type; use function Psl\Type\non_empty_string; diff --git a/test/PhproTest/SoapClient/Functional/Client/ClientTest.php b/test/PhproTest/SoapClient/Functional/Client/ClientTest.php index 9f274f0c..81203dc5 100644 --- a/test/PhproTest/SoapClient/Functional/Client/ClientTest.php +++ b/test/PhproTest/SoapClient/Functional/Client/ClientTest.php @@ -12,10 +12,10 @@ use Phpro\SoapClient\Caller\Caller; use Phpro\SoapClient\Caller\EngineCaller; use Phpro\SoapClient\Soap\DefaultEngineFactory; +use Phpro\SoapClient\Soap\EngineOptions; use Phpro\SoapClient\Type\MixedResult; use Phpro\SoapClient\Type\MultiArgumentRequest; use PHPUnit\Framework\TestCase; -use Soap\ExtSoapEngine\ExtSoapOptions; use Soap\Psr18Transport\Psr18Transport; class ClientTest extends TestCase @@ -28,14 +28,16 @@ protected function setUp(): void $namingStrategy = new PathNamingStrategy(); $caller = new EngineCaller( DefaultEngineFactory::create( - ExtSoapOptions::defaults(FIXTURE_DIR.'/wsdl/functional/calculator.wsdl'), - Psr18Transport::createForClient( - new PluginClient( - Psr18ClientDiscovery::find(), - [ - new RecordPlugin($namingStrategy, $recorder), - new ReplayPlugin($namingStrategy, $recorder, false), - ] + EngineOptions::defaults(FIXTURE_DIR.'/wsdl/functional/calculator.wsdl') + ->withTransport( + Psr18Transport::createForClient( + new PluginClient( + Psr18ClientDiscovery::find(), + [ + new RecordPlugin($namingStrategy, $recorder), + new ReplayPlugin($namingStrategy, $recorder, false), + ] + ) ) ) ) diff --git a/test/PhproTest/SoapClient/Functional/ExtSoap/AbstractSoapTestCase.php b/test/PhproTest/SoapClient/Functional/ExtSoap/AbstractSoapTestCase.php deleted file mode 100644 index 4c4c2f82..00000000 --- a/test/PhproTest/SoapClient/Functional/ExtSoap/AbstractSoapTestCase.php +++ /dev/null @@ -1,41 +0,0 @@ -disableWsdlCache() - ); - - $this->client = $driver->getClient(); - - return $driver; - } - - protected function configureServer(string $wsdl, array $options, $object): TraceableTransport - { - $options = ExtSoapOptions::defaults($wsdl, $options)->disableWsdlCache(); - - $server = new \SoapServer($options->getWsdl(), $options->getOptions()); - $server->setObject($object); - - return new TraceableTransport( - $this->client, - new ExtSoapServerTransport($server) - ); - } -} diff --git a/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/DuplicateTypenamesTest.php b/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/DuplicateTypenamesTest.php deleted file mode 100644 index 915f72f5..00000000 --- a/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/DuplicateTypenamesTest.php +++ /dev/null @@ -1,237 +0,0 @@ -wsdl = FIXTURE_DIR.'/wsdl/functional/duplicate-typenames.wsdl'; - $this->driver = $this->configureSoapDriver($this->wsdl, []); - $this->transport = $this->configureServer( - $this->wsdl, - [], - new class() - { - public function validate($store1, $store2) - { - return ['output1' => $store1, 'output2' => $store2]; - } - } - ); - } - - /** @test */ - function it_registers_both_types() - { - $types = $this->driver->getMetadata()->getTypes(); - $this->assertCount(2, $types); - - [$store1, $store2] = [...$types]; - $store1Props = [...$store1->getProperties()]; - $store2Props = [...$store2->getProperties()]; - - - $this->assertEquals($store1->getName(), 'Store'); - $this->assertEquals($store1Props[0]->getName(), 'Attribute1'); - $this->assertEquals($store2->getName(), 'Store'); - $this->assertEquals($store2Props[0]->getName(), 'Attribute2'); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_knows_how_to_encode_both_types() - { - $engine = new SimpleEngine($this->driver, $this->transport); - $store1 = (object) ['Attribute1' => 'ok']; - $store2 = (object) ['Attribute2' => 'ok']; - - $response = $engine->request('validate', [$store1, $store2]); - - $this->assertEquals($store1, $response['output1']); - $this->assertEquals($store2, $response['output2']); - - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - $this->assertStringContainsString( - 'ok', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'ok', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'ok', - $lastRequestInfo->getLastResponse() - ); - $this->assertStringContainsString( - 'ok', - $lastRequestInfo->getLastResponse() - ); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_uses_same_model_for_both_objects() - { - $this->driver = $this->configureSoapDriver($this->wsdl, [ - 'classmap' => new ClassMapCollection( - new ClassMap('Store', DuplicateTypeStore::class) - ) - ]); - $this->transport = $this->configureServer( - $this->wsdl, - [], - new class() - { - public function validate($store1, $store2) - { - return [ - 'output1' => new DuplicateTypeStore('attr1', null), - 'output2' => new DuplicateTypeStore(null, 'attr2') - ]; - } - } - ); - - $engine = new SimpleEngine($this->driver, $this->transport); - $store1 = new DuplicateTypeStore('attr1', 'attr2'); - $store2 = new DuplicateTypeStore('attr1', 'attr2'); - $response = $engine->request('validate', [$store1, $store2]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertEquals(new DuplicateTypeStore('attr1', null), $response['output1']); - $this->assertEquals(new DuplicateTypeStore(null, 'attr2'), $response['output2']); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastResponse() - ); - $this->assertStringContainsString( - 'attr2', - $lastRequestInfo->getLastResponse() - ); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_is_possible_to_override_a_single_instance_with_typemap() - { - $this->driver = $this->configureSoapDriver($this->wsdl, [ - 'classmap' => new ClassMapCollection( - new ClassMap('Store', DuplicateTypeStore::class) - ), - 'typemap' => [ - [ - 'type_name' => 'Store', - 'type_ns' => 'http://soapinterop.org/xsd1', - 'from_xml' => function($xml) { - $doc = new \DOMDocument(); - $doc->loadXML($xml); - $attr1 = $doc->childNodes->item(0)->textContent; - - return $this->createStore1Class($attr1); - }, - ], - ] - ]); - $this->transport = $this->configureServer( - $this->wsdl, - [], - new class() - { - public function validate($store1, $store2) - { - return [ - 'output1' => new DuplicateTypeStore('attr1', null), - 'output2' => new DuplicateTypeStore(null, 'attr2') - ]; - } - } - ); - - $engine = new SimpleEngine($this->driver, $this->transport); - $store1 = new DuplicateTypeStore('attr1', 'attr2'); - $store2 = new DuplicateTypeStore('attr1', 'attr2'); - $response = $engine->request('validate', [$store1, $store2]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertEquals($this->createStore1Class('attr1'), $response['output1']); - $this->assertEquals(new DuplicateTypeStore(null, 'attr2'), $response['output2']); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'attr1', - $lastRequestInfo->getLastResponse() - ); - $this->assertStringContainsString( - 'attr2', - $lastRequestInfo->getLastResponse() - ); - } - - private function createStore1Class($attr1) { - return new class($attr1) { - private $Attribute1; - public function __construct($Attribute1) - { - $this->Attribute1 = $Attribute1; - } - }; - } -} - - -class DuplicateTypeStore { - public $Attribute1; - public $Attribute2; - - public function __construct($Attribute1, $Attribute2) - { - $this->Attribute1 = $Attribute1; - $this->Attribute2 = $Attribute2; - } -} diff --git a/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/EnumTest.php b/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/EnumTest.php deleted file mode 100644 index 900c2b6a..00000000 --- a/test/PhproTest/SoapClient/Functional/ExtSoap/Encoding/EnumTest.php +++ /dev/null @@ -1,174 +0,0 @@ -wsdl = FIXTURE_DIR . '/wsdl/functional/enum.wsdl'; - $this->driver = $this->configureSoapDriver($this->wsdl, []); - $this->transport = $this->configureServer( - $this->wsdl, - [], - new class() - { - public function validate($input) - { - return $input; - } - } - ); - } - - /** @test */ - function it_does_not_register_a_type() - { - $types = $this->driver->getMetadata()->getTypes(); - $this->assertCount(0, $types); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_knows_how_to_add_enums() - { - $input = 'Home'; - $engine = new SimpleEngine($this->driver, $this->transport); - $response = (string) $engine->request('validate', [$input]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertEquals($input, $response); - $this->assertStringContainsString( - 'Home', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'Home', - $lastRequestInfo->getLastResponse() - ); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_does_not_validate_enums() - { - $input = 'INVALID'; - $engine = new SimpleEngine($this->driver, $this->transport); - $engine->request('validate', [$input]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertStringContainsString( - 'INVALID', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'INVALID', - $lastRequestInfo->getLastResponse() - ); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_does_not_validate_enum_types() - { - $input = 123; - $engine = new SimpleEngine($this->driver, $this->transport); - $engine->request('validate', [$input]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertStringContainsString( - '123', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - '123', - $lastRequestInfo->getLastResponse() - ); - } - - /** - * @test - * @runInSeparateProcess - */ - function it_can_be_transformed_with_type_map() - { - $this->driver = $this->configureSoapDriver($this->wsdl, [ - 'typemap' => [ - [ - 'type_name' => 'PhoneTypeEnum', - 'type_ns' => 'http://soapinterop.org/xsd', - 'from_xml' => function($xml) { - $doc = new \DOMDocument(); - $doc->loadXML($xml); - - if ('' === $doc->textContent) { - return null; - } - - return OfficeEnum::from($doc->textContent)->value; - }, - 'to_xml' => function($enum) { - return sprintf( - '%s', - $enum ? OfficeEnum::from($enum)->value : '' - ); - }, - ] - ] - ]); - $engine = new SimpleEngine($this->driver, $this->transport); - - $input = OfficeEnum::HOME->value; - $response = $engine->request('validate', [$input]); - $lastRequestInfo = $this->transport->collectLastRequestInfo(); - - $this->assertEquals($input, $response); - $this->assertStringContainsString( - 'Home', - $lastRequestInfo->getLastRequest() - ); - $this->assertStringContainsString( - 'Home', - $lastRequestInfo->getLastResponse() - ); - } -} - -enum OfficeEnum : string { - case HOME = 'Home'; - case GSM = 'Gsm'; - case OFFICE = 'Office'; - - /** - * sadly __toString is not possible on enums. - * Otherwise, soap would just be able to use php enums... - */ -} diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php index f8f18324..3363b7c5 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php @@ -70,7 +70,7 @@ private function createContext() $type = new Type($namespace ='MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php index 8ac8f40c..c6979702 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php @@ -56,15 +56,15 @@ function it_assembles_a_classmap() namespace ClassMapNamespace; use MyNamespace as Type; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMapCollection; -use Soap\ExtSoapEngine\Configuration\ClassMap\ClassMap; +use Soap\Encoding\ClassMap\ClassMapCollection; +use Soap\Encoding\ClassMap\ClassMap; class MyClassMap { - public static function getCollection() : \Soap\ExtSoapEngine\Configuration\ClassMap\ClassMapCollection + public static function getCollection() : \Soap\Encoding\ClassMap\ClassMapCollection { return new ClassMapCollection( - new ClassMap('MyType', Type\MyType::class), + new ClassMap('http://my-namespace.com', 'MyType', Type\MyType::class), ); } } @@ -90,7 +90,9 @@ private function createContext() new MetaProperty('myProperty', XsdType::guess('string')) ), ], - new TypeMeta(), + (new XsdType('MyType')) + ->withXmlNamespace('http://my-namespace.com') + ->withXmlTypeName('MyType'), ), ]); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClientMethodAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClientMethodAssemblerTest.php index ce917ad4..6bdd2678 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClientMethodAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClientMethodAssemblerTest.php @@ -53,7 +53,7 @@ private function createContext() $method = new ClientMethod( 'functionName', [ - new Parameter('param', 'ParamType', $typeNamespace, new TypeMeta()), + new Parameter('param', 'ParamType', $typeNamespace, XsdType::create('ParamType')), ], ReturnType::fromMetaData($typeNamespace, XsdType::create('ReturnType')), $typeNamespace, @@ -75,8 +75,8 @@ private function createMultiArgumentContext() $method = new ClientMethod( 'functionName', [ - new Parameter('param', 'ParamType', $typeNamespace, new TypeMeta()), - new Parameter('param2', 'OtherParamType', $typeNamespace, new TypeMeta()), + new Parameter('param', 'ParamType', $typeNamespace, XsdType::create('ParamType')), + new Parameter('param2', 'OtherParamType', $typeNamespace, XsdType::create('OtherParamType')), ], ReturnType::fromMetaData($typeNamespace, XsdType::create('ReturnType')), $typeNamespace, @@ -247,7 +247,7 @@ function it_assembles_a_method_with_underscore_param_type() $method = new ClientMethod( 'Function_name', [ - new Parameter('param', 'param_type', $typeNamespace, new TypeMeta()), + new Parameter('param', 'param_type', $typeNamespace, XsdType::create('param_type')), ], ReturnType::fromMetaData($typeNamespace, XsdType::create('return_type')), $typeNamespace, @@ -316,7 +316,7 @@ function it_deals_with_scalar_types_as_a_multi_arguments_request() { $method = new ClientMethod( 'Function_name', [ - new Parameter('param', 'string', $typeNamespace, (new TypeMeta())->withIsSimple(true)), + new Parameter('param', 'string', $typeNamespace, XsdType::create('string')->withMeta(static fn (TypeMeta $meta) => $meta->withIsSimple(true))), ], ReturnType::fromMetaData($typeNamespace, XsdType::create('ReturnType')), $typeNamespace, @@ -427,8 +427,8 @@ function it_can_deal_with_scalar_return_types_on_multi_arguments() $method = new ClientMethod( 'functionName', [ - new Parameter('param1', 'string', $typeNamespace, (new TypeMeta())), - new Parameter('param2', 'string', $typeNamespace, (new TypeMeta())), + new Parameter('param1', 'string', $typeNamespace, XsdType::create('string')), + new Parameter('param2', 'string', $typeNamespace, XsdType::create('string')), ], ReturnType::fromMetaData($typeNamespace, XsdType::create('string')->withMeta( fn (TypeMeta $meta): TypeMeta => $meta->withIsSimple(true) diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php index 30728f5d..37fa709b 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php @@ -84,7 +84,7 @@ function it_assambles_a_constructor() Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), Property::fromMetaData($namespace, new MetaProperty('prop3', XsdType::guess('SomeClass'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -160,7 +160,7 @@ function it_assambles_a_constructor_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -196,7 +196,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php index 0d401c87..fab286aa 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php @@ -95,7 +95,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php index 551e2afa..eaf610d7 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php @@ -9,6 +9,7 @@ use PHPUnit\Framework\TestCase; use Laminas\Code\Generator\ClassGenerator; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class ExtendingTypeAssemblerTest @@ -68,7 +69,7 @@ function it_skips_assambling_on_non_extending_type() { $assembler = new ExtendingTypeAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -93,11 +94,11 @@ function it_skips_assambling_on_extending_simple_type() { $assembler = new ExtendingTypeAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], (new TypeMeta())->withExtends([ + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ 'type' => 'string', 'namespace' => 'xsd', 'isSimple' => true, - ])); + ]))); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -121,10 +122,10 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], (new TypeMeta())->withExtends([ + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ 'type' => 'MyBaseType', 'namespace' => 'xxxx' - ])); + ]))); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php index 4bbc0726..81698ea8 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php @@ -70,7 +70,7 @@ private function createContext() $type = new Type($namespace ='MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType'), new TypeMeta()); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php index 67ea2d59..c23eb2ae 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php @@ -206,7 +206,7 @@ function it_assembles_a_fluent_setter_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new PropertyContext($class, $type, $property); $assembler->assemble($context); @@ -244,7 +244,7 @@ private function createContext() $namespace, new MetaProperty('prop1', XsdType::guess('string')) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -257,7 +257,7 @@ private function createContextWithAnUnknownType() $class = new ClassGenerator('MyType', 'MyNamespace'); $type = new Type($namespace = 'MyNamespace', 'MyType', [ $property = Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('foobar'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -274,7 +274,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); $property = $properties['prop1']; return new PropertyContext($class, $type, $property); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php index 2972f52b..a3b0ab96 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php @@ -264,7 +264,7 @@ function it_assembles_a_property_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new PropertyContext($class, $type, $property); $assembler->assemble($context); @@ -303,7 +303,7 @@ private function createContext($propertyName = 'prop1') ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); $property = $properties[$propertyName]; return new PropertyContext($class, $type, $property); @@ -321,7 +321,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); $property = $properties['prop1']; return new PropertyContext($class, $type, $property); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php index f8e69335..286ad903 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php @@ -253,7 +253,7 @@ function it_assembles_a_fluent_setter_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new PropertyContext($class, $type, $property); $assembler->assemble($context); @@ -290,7 +290,7 @@ private function createContext() $class = new ClassGenerator('MyType', 'MyNamespace'); $type = new Type('MyNamespace', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -307,7 +307,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); $property = $properties['prop1']; return new PropertyContext($class, $type, $property); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/InterfaceAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/InterfaceAssemblerTest.php index 71eefe25..de72a0a9 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/InterfaceAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/InterfaceAssemblerTest.php @@ -48,7 +48,7 @@ function it_can_assemble_property_context() { $assembler = new InterfaceAssembler('MyUsedClass'); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))); $context = new PropertyContext($class, $type, $property); $this->assertTrue($assembler->canAssemble($context)); @@ -87,7 +87,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php index 02094887..7078c92f 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php @@ -133,7 +133,7 @@ private function createContext(?callable $metaConfigurator = null) ->withMinOccurs(1) ->withMaxOccurs(2) )))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php index 8917ba14..539b829f 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php @@ -80,7 +80,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php index cf0667b2..62f129dc 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php @@ -210,7 +210,7 @@ function it_assembles_properties_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new PropertyContext($class, $type, $property); $assembler->assemble($context); @@ -305,7 +305,7 @@ private function createContext() $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string')->withMeta( static fn (TypeMeta $meta): TypeMeta => $meta->withDocs('Type specific docs') ))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -321,7 +321,7 @@ private function createContextWithLongType() 'This\\Is\\My\\Very\\Very\\Long\\Namespace\\And\\Class\\Name\\That\\Should\\Not\\Never\\Ever', new MetaProperty('prop1', XsdType::guess('Wrap')) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -335,7 +335,7 @@ private function createContextWithNullableType() $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string')->withMeta( static fn (TypeMeta $meta): TypeMeta => $meta->withDocs('Type specific docs')->withIsNullable(true) ))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php index c703ab7a..b8d840fc 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php @@ -73,7 +73,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php index 0fa04e4a..0077e0b5 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php @@ -73,7 +73,7 @@ private function createContext() $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php index edccee62..a9463a05 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php @@ -144,7 +144,7 @@ private function createContext() $class = new ClassGenerator('MyType', 'MyNamespace'); $type = new Type($namespace = 'MyNamespace', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('SomeClass'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php index aa171993..0bb543b3 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php @@ -169,7 +169,7 @@ function it_assembles_a_setter_with_advanced_types() static fn (TypeMeta $meta): TypeMeta => $meta->withIsList(true) )) ), - ], new TypeMeta()); + ], XsdType::create('MyType')); $context = new PropertyContext($class, $type, $property); $assembler->assemble($context); @@ -202,7 +202,7 @@ private function createContext() $class = new ClassGenerator('MyType', 'MyNamespace'); $type = new Type('MyNamespace', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))), - ], new TypeMeta()); + ], XsdType::create('MyType')); return new PropertyContext($class, $type, $property); } @@ -219,7 +219,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); $property = $properties['prop1']; return new PropertyContext($class, $type, $property); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php index 8575d76f..bab86bbd 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php @@ -9,6 +9,7 @@ use PHPUnit\Framework\TestCase; use Laminas\Code\Generator\ClassGenerator; use Soap\Engine\Metadata\Model\TypeMeta; +use Soap\Engine\Metadata\Model\XsdType; /** * Class TraitAssemblerTest @@ -93,7 +94,7 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/UseAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/UseAssemblerTest.php index 7eeb8dda..c2ba1455 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/UseAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/UseAssemblerTest.php @@ -48,7 +48,7 @@ function it_can_assemble_property_context() { $assembler = new UseAssembler('MyUsedClass'); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))); $context = new PropertyContext($class, $type, $property); $this->assertTrue($assembler->canAssemble($context)); @@ -178,7 +178,7 @@ function it_does_not_assemble_use_for_the_global_namespace() { $assembler = new UseAssembler('SomeOtherClass'); $class = new ClassGenerator('MyType'); - $type = new Type('', 'MyType', [], new TypeMeta()); + $type = new Type('', 'MyType', [], XsdType::create('MyType')); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -225,7 +225,7 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], new TypeMeta()); + $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); return new TypeContext($class, $type); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/ClientFactoryGeneratorTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/ClientFactoryGeneratorTest.php index a171c673..407ea087 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/ClientFactoryGeneratorTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/ClientFactoryGeneratorTest.php @@ -23,17 +23,34 @@ public function testGenerate() use App\Classmap\SomeClassmap; use Symfony\Component\EventDispatcher\EventDispatcher; use Phpro\SoapClient\Soap\DefaultEngineFactory; -use Soap\ExtSoapEngine\ExtSoapOptions; +use Phpro\SoapClient\Soap\EngineOptions; use Phpro\SoapClient\Caller\EventDispatchingCaller; use Phpro\SoapClient\Caller\EngineCaller; +use Soap\Encoding\EncoderRegistry; class MyclientFactory { + /** + * This factory can be used as a starting point to create your own specialized + * factory. Feel free to modify. + */ public static function factory(string \$wsdl) : \App\Client\Myclient { \$engine = DefaultEngineFactory::create( - ExtSoapOptions::defaults(\$wsdl, []) - ->withClassMap(SomeClassmap::getCollection()) + EngineOptions::defaults(\$wsdl) + ->withEncoderRegistry( + EncoderRegistry::default()->addClassMapCollection( + SomeClassmap::getCollection() + ) + ) + // If you want to enable WSDL caching: + // ->withCache() + // If you want to use Alternate HTTP settings: + // ->withWsdlLoader() + // ->withTransport() + // If you want specific SOAP setting: + // ->withWsdlParserContext() + // ->withPreferredSoapVersion() ); \$eventDispatcher = new EventDispatcher(); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/ConfigGeneratorTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/ConfigGeneratorTest.php index 00942839..fc1d79e4 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/ConfigGeneratorTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/ConfigGeneratorTest.php @@ -17,12 +17,12 @@ public function testGenerate(): void use Phpro\SoapClient\CodeGenerator\Assembler; use Phpro\SoapClient\CodeGenerator\Rules; use Phpro\SoapClient\CodeGenerator\Config\Config; -use Soap\ExtSoapEngine\ExtSoapOptions; -use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory; +use Phpro\SoapClient\Soap\EngineOptions; +use Phpro\SoapClient\Soap\DefaultEngineFactory; return Config::create() - ->setEngine(\$engine = CodeGeneratorEngineFactory::create( - 'wsdl.xml' + ->setEngine(\$engine = DefaultEngineFactory::create( + EngineOptions::defaults('wsdl.xml') )) ->setTypeDestination('src/type') ->setTypeNamespace('App\\\\Type') @@ -93,12 +93,12 @@ public function testGenerateWithoutDocblocks(): void use Phpro\SoapClient\CodeGenerator\Assembler; use Phpro\SoapClient\CodeGenerator\Rules; use Phpro\SoapClient\CodeGenerator\Config\Config; -use Soap\ExtSoapEngine\ExtSoapOptions; -use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory; +use Phpro\SoapClient\Soap\EngineOptions; +use Phpro\SoapClient\Soap\DefaultEngineFactory; return Config::create() - ->setEngine(\$engine = CodeGeneratorEngineFactory::create( - 'wsdl.xml' + ->setEngine(\$engine = DefaultEngineFactory::create( + EngineOptions::defaults('wsdl.xml') )) ->addRule(new Rules\AssembleRule(new Assembler\GetterAssembler( (new Assembler\GetterAssemblerOptions())->withDocBlocks(false) diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Model/PropertyTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Model/PropertyTest.php index 8609790e..8259edb4 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Model/PropertyTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Model/PropertyTest.php @@ -19,7 +19,7 @@ class PropertyTest extends TestCase */ public function it_returns_mixed_type_post_php8(): void { - $property = new Property('test', 'mixed', 'App', new TypeMeta()); + $property = new Property('test', 'mixed', 'App', XsdType::create('mixed')); self::assertEquals('mixed', $property->getPhpType()); self::assertEquals('mixed', $property->getType()); } diff --git a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php similarity index 90% rename from test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php rename to test/PhproTest/SoapClient/Unit/Soap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php index d6615178..34a03070 100644 --- a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php +++ b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Detector/DuplicateTypeNamesDetectorTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace PhproTest\SoapClient\Unit\Soap\ExtSoap\Metadata\Detector; +namespace PhproTest\SoapClient\Unit\Soap\Metadata\Detector; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Detector\DuplicateTypeNamesDetector; +use Phpro\SoapClient\Soap\Metadata\Detector\DuplicateTypeNamesDetector; use PHPUnit\Framework\TestCase; use Soap\Engine\Metadata\Collection\PropertyCollection; use Soap\Engine\Metadata\Collection\TypeCollection; diff --git a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php similarity index 93% rename from test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php rename to test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php index 8b41ff10..94045cca 100644 --- a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php +++ b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/IntersectDuplicateTypesStrategyTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace PhproTest\SoapClient\Unit\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes; +namespace PhproTest\SoapClient\Unit\Soap\Metadata\Manipulators\DuplicateTypes; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy; use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorInterface; use PHPUnit\Framework\TestCase; use Soap\Engine\Metadata\Collection\PropertyCollection; diff --git a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php similarity index 91% rename from test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php rename to test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php index 5f271ad7..89faf36f 100644 --- a/test/PhproTest/SoapClient/Unit/Soap/ExtSoap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php +++ b/test/PhproTest/SoapClient/Unit/Soap/Metadata/Manipulators/DuplicateTypes/RemoveDuplicateTypesStrategyTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace PhproTest\SoapClient\Unit\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes; +namespace PhproTest\SoapClient\Unit\Soap\Metadata\Manipulators\DuplicateTypes; -use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy; +use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy; use Phpro\SoapClient\Soap\Metadata\Manipulators\TypesManipulatorInterface; use PHPUnit\Framework\TestCase; use Soap\Engine\Metadata\Collection\PropertyCollection; diff --git a/test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_fd199.txt b/test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_7c968.txt similarity index 87% rename from test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_fd199.txt rename to test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_7c968.txt index ae3ed318..2e1c5f45 100644 --- a/test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_fd199.txt +++ b/test/fixtures/vcr/client/www.dneonline.com_POST_calculator.asmx_7c968.txt @@ -1,11 +1,11 @@ HTTP/1.1 200 OK Cache-Control: private, max-age=0 Content-Type: text/xml; charset=utf-8 -Server: Microsoft-IIS/8.0 +Server: Microsoft-IIS/10.0 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET X-Powered-By-Plesk: PleskWin -Date: Fri, 27 Aug 2021 12:38:04 GMT +Date: Mon, 10 Jun 2024 08:54:40 GMT Content-Length: 325 3 \ No newline at end of file