Skip to content

Commit

Permalink
Prepare soap-client for new php-soap/encoding package
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jun 10, 2024
1 parent 66eb962 commit 949c585
Show file tree
Hide file tree
Showing 67 changed files with 484 additions and 767 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
11 changes: 1 addition & 10 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,7 @@ The `DefaultEngineFactory` can now be configured with a transport and the metada
Full example on how you can personalize your factory class:

```php
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\MetadataOptions;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Soap\ExtSoapEngine\Wsdl\Naming\Md5Strategy;
use Soap\ExtSoapEngine\Wsdl\PermanentWsdlLoaderProvider;
use Soap\Psr18Transport\Psr18Transport;
use Soap\Psr18Transport\Wsdl\Psr18Loader;
use Http\Client\Common\PluginClient;use Http\Discovery\Psr18ClientDiscovery;use Phpro\SoapClient\Soap\DefaultEngineFactory;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;use Soap\ExtSoapEngine\Wsdl\PermanentWsdlLoaderProvider;use Soap\Psr18Transport\Psr18Transport;use Soap\Psr18Transport\Wsdl\Psr18Loader;

$httpClient = Psr18ClientDiscovery::find();
$engine = DefaultEngineFactory::create(
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
11 changes: 1 addition & 10 deletions docs/cli/generate-clientfactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ More advanced client factory:
```php
<?php

use Http\Client\Common\PluginClient;
use Http\Discovery\Psr18ClientDiscovery;
use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy;
use Phpro\SoapClient\Soap\Metadata\MetadataOptions;
use Soap\Psr18Transport\Psr18Transport;
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;
use Http\Client\Common\PluginClient;use Http\Discovery\Psr18ClientDiscovery;use Phpro\SoapClient\Caller\EngineCaller;use Phpro\SoapClient\Caller\EventDispatchingCaller;use Phpro\SoapClient\Soap\ExtSoap\DefaultEngineFactory;use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy;use Phpro\SoapClient\Soap\Metadata\MetadataOptions;use Soap\ExtSoapEngine\ExtSoapOptions;use Soap\Psr18Transport\Psr18Transport;use Symfony\Component\EventDispatcher\EventDispatcher;

class CalculatorClientFactory
{
Expand Down
4 changes: 1 addition & 3 deletions docs/drivers/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ You can overwrite the strategy on the `DefaultEngineFactory` object inside the c
```php
<?php

use Phpro\SoapClient\Soap\DefaultEngineFactory;
use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy;
use Phpro\SoapClient\Soap\Metadata\MetadataOptions;
use Phpro\SoapClient\Soap\DefaultEngineFactory;use Phpro\SoapClient\Soap\Metadata\Manipulators\DuplicateTypes\RemoveDuplicateTypesStrategy;use Phpro\SoapClient\Soap\Metadata\MetadataOptions;

$engine = DefaultEngineFactory::create(
$options, $transport,
Expand Down
4 changes: 2 additions & 2 deletions spec/Phpro/SoapClient/CodeGenerator/ClientGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion spec/Phpro/SoapClient/CodeGenerator/Model/ParameterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion spec/Phpro/SoapClient/CodeGenerator/Model/PropertySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Soap\Engine\Metadata\Model\TypeMeta;
use Soap\Engine\Metadata\Model\XsdType;

/**
* Class PropertySpec
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion spec/Phpro/SoapClient/CodeGenerator/Model/ReturnTypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Soap\Engine\Metadata\Model\TypeMeta;
use Soap\Engine\Metadata\Model\XsdType;

/**
* Class ReturnTypeSpec
Expand All @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Soap\Engine\Metadata\Model\TypeMeta;
use Soap\Engine\Metadata\Model\XsdType;

/**
* Class TypeMapSpec
Expand All @@ -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'))
]);
}

Expand Down
11 changes: 6 additions & 5 deletions spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Soap\Engine\Metadata\Model\TypeMeta;
use Soap\Engine\Metadata\Model\XsdType;

/**
* Class TypeSpec
Expand All @@ -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')
);
}

Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Soap\Engine\Metadata\Model\TypeMeta;
use Soap\Engine\Metadata\Model\XsdType;

/**
* Class PropertynameMatchesRuleSpec
Expand Down Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 949c585

Please sign in to comment.