From 4fccfc09f517cf76c0327e91be4ad0ae208dc7bd Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Tue, 22 Oct 2024 15:08:29 +0200 Subject: [PATCH] Rework code generator models for easier 3rd-party class type encoders --- .../CodeGenerator/Model/TypeMapSpec.php | 2 +- .../CodeGenerator/Model/TypeSpec.php | 5 ++++- .../Rules/IsAbstractTypeRuleSpec.php | 8 +++---- .../Rules/IsExtendingTypeRuleSpec.php | 8 +++---- .../CodeGenerator/Rules/IsRequestRuleSpec.php | 8 +++---- .../CodeGenerator/Rules/IsResultRuleSpec.php | 8 +++---- .../CodeGenerator/Rules/TypeMapRuleSpec.php | 14 ++++++------ .../Rules/TypenameMatchesRuleSpec.php | 8 +++---- .../CodeGenerator/TypeGeneratorSpec.php | 2 ++ .../CodeGenerator/Model/ClientMethod.php | 5 ++++- .../CodeGenerator/Model/ClientMethodMap.php | 2 ++ .../CodeGenerator/Model/Parameter.php | 14 +++++++----- .../CodeGenerator/Model/Property.php | 22 +++++++++---------- .../CodeGenerator/Model/ReturnType.php | 10 +++++---- .../SoapClient/CodeGenerator/Model/Type.php | 16 +++++++++----- .../CodeGenerator/Model/TypeMap.php | 2 ++ .../Calculator/TypeNameCalculator.php | 4 ++-- .../CodeGenerator/Util/Normalizer.php | 5 ++++- .../Assembler/AbstractClassAssemblerTest.php | 2 +- .../Assembler/ClassMapAssemblerTest.php | 1 + .../Assembler/ConstructorAssemblerTest.php | 6 ++--- .../Assembler/ExtendAssemblerTest.php | 2 +- .../Assembler/ExtendingTypeAssemblerTest.php | 6 ++--- .../Assembler/FinalClassAssemblerTest.php | 2 +- .../Assembler/FluentSetterAssemblerTest.php | 8 +++---- .../Assembler/GetterAssemblerTest.php | 8 +++---- .../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 | 2 +- .../Assembler/UseAssemblerTest.php | 6 ++--- 37 files changed, 123 insertions(+), 97 deletions(-) diff --git a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php index eb590423..27be5344 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeMapSpec.php @@ -21,7 +21,7 @@ class TypeMapSpec extends ObjectBehavior function let() { $this->beConstructedWith($namespace = 'MyNamespace', [ - new Type($namespace, 'type1', [ + new Type($namespace, 'type1', 'type1', [ 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 fd8c61f0..be9d308f 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Model/TypeSpec.php @@ -4,6 +4,7 @@ use Phpro\SoapClient\CodeGenerator\Model\Property; use Phpro\SoapClient\CodeGenerator\Model\Type; +use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Soap\Engine\Metadata\Model\TypeMeta; @@ -22,6 +23,7 @@ function let() $this->beConstructedWith( $namespace = 'MyNamespace', 'myType', + 'MyType', [new Property('prop1', 'string', $namespace, XsdType::create('string'))], XsdType::create('MyType') ); @@ -58,7 +60,7 @@ function it_has_meta() function it_should_not_replace_underscores_in_paths() { - $this->beConstructedWith('MyNamespace', 'my_type_3_2', ['prop1' => 'string'], XsdType::create('MyType')); + $this->beConstructedWith('MyNamespace', 'my_type_3_2', Normalizer::normalizeClassname('my_type_3_2'), ['prop1' => 'string'], XsdType::create('MyType')); $this->getFileInfo('my/some_dir')->getPathname()->shouldReturn('my/some_dir/MyType32.php'); } @@ -67,6 +69,7 @@ function it_should_prefix_reserved_keywords() $this->beConstructedWith( $namespace = 'MyNamespace', 'Final', + Normalizer::normalizeClassname('Final'), [new Property('xor', 'string', $namespace, XsdType::create('string'))], XsdType::create('MyType') ); diff --git a/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php b/spec/Phpro/SoapClient/CodeGenerator/Rules/IsAbstractTypeRuleSpec.php index 83f17429..c5bea821 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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'NotAbstract', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyAbstract', '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 adf6ef20..c8009e8d 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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'NotExtending', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'MyExtending', '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 c9872f9d..b8f90b38 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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'RequestType', '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 1115c67c..44972009 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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'ResultType', 'ResultType', [], XsdType::create('MyType'))); $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 095edf14..6066f8cc 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRuleSpec.php @@ -48,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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'NullType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'SomeType', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'UnknownType', '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 ff67c859..fa357c3a 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRuleSpec.php @@ -44,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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'InvalidTypeName', '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', [], XsdType::create('MyType'))); + $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', '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 e9a74e33..a7f733ad 100644 --- a/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php +++ b/spec/Phpro/SoapClient/CodeGenerator/TypeGeneratorSpec.php @@ -48,6 +48,7 @@ function it_generates_types(RuleSetInterface $ruleSet, FileGenerator $file, Clas $type = new Type( $namespace = 'MyNamespace', 'MyType', + 'MyType', [new Property('prop1', 'string', $namespace, XsdType::create('string'))], XsdType::create('MyType') ); @@ -72,6 +73,7 @@ function it_generates_types_for_file_without_classes(RuleSetInterface $ruleSet, $type = new Type( $namespace = 'MyNamespace', 'MyType', + 'MyType', [new Property('prop1', 'string', $namespace, XsdType::create('string'))], XsdType::create('MyType') ); diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethod.php b/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethod.php index 3403227f..2e474f7d 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethod.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethod.php @@ -2,6 +2,7 @@ namespace Phpro\SoapClient\CodeGenerator\Model; +use Phpro\SoapClient\CodeGenerator\Util\Normalizer; use Soap\Engine\Metadata\Model\Method as MetadataMethod; use Soap\Engine\Metadata\Model\MethodMeta; use Soap\Engine\Metadata\Model\Parameter as MetadataParameter; @@ -35,6 +36,8 @@ class ClientMethod private MethodMeta $meta; /** + * @internal - Use ClientMethod::fromMetadata instead + * * TypeModel constructor. * * @param non-empty-string $name @@ -71,7 +74,7 @@ function (MetadataParameter $parameter) use ($parameterNamespace) { iterator_to_array($method->getParameters()) ), ReturnType::fromMetaData($parameterNamespace, $method->getReturnType()), - $parameterNamespace, + Normalizer::normalizeNamespace($parameterNamespace), $method->getMeta() ); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethodMap.php b/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethodMap.php index 9dbb5884..79885fa0 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethodMap.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/ClientMethodMap.php @@ -18,6 +18,8 @@ class ClientMethodMap private $methods; /** + * @internal - Use ClientMethodMap::fromMetadata instead + * * ClientMethodMap constructor. * * @param array|ClientMethod[] $methods diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php b/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php index 7f5621c4..7ce0a30a 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Parameter.php @@ -31,6 +31,8 @@ class Parameter private TypeMeta $meta; /** + * @internal - Use Parameter::fromMetadata instead + * * Parameter constructor. * * @param non-empty-string $name @@ -39,9 +41,9 @@ class Parameter */ 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->name = $name; + $this->type = $type; + $this->namespace = $namespace; $this->xsdType = $xsdType; $this->meta = $xsdType->getMeta(); } @@ -55,9 +57,9 @@ public static function fromMetadata(string $parameterNamespace, MetadataParamete $typeName = (new TypeNameCalculator())($type); return new self( - non_empty_string()->assert($parameter->getName()), - non_empty_string()->assert($typeName), - $parameterNamespace, + Normalizer::normalizeProperty(non_empty_string()->assert($parameter->getName())), + Normalizer::normalizeDataType(non_empty_string()->assert($typeName)), + Normalizer::normalizeNamespace($parameterNamespace), $type ); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php index 6abcfe9c..8eff1e10 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php @@ -6,7 +6,6 @@ use Phpro\SoapClient\CodeGenerator\TypeEnhancer\MetaTypeEnhancer; use Phpro\SoapClient\CodeGenerator\TypeEnhancer\TypeEnhancer; use Phpro\SoapClient\CodeGenerator\Util\Normalizer; -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; @@ -41,6 +40,8 @@ class Property private TypeEnhancer $typeEnhancer; /** + * @internal + * * Property constructor. * * @param non-empty-string $name @@ -49,9 +50,9 @@ class Property */ 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->name = $name; + $this->type = $type; + $this->namespace = $namespace; $this->xsdType = $xsdType; $this->meta = $xsdType->getMeta(); $this->typeEnhancer = new MetaTypeEnhancer($this->meta); @@ -60,25 +61,24 @@ public function __construct(string $name, string $type, string $namespace, XsdTy /** * @param non-empty-string $namespace */ - public static function fromMetaData(string $namespace, MetadataProperty $property) + public static function fromMetaData(string $namespace, MetadataProperty $property): self { $type = $property->getType(); $typeName = $type->getName(); + $calculatedTypeName = Normalizer::normalizeDataType((new TypeNameCalculator())($type)); // This makes it possible to set FQCN as type names in the metadata through TypeReplacers. if (Normalizer::isConsideredExistingThirdPartyClass($typeName)) { $className = Normalizer::getClassNameFromFQN($typeName); - $type = $type->copy($className)->withBaseType($className); + $type = $type->copy($className)->withBaseType($className)->withMemberTypes([]); $namespace = Normalizer::getNamespaceFromFQN($typeName); + $calculatedTypeName = $className; } - $meta = $type->getMeta(); - $calculatedTypeName = (new TypeNameCalculator())($type); - return new self( - non_empty_string()->assert($property->getName()), + Normalizer::normalizeProperty(non_empty_string()->assert($property->getName())), non_empty_string()->assert($calculatedTypeName), - $namespace, + Normalizer::normalizeNamespace($namespace), $type ); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php b/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php index c9a3e1ed..16813f25 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/ReturnType.php @@ -27,6 +27,8 @@ final class ReturnType private TypeMeta $meta; /** + * @internal - Use ReturnType::fromMetaData instead + * * Property constructor. * * @param non-empty-string $type @@ -34,8 +36,8 @@ final class ReturnType */ public function __construct(string $type, string $namespace, XsdType $xsdType) { - $this->type = Normalizer::normalizeDataType($type); - $this->namespace = Normalizer::normalizeNamespace($namespace); + $this->type = $type; + $this->namespace = $namespace; $this->xsdType = $xsdType; $this->meta = $xsdType->getMeta(); } @@ -51,8 +53,8 @@ public static function fromMetaData(string $namespace, XsdType $returnType): sel $typeName = (new TypeNameCalculator())($returnType); return new self( - non_empty_string()->assert($typeName), - $namespace, + Normalizer::normalizeDataType(non_empty_string()->assert($typeName)), + Normalizer::normalizeNamespace($namespace), $returnType ); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php index ad35facc..adb5c29e 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php @@ -42,17 +42,20 @@ class Type private TypeMeta $meta; /** + * @internal - Use Type::fromMetadata instead + * * TypeModel constructor. * * @param non-empty-string $namespace * @param non-empty-string $xsdName + * @param non-empty-string $name * @param Property[] $properties */ - public function __construct(string $namespace, string $xsdName, array $properties, XsdType $xsdType) + public function __construct(string $namespace, string $xsdName, string $name, array $properties, XsdType $xsdType) { - $this->namespace = Normalizer::normalizeNamespace($namespace); + $this->namespace = $namespace; $this->xsdName = $xsdName; - $this->name = Normalizer::normalizeClassname($xsdName); + $this->name = $name; $this->properties = $properties; $this->xsdType = $xsdType; $this->meta = $xsdType->getMeta(); @@ -63,9 +66,12 @@ public function __construct(string $namespace, string $xsdName, array $propertie */ public static function fromMetadata(string $namespace, MetadataType $type): self { + $xsdName = non_empty_string()->assert($type->getName()); + return new self( - $namespace, - non_empty_string()->assert($type->getName()), + Normalizer::normalizeNamespace($namespace), + $xsdName, + Normalizer::normalizeClassname($xsdName), array_map( function (MetadataProperty $property) use ($namespace) { return Property::fromMetaData( diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php b/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php index ee4c4b89..7f89a8c4 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php @@ -25,6 +25,8 @@ class TypeMap private $namespace; /** + * @internal - Use TypeMap::fromMetadata instead + * * TypeMap constructor. * * @param non-empty-string $namespace diff --git a/src/Phpro/SoapClient/CodeGenerator/TypeEnhancer/Calculator/TypeNameCalculator.php b/src/Phpro/SoapClient/CodeGenerator/TypeEnhancer/Calculator/TypeNameCalculator.php index 2224954e..e6d994e0 100644 --- a/src/Phpro/SoapClient/CodeGenerator/TypeEnhancer/Calculator/TypeNameCalculator.php +++ b/src/Phpro/SoapClient/CodeGenerator/TypeEnhancer/Calculator/TypeNameCalculator.php @@ -28,11 +28,11 @@ public function __invoke(XsdType $type): string $isList = $meta->isList()->unwrapOr(false); if ($isList) { $memberType = $type->getMemberTypes()[0] ?? 'mixed'; - return $isKnownType ? $type->getName() : $memberType; + return $isKnownType ? $normalizedTypeName : $memberType; } if ($isKnownType) { - return $type->getName(); + return $normalizedTypeName; } return $type->getBaseTypeOrFallbackToName(); diff --git a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php index dcf7b831..f1872b41 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php +++ b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php @@ -278,7 +278,10 @@ public static function getCompleteUseStatement(string $useName, string $useAlias return $use; } - public static function isConsideredExistingThirdPartyClass(string $class) + /** + * @phpstan-assert-if-true non-empty-string $class + */ + public static function isConsideredExistingThirdPartyClass(string $class): bool { return str_contains($class, '\\') && class_exists($class); } diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php index 3363b7c5..d2c318c8 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/AbstractClassAssemblerTest.php @@ -67,7 +67,7 @@ abstract class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace ='MyNamespace', 'MyType', [ + $type = new Type($namespace ='MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php index 7d0c8190..a8cc73bc 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ClassMapAssemblerTest.php @@ -84,6 +84,7 @@ private function createContext() new Type( $namespace, 'MyType', + 'MyType', [ Property::fromMetaData( $namespace, diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php index 37fa709b..280f1856 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ConstructorAssemblerTest.php @@ -80,7 +80,7 @@ function it_assambles_a_constructor() { $assembler = new ConstructorAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ 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'))), @@ -153,7 +153,7 @@ function it_assambles_a_constructor_with_advanced_types() { $assembler = new ConstructorAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -193,7 +193,7 @@ public function __construct(array \$prop1) private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php index fab286aa..3f112aa9 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendAssemblerTest.php @@ -92,7 +92,7 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php index fef4d08c..488d9ced 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ExtendingTypeAssemblerTest.php @@ -91,7 +91,7 @@ function it_skips_assambling_on_non_extending_type() { $assembler = new ExtendingTypeAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', 'MyType', [], XsdType::create('MyType')); $context = new TypeContext($class, $type); $assembler->assemble($context); @@ -116,7 +116,7 @@ function it_skips_assambling_on_extending_simple_type() { $assembler = new ExtendingTypeAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ + $type = new Type('MyNamespace', 'MyType', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ 'type' => 'string', 'namespace' => 'xsd', 'isSimple' => true, @@ -144,7 +144,7 @@ class MyType private function createContext(?string $importedNamespace = null) { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($importedNamespace ?? 'MyNamespace', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ + $type = new Type($importedNamespace ?? 'MyNamespace', 'MyType', 'MyType', [], XsdType::create('MyType')->withMeta(static fn (TypeMeta $meta) => $meta->withExtends([ 'type' => 'MyBaseType', 'namespace' => 'xxxx' ]))); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php index 81698ea8..e1918674 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FinalClassAssemblerTest.php @@ -67,7 +67,7 @@ final class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace ='MyNamespace', 'MyType', [ + $type = new Type($namespace ='MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType'), new TypeMeta()); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php index c23eb2ae..0ef35744 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/FluentSetterAssemblerTest.php @@ -199,7 +199,7 @@ function it_assembles_a_fluent_setter_with_advanced_types() { $assembler = new FluentSetterAssembler((new FluentSetterAssemblerOptions())); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -239,7 +239,7 @@ public function setProp1(array \$prop1) : static private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')) @@ -255,7 +255,7 @@ private function createContext() private function createContextWithAnUnknownType() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('foobar'))), ], XsdType::create('MyType')); @@ -274,7 +274,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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 a3b0ab96..ea65a531 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/GetterAssemblerTest.php @@ -257,7 +257,7 @@ function it_assembles_a_property_with_advanced_types() { $assembler = new GetterAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -298,12 +298,12 @@ private function createContext($propertyName = 'prop1') $properties = [ 'prop1' => Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))), 'prop2' => Property::fromMetaData('ns1', new MetaProperty('prop2', XsdType::guess('int'))), - 'prop3' => Property::fromMetaData('ns1', new MetaProperty('prop3', XsdType::guess('boolean'))), + 'prop3' => Property::fromMetaData('ns1', new MetaProperty('prop3', XsdType::guess('bool'))), 'prop4' => Property::fromMetaData('ns1', new MetaProperty('prop4', XsdType::guess('My_Response'))), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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), XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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 286ad903..7a8f5d7c 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ImmutableSetterAssemblerTest.php @@ -246,7 +246,7 @@ function it_assembles_a_fluent_setter_with_advanced_types() { $assembler = new ImmutableSetterAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -288,7 +288,7 @@ public function withProp1(array \$prop1) : static private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [ + $type = new Type('MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))), ], XsdType::create('MyType')); @@ -307,7 +307,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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 de72a0a9..bcece635 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', [], XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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)); @@ -84,7 +84,7 @@ class MyType implements Iterator private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php index 7078c92f..cddf768e 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/IteratorAssemblerTest.php @@ -126,7 +126,7 @@ private function createContext(?callable $metaConfigurator = null) { $metaConfigurator ??= identity(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( static fn (TypeMeta $meta): TypeMeta => $metaConfigurator($meta ->withIsList(true) diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php index 539b829f..543a7e0e 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/JsonSerializableAssemblerTest.php @@ -77,7 +77,7 @@ public function jsonSerialize() : array private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php index 62f129dc..1f4fb759 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/PropertyAssemblerTest.php @@ -203,7 +203,7 @@ function it_assembles_properties_with_advanced_types() { $assembler = new PropertyAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -301,7 +301,7 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [ + $type = new Type('MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string')->withMeta( static fn (TypeMeta $meta): TypeMeta => $meta->withDocs('Type specific docs') ))), @@ -316,7 +316,7 @@ private function createContext() private function createContextWithLongType() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [ + $type = new Type('MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( 'This\\Is\\My\\Very\\Very\\Long\\Namespace\\And\\Class\\Name\\That\\Should\\Not\\Never\\Ever', new MetaProperty('prop1', XsdType::guess('Wrap')) @@ -331,7 +331,7 @@ private function createContextWithLongType() private function createContextWithNullableType() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [ + $type = new Type('MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string')->withMeta( static fn (TypeMeta $meta): TypeMeta => $meta->withDocs('Type specific docs')->withIsNullable(true) ))), diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php index b8d840fc..ae70b242 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/RequestAssemblerTest.php @@ -70,7 +70,7 @@ class MyType implements RequestInterface private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php index 0077e0b5..b80fdc80 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultAssemblerTest.php @@ -70,7 +70,7 @@ class MyType implements ResultInterface private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('string'))), Property::fromMetaData($namespace, new MetaProperty('prop2', XsdType::guess('int'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php index a9463a05..5f75c7de 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/ResultProviderAssemblerTest.php @@ -142,7 +142,7 @@ public function getResult() : \Phpro\SoapClient\Type\ResultInterface private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ Property::fromMetaData($namespace, new MetaProperty('prop1', XsdType::guess('SomeClass'))), ], XsdType::create('MyType')); diff --git a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php index 0bb543b3..877aa34e 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/SetterAssemblerTest.php @@ -162,7 +162,7 @@ function it_assembles_a_setter_with_advanced_types() { $assembler = new SetterAssembler(); $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type($namespace = 'MyNamespace', 'MyType', [ + $type = new Type($namespace = 'MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData( $namespace, new MetaProperty('prop1', XsdType::guess('string')->withMeta( @@ -200,7 +200,7 @@ public function setProp1(array \$prop1) : void private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [ + $type = new Type('MyNamespace', 'MyType', 'MyType', [ $property = Property::fromMetaData('ns1', new MetaProperty('prop1', XsdType::guess('string'))), ], XsdType::create('MyType')); @@ -219,7 +219,7 @@ private function createContextWithLongType() ), ]; $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', array_values($properties), XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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 bab86bbd..a01e34be 100644 --- a/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php +++ b/test/PhproTest/SoapClient/Unit/CodeGenerator/Assembler/TraitAssemblerTest.php @@ -94,7 +94,7 @@ class MyType private function createContext() { $class = new ClassGenerator('MyType', 'MyNamespace'); - $type = new Type('MyNamespace', 'MyType', [], XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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 c2ba1455..e8de0cc4 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', [], XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', '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', [], XsdType::create('MyType')); + $type = new Type('', 'MyType', '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', [], XsdType::create('MyType')); + $type = new Type('MyNamespace', 'MyType', 'MyType', [], XsdType::create('MyType')); return new TypeContext($class, $type); }