From 074f5580f9eab7240dca58e27a84ba7c94595535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Thu, 17 Aug 2023 22:06:58 +0200 Subject: [PATCH 01/12] issue #299 - Allow classes to have dynamic properties --- src/File/Struct.php | 9 ++++++++- src/File/StructArray.php | 5 +++++ src/File/StructEnum.php | 5 +++++ .../generated/ValidAdGroupsSelectionCriteria.php | 1 + tests/resources/generated/ValidAddRequest.php | 1 + .../generated/ValidAddRequestRepeatedMaxOccurs.php | 1 + tests/resources/generated/ValidAddress.php | 1 + tests/resources/generated/ValidAddressDelivery_Type.php | 1 + tests/resources/generated/ValidAddressType.php | 1 + tests/resources/generated/ValidApiControlsType.php | 1 + tests/resources/generated/ValidApiFareItinerary.php | 1 + tests/resources/generated/ValidApiItem.php | 1 + tests/resources/generated/ValidApiNewsArticle.php | 1 + tests/resources/generated/ValidApiOffer.php | 1 + tests/resources/generated/ValidApiQuery.php | 1 + ...lidApiQueryWithIdenticalPropertiesDifferentByCase.php | 1 + tests/resources/generated/ValidApiSearchRequest.php | 1 + tests/resources/generated/ValidApiVideoRequest.php | 1 + tests/resources/generated/ValidBannerInfo.php | 1 + tests/resources/generated/ValidCampaignGetItem.php | 1 + tests/resources/generated/ValidDetails.php | 1 + tests/resources/generated/ValidExpiryDate.php | 1 + tests/resources/generated/ValidFieldString1000.php | 1 + tests/resources/generated/ValidHotelReservationType.php | 1 + tests/resources/generated/ValidHouseProfileData.php | 1 + tests/resources/generated/ValidPaymentCardType.php | 1 + tests/resources/generated/ValidProposeNewTimeType.php | 1 + .../ValidSetExpressCheckoutRequestDetailsType.php | 1 + tests/resources/generated/ValidShopper.php | 1 + tests/resources/generated/ValidTaxType.php | 1 + tests/resources/generated/ValidUniqueID_Type.php | 1 + tests/resources/generated/ValidUnitTestsStructResult.php | 1 + .../resources/generated/ValidUnitTestsValueListType.php | 1 + tests/resources/generated/ValidWorkingPeriod.php | 1 + 34 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/File/Struct.php b/src/File/Struct.php index a6924ce9..a2fb41fd 100644 --- a/src/File/Struct.php +++ b/src/File/Struct.php @@ -43,10 +43,17 @@ public function getModel(): ?StructModel return parent::getModel(); } + protected function addClassElement(): AbstractModelFile + { + $this->getFile()->addString('#[\AllowDynamicProperties]'); + + return parent::addClassElement(); + } + protected function defineUseStatements(): self { if ($this->getGenerator()->getOptionValidation()) { - $this->getFile()->addUse(\InvalidArgumentException::class, null, false); + $this->getFile()->addUse(\InvalidArgumentException::class); } return parent::defineUseStatements(); diff --git a/src/File/StructArray.php b/src/File/StructArray.php index 64a23bae..9893cc37 100644 --- a/src/File/StructArray.php +++ b/src/File/StructArray.php @@ -40,6 +40,11 @@ public function addStructMethodsSetAndGet(): self return $this; } + protected function addClassElement(): AbstractModelFile + { + return AbstractModelFile::addClassElement(); + } + public function setModel(AbstractModel $model): self { if ($model instanceof StructModel && !$model->isArray()) { diff --git a/src/File/StructEnum.php b/src/File/StructEnum.php index fd0f3893..7c6d45e6 100644 --- a/src/File/StructEnum.php +++ b/src/File/StructEnum.php @@ -27,6 +27,11 @@ public function setModel(AbstractModel $model): self return parent::setModel($model); } + protected function addClassElement(): AbstractModelFile + { + return AbstractModelFile::addClassElement(); + } + protected function fillClassConstants(ConstantContainer $constants): void { /** @var StructModel $model */ diff --git a/tests/resources/generated/ValidAdGroupsSelectionCriteria.php b/tests/resources/generated/ValidAdGroupsSelectionCriteria.php index b2077fb7..b41762e2 100644 --- a/tests/resources/generated/ValidAdGroupsSelectionCriteria.php +++ b/tests/resources/generated/ValidAdGroupsSelectionCriteria.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiAdGroupsSelectionCriteria extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidAddRequest.php b/tests/resources/generated/ValidAddRequest.php index bbe70ff0..6da462fa 100644 --- a/tests/resources/generated/ValidAddRequest.php +++ b/tests/resources/generated/ValidAddRequest.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiAddRequest extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidAddRequestRepeatedMaxOccurs.php b/tests/resources/generated/ValidAddRequestRepeatedMaxOccurs.php index d2d2e3af..be61b5f6 100644 --- a/tests/resources/generated/ValidAddRequestRepeatedMaxOccurs.php +++ b/tests/resources/generated/ValidAddRequestRepeatedMaxOccurs.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiAddRequest extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidAddress.php b/tests/resources/generated/ValidAddress.php index c59f9998..4e1e133b 100644 --- a/tests/resources/generated/ValidAddress.php +++ b/tests/resources/generated/ValidAddress.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiАдресРФ extends ApiСостав { /** diff --git a/tests/resources/generated/ValidAddressDelivery_Type.php b/tests/resources/generated/ValidAddressDelivery_Type.php index db40ff81..b4b3419e 100644 --- a/tests/resources/generated/ValidAddressDelivery_Type.php +++ b/tests/resources/generated/ValidAddressDelivery_Type.php @@ -15,6 +15,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiAddressDelivery_Type extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidAddressType.php b/tests/resources/generated/ValidAddressType.php index f8bc94e0..4532c832 100644 --- a/tests/resources/generated/ValidAddressType.php +++ b/tests/resources/generated/ValidAddressType.php @@ -15,6 +15,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiAddressType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiControlsType.php b/tests/resources/generated/ValidApiControlsType.php index 8335a324..637f3cf3 100644 --- a/tests/resources/generated/ValidApiControlsType.php +++ b/tests/resources/generated/ValidApiControlsType.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiControlsType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiFareItinerary.php b/tests/resources/generated/ValidApiFareItinerary.php index 820d693b..f7f945ce 100755 --- a/tests/resources/generated/ValidApiFareItinerary.php +++ b/tests/resources/generated/ValidApiFareItinerary.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiFareItinerary extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiItem.php b/tests/resources/generated/ValidApiItem.php index 83a7fede..adf45740 100755 --- a/tests/resources/generated/ValidApiItem.php +++ b/tests/resources/generated/ValidApiItem.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiItem extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiNewsArticle.php b/tests/resources/generated/ValidApiNewsArticle.php index ea50f980..d1e31a70 100755 --- a/tests/resources/generated/ValidApiNewsArticle.php +++ b/tests/resources/generated/ValidApiNewsArticle.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiNewsArticle extends StructClass { /** diff --git a/tests/resources/generated/ValidApiOffer.php b/tests/resources/generated/ValidApiOffer.php index ee402abe..551f6858 100644 --- a/tests/resources/generated/ValidApiOffer.php +++ b/tests/resources/generated/ValidApiOffer.php @@ -16,6 +16,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiOffer extends ApiOrder { /** diff --git a/tests/resources/generated/ValidApiQuery.php b/tests/resources/generated/ValidApiQuery.php index 679e31e8..5feb772e 100755 --- a/tests/resources/generated/ValidApiQuery.php +++ b/tests/resources/generated/ValidApiQuery.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiQuery extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiQueryWithIdenticalPropertiesDifferentByCase.php b/tests/resources/generated/ValidApiQueryWithIdenticalPropertiesDifferentByCase.php index 8fff9f11..f99cb885 100644 --- a/tests/resources/generated/ValidApiQueryWithIdenticalPropertiesDifferentByCase.php +++ b/tests/resources/generated/ValidApiQueryWithIdenticalPropertiesDifferentByCase.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiQuery extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiSearchRequest.php b/tests/resources/generated/ValidApiSearchRequest.php index b8156d05..f5faf4cd 100755 --- a/tests/resources/generated/ValidApiSearchRequest.php +++ b/tests/resources/generated/ValidApiSearchRequest.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiSearchRequest extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidApiVideoRequest.php b/tests/resources/generated/ValidApiVideoRequest.php index 84b0d80b..e34cf88d 100755 --- a/tests/resources/generated/ValidApiVideoRequest.php +++ b/tests/resources/generated/ValidApiVideoRequest.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiVideoRequest extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidBannerInfo.php b/tests/resources/generated/ValidBannerInfo.php index 72057d03..1d6c7b09 100644 --- a/tests/resources/generated/ValidBannerInfo.php +++ b/tests/resources/generated/ValidBannerInfo.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiBannerInfo extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidCampaignGetItem.php b/tests/resources/generated/ValidCampaignGetItem.php index 032803d4..84e1dd64 100644 --- a/tests/resources/generated/ValidCampaignGetItem.php +++ b/tests/resources/generated/ValidCampaignGetItem.php @@ -12,6 +12,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiCampaignGetItem extends ApiCampaignBase { /** diff --git a/tests/resources/generated/ValidDetails.php b/tests/resources/generated/ValidDetails.php index bd4b216a..3db5f69e 100644 --- a/tests/resources/generated/ValidDetails.php +++ b/tests/resources/generated/ValidDetails.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiDetails extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidExpiryDate.php b/tests/resources/generated/ValidExpiryDate.php index 81dc8b4c..b670bba2 100644 --- a/tests/resources/generated/ValidExpiryDate.php +++ b/tests/resources/generated/ValidExpiryDate.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiExpiryDate extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidFieldString1000.php b/tests/resources/generated/ValidFieldString1000.php index e26d77e6..5bb84d02 100644 --- a/tests/resources/generated/ValidFieldString1000.php +++ b/tests/resources/generated/ValidFieldString1000.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiFieldString1000 extends ApiFieldString { } diff --git a/tests/resources/generated/ValidHotelReservationType.php b/tests/resources/generated/ValidHotelReservationType.php index a4cb8978..2dc14eb1 100644 --- a/tests/resources/generated/ValidHotelReservationType.php +++ b/tests/resources/generated/ValidHotelReservationType.php @@ -15,6 +15,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiHotelReservationType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidHouseProfileData.php b/tests/resources/generated/ValidHouseProfileData.php index 96e99e26..303769a3 100644 --- a/tests/resources/generated/ValidHouseProfileData.php +++ b/tests/resources/generated/ValidHouseProfileData.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiHouseProfileData extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidPaymentCardType.php b/tests/resources/generated/ValidPaymentCardType.php index 8cec7c12..b531c7de 100644 --- a/tests/resources/generated/ValidPaymentCardType.php +++ b/tests/resources/generated/ValidPaymentCardType.php @@ -16,6 +16,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiPaymentCardType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidProposeNewTimeType.php b/tests/resources/generated/ValidProposeNewTimeType.php index 4fca703b..17b29eeb 100644 --- a/tests/resources/generated/ValidProposeNewTimeType.php +++ b/tests/resources/generated/ValidProposeNewTimeType.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiProposeNewTimeType extends ApiResponseObjectType { } diff --git a/tests/resources/generated/ValidSetExpressCheckoutRequestDetailsType.php b/tests/resources/generated/ValidSetExpressCheckoutRequestDetailsType.php index d69cc628..94f12f4a 100644 --- a/tests/resources/generated/ValidSetExpressCheckoutRequestDetailsType.php +++ b/tests/resources/generated/ValidSetExpressCheckoutRequestDetailsType.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiSetExpressCheckoutRequestDetailsType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidShopper.php b/tests/resources/generated/ValidShopper.php index 64d3078e..4c1bf04a 100644 --- a/tests/resources/generated/ValidShopper.php +++ b/tests/resources/generated/ValidShopper.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiShopper extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidTaxType.php b/tests/resources/generated/ValidTaxType.php index 652d2306..a96c8dbd 100644 --- a/tests/resources/generated/ValidTaxType.php +++ b/tests/resources/generated/ValidTaxType.php @@ -15,6 +15,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiTaxType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidUniqueID_Type.php b/tests/resources/generated/ValidUniqueID_Type.php index 2560f196..c4d97c88 100644 --- a/tests/resources/generated/ValidUniqueID_Type.php +++ b/tests/resources/generated/ValidUniqueID_Type.php @@ -15,6 +15,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiUniqueID_Type extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidUnitTestsStructResult.php b/tests/resources/generated/ValidUnitTestsStructResult.php index e6ac4c7b..207281d8 100644 --- a/tests/resources/generated/ValidUnitTestsStructResult.php +++ b/tests/resources/generated/ValidUnitTestsStructResult.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiResult extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidUnitTestsValueListType.php b/tests/resources/generated/ValidUnitTestsValueListType.php index 074a3336..9e296f1d 100644 --- a/tests/resources/generated/ValidUnitTestsValueListType.php +++ b/tests/resources/generated/ValidUnitTestsValueListType.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiValueListType extends AbstractStructBase { /** diff --git a/tests/resources/generated/ValidWorkingPeriod.php b/tests/resources/generated/ValidWorkingPeriod.php index cdce5d1f..41eb7126 100644 --- a/tests/resources/generated/ValidWorkingPeriod.php +++ b/tests/resources/generated/ValidWorkingPeriod.php @@ -13,6 +13,7 @@ * @subpackage Structs * @release 1.1.0 */ +#[\AllowDynamicProperties] class ApiWorkingPeriod extends AbstractStructBase { /** From e388039e79ae1dc01cf22733064c0f20e599265b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Fri, 25 Aug 2023 19:25:39 +0200 Subject: [PATCH 02/12] issue #300 - fix default method parameter value (#302) --- src/File/Struct.php | 2 +- src/Generator/Utils.php | 10 ++-------- src/Model/StructAttribute.php | 4 ++-- tests/Generator/UtilsTest.php | 1 + tests/Model/StructAttributeTest.php | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/File/Struct.php b/src/File/Struct.php index a2fb41fd..226c1d32 100644 --- a/src/File/Struct.php +++ b/src/File/Struct.php @@ -182,7 +182,7 @@ protected function getStructMethodParameter(StructAttributeModel $attribute): Ph } try { - $defaultValue = $attribute->getDefaultValue(); + $defaultValue = $attribute->getDefaultValue($this->getStructAttributeTypeAsPhpType($attribute)); return new PhpFunctionParameter( lcfirst($attribute->getUniqueString($attribute->getCleanName(), 'method')), diff --git a/src/Generator/Utils.php b/src/Generator/Utils.php index ed6644ef..c2a3b333 100644 --- a/src/Generator/Utils.php +++ b/src/Generator/Utils.php @@ -104,23 +104,17 @@ public static function getStreamContextOptions(?string $basicAuthLogin = null, ? public static function getValueWithinItsType($value, ?string $knownType = null) { if (is_int($value) || (!is_null($value) && in_array($knownType, [ - 'time', - 'positiveInteger', - 'unsignedLong', - 'unsignedInt', - 'short', - 'long', 'int', 'integer', ], true))) { - return intval($value); + return (int) $value; } if (is_float($value) || (!is_null($value) && in_array($knownType, [ 'float', 'double', 'decimal', ], true))) { - return floatval($value); + return (float) $value; } if (is_bool($value) || (!is_null($value) && in_array($knownType, [ 'bool', diff --git a/src/Model/StructAttribute.php b/src/Model/StructAttribute.php index ed89a572..bbaca229 100644 --- a/src/Model/StructAttribute.php +++ b/src/Model/StructAttribute.php @@ -137,7 +137,7 @@ public function isList(): bool /** * @return null|array|bool|float|int|string */ - public function getDefaultValue() + public function getDefaultValue(?string $type = null) { if (($struct = $this->getTypeStruct()) && $struct->isStruct()) { return null; @@ -149,7 +149,7 @@ public function getDefaultValue() 'DefaultValue', 'defaultValue', 'defaultvalue', - ]), $this->getType(true)); + ]), $type); } public function isRequired(): bool diff --git a/tests/Generator/UtilsTest.php b/tests/Generator/UtilsTest.php index 4401601b..07e22fb8 100755 --- a/tests/Generator/UtilsTest.php +++ b/tests/Generator/UtilsTest.php @@ -35,6 +35,7 @@ public function testGetValueWithinItsType(): void { $this->assertSame('020', Utils::getValueWithinItsType('020', 'string')); $this->assertSame('01', Utils::getValueWithinItsType('01', 'string')); + $this->assertSame(1, Utils::getValueWithinItsType('1', 'int')); $this->assertSame(2.568, Utils::getValueWithinItsType('2.568', 'float')); $this->assertSame(true, Utils::getValueWithinItsType('true', 'bool')); $this->assertSame(false, Utils::getValueWithinItsType('false', 'bool')); diff --git a/tests/Model/StructAttributeTest.php b/tests/Model/StructAttributeTest.php index 68b407d8..44322ac6 100755 --- a/tests/Model/StructAttributeTest.php +++ b/tests/Model/StructAttributeTest.php @@ -76,7 +76,7 @@ public function testStructAttributeTypeMustBeBool(): void $this->assertSame('boolean', $structAttribute->getType(true)); $this->assertSame('Success', $structAttribute->getType()); - $this->assertFalse($structAttribute->getDefaultValue()); + $this->assertFalse($structAttribute->getDefaultValue('boolean')); } public function testIsNullableMustReturnFalse(): void From 1c73fad0040996d70405add182c86abf43d0e99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Fri, 25 Aug 2023 21:43:09 +0200 Subject: [PATCH 03/12] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6215934..fe025b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 4.1.9 - 2023-08-25 +- issue #299, pr #301 - Deprecated Warnings for Dynamic Properties +- issue #300, pr #302 - Incorrect default value for integer attribute + ## 4.1.8 - 2023-04-20 - issue #285, pr #288 - Type-Error when using regex pattern for decimal restriction - issue #292, pr #293 - Wrong type for gYearMonth and gMonthDay From 207018aa632afa606a9fac594df0dfb61d8659ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Mon, 4 Sep 2023 20:58:35 +0200 Subject: [PATCH 04/12] issue #298 - use root namespace for predefined constants --- src/Generator/GeneratorSoapClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generator/GeneratorSoapClient.php b/src/Generator/GeneratorSoapClient.php index ef088dab..4269233e 100644 --- a/src/Generator/GeneratorSoapClient.php +++ b/src/Generator/GeneratorSoapClient.php @@ -19,10 +19,10 @@ public function __construct(Generator $generator) public function initSoapClient(): self { try { - $soapClient = new SoapClient($this->getSoapClientOptions(SOAP_1_1)); + $soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_1)); } catch (\SoapFault $fault) { try { - $soapClient = new SoapClient($this->getSoapClientOptions(SOAP_1_2)); + $soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_2)); } catch (\SoapFault $fault) { throw new \InvalidArgumentException(sprintf('Unable to load WSDL at "%s"!', $this->getGenerator()->getOptionOrigin()), __LINE__, $fault); } From 4dcf78015be4cf49e196e1c5fd6eb9133696946b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Mon, 11 Sep 2023 22:06:03 +0200 Subject: [PATCH 05/12] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe025b1c..4837a845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 4.1.10 - 2023-09-11 +- issue #298, pr #303 - Undefined constant "WsdlToPhp\PackageGenerator\Generator\SOAP_1_1" + ## 4.1.9 - 2023-08-25 - issue #299, pr #301 - Deprecated Warnings for Dynamic Properties - issue #300, pr #302 - Incorrect default value for integer attribute From 43b58005567707a0836e251f0e5de063dd8b216f Mon Sep 17 00:00:00 2001 From: Paul Melekhov Date: Wed, 18 Oct 2023 11:19:01 +0400 Subject: [PATCH 06/12] Fixed a bug in composer.json when trying to override default options like required php version (#305) --- src/File/Composer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/File/Composer.php b/src/File/Composer.php index dfc1d734..408153fc 100644 --- a/src/File/Composer.php +++ b/src/File/Composer.php @@ -91,7 +91,7 @@ protected function addAutoloadToComposerJson(array &$content): Composer protected function addComposerSettings(array &$content): Composer { - $content = array_merge_recursive($content, $this->getGenerator()->getOptionComposerSettings()); + $content = array_replace_recursive($content, $this->getGenerator()->getOptionComposerSettings()); return $this; } From 3b05c17117414b9dfe3aa8df90c4d8e21ed4772c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Wed, 18 Oct 2023 09:39:30 +0200 Subject: [PATCH 07/12] update contributors --- README.md | 1 + composer.json | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 497d9b13..ebfedc66 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ Developers who helped on this project are listed in the [composer.json](composer - [Arnaud POINTET](https://github.com/Oipnet) - [dypa](https://github.com/dypa) - [tbreuss](https://github.com/tbreuss) +- [Paul Melekhov](https://github.com/gugglegum) ## FAQ diff --git a/composer.json b/composer.json index bbbe6611..f189bc84 100644 --- a/composer.json +++ b/composer.json @@ -89,9 +89,14 @@ "role": "Contributor" }, { - "name": "tbreuss", - "email": "thomasbreuss@gmx.ch", + "name": "gugglegum", + "email": "gugglegum@gmail.com", "role": "Contributor" + }, + { + "name": "tbreuss", + "email": "thomasbreuss@gmx.ch", + "role": "Contributor" } ], "support" : { From 46a4d6faef6fc1e3dbff51dfa49936cf2a6b0a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Wed, 18 Oct 2023 21:10:52 +0200 Subject: [PATCH 08/12] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4837a845..5f44c0f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 4.1.11 - 2023-10-18 +- issue #304, pr #305 - Override required PHP version in composer.json + ## 4.1.10 - 2023-09-11 - issue #298, pr #303 - Undefined constant "WsdlToPhp\PackageGenerator\Generator\SOAP_1_1" From b36736dc6ce1002edcaf872f89724d1887914bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Kr=C3=A1tk=C3=BD?= <33813757+AlexKratky@users.noreply.github.com> Date: Fri, 12 Apr 2024 19:21:18 +0200 Subject: [PATCH 09/12] added support for symfony 7 (#309) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f189bc84..f9d395a6 100644 --- a/composer.json +++ b/composer.json @@ -110,8 +110,8 @@ "ext-mbstring": "*", "ext-soap": "*", "composer/composer": "^2.0", - "symfony/console": "^4.0|^5.0|^6.0", - "symfony/yaml": "^4.0|^5.0|^6.0", + "symfony/console": "^4.0|^5.0|^6.0|^7.0", + "symfony/yaml": "^4.0|^5.0|^6.0|^7.0", "wsdltophp/packagebase": "^5.0", "wsdltophp/phpgenerator": "^4.0", "wsdltophp/wsdlhandler": "^1.0" From d1321a0e17c30656549b274802827ca591db3e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Sat, 13 Apr 2024 06:34:56 +0200 Subject: [PATCH 10/12] Update changelog, readme and composer contributors list --- CHANGELOG.md | 3 +++ README.md | 1 + composer.json | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f44c0f0..c889df39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 4.1.12 - 2024-04-13 +- issue #308, pr #309 - Symfony 7 / added support for symfony 7 + ## 4.1.11 - 2023-10-18 - issue #304, pr #305 - Override required PHP version in composer.json diff --git a/README.md b/README.md index ebfedc66..8d38a46c 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,7 @@ Developers who helped on this project are listed in the [composer.json](composer - [dypa](https://github.com/dypa) - [tbreuss](https://github.com/tbreuss) - [Paul Melekhov](https://github.com/gugglegum) +- [Alex Krátký](https://github.com/AlexKratky) ## FAQ diff --git a/composer.json b/composer.json index f9d395a6..b8325ccd 100644 --- a/composer.json +++ b/composer.json @@ -97,6 +97,10 @@ "name": "tbreuss", "email": "thomasbreuss@gmx.ch", "role": "Contributor" + }, + { + "name": "Alex Krátký", + "role": "Contributor" } ], "support" : { From b37daa9e10b36e167c64045467dda0faff628556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Fri, 21 Jun 2024 06:07:08 +0200 Subject: [PATCH 11/12] issue #312 - Fix getter return type (#313) --- src/File/AbstractModelFile.php | 13 ++++++++++-- src/File/Struct.php | 21 +++++++++---------- src/File/StructArray.php | 10 ++++----- tests/resources/generated/ValidBannerInfo.php | 20 +++++++++--------- .../generated/ValidHouseProfileData.php | 4 ++-- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/File/AbstractModelFile.php b/src/File/AbstractModelFile.php index 635e8c53..a83b5299 100644 --- a/src/File/AbstractModelFile.php +++ b/src/File/AbstractModelFile.php @@ -400,7 +400,12 @@ protected function getStructAttributeTypeGetAnnotation(StructAttributeModel $att return '\\DOMDocument|string|null'; } - return sprintf('%s%s%s', $this->getStructAttributeTypeAsPhpType($attribute, false), $this->useBrackets($attribute, $returnArrayType) ? '[]' : '', !$nullableItemType && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null'); + return sprintf( + '%s%s%s', + $this->getStructAttributeTypeAsPhpType($attribute, false), + $this->useBrackets($attribute, $returnArrayType) ? '[]' : '', + !$nullableItemType && !$attribute->isNullable() && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null' + ); } protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $attribute, bool $returnArrayType = true, bool $itemType = false): string @@ -413,7 +418,11 @@ protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $att return 'array|string'; } - return sprintf('%s%s', $this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType), $this->useBrackets($attribute, !$itemType) ? '[]' : ''); + return sprintf( + '%s%s', + $this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType), + $this->useBrackets($attribute, !$itemType) ? '[]' : '' + ); } protected function useBrackets(StructAttributeModel $attribute, bool $returnArrayType = true): bool diff --git a/src/File/Struct.php b/src/File/Struct.php index 226c1d32..a035ca6c 100644 --- a/src/File/Struct.php +++ b/src/File/Struct.php @@ -347,17 +347,16 @@ protected function addStructMethodGetBodyReturn(PhpMethod $method, StructAttribu protected function addStructMethodGet(StructAttributeModel $attribute): self { - switch (true) { - // it can either be a string, a DOMDocument or null... - case $attribute->isXml(): - $returnType = ''; - - break; - - default: - $returnType = (!$attribute->getRemovableFromRequest() && !$attribute->isAChoice() && $attribute->isRequired() ? '' : '?').$this->getStructAttributeTypeAsPhpType($attribute); - - break; + // it can either be a string, a DOMDocument or null... + if ($attribute->isXml()) { + $returnType = ''; + } else { + $returnType = ( + !$attribute->getRemovableFromRequest() + && !$attribute->isAChoice() + && $attribute->isRequired() + && !$attribute->isNullable() ? '' : '?' + ).$this->getStructAttributeTypeAsPhpType($attribute); } $method = new PhpMethod( diff --git a/src/File/StructArray.php b/src/File/StructArray.php index 9893cc37..a867db33 100644 --- a/src/File/StructArray.php +++ b/src/File/StructArray.php @@ -40,11 +40,6 @@ public function addStructMethodsSetAndGet(): self return $this; } - protected function addClassElement(): AbstractModelFile - { - return AbstractModelFile::addClassElement(); - } - public function setModel(AbstractModel $model): self { if ($model instanceof StructModel && !$model->isArray()) { @@ -54,6 +49,11 @@ public function setModel(AbstractModel $model): self return parent::setModel($model); } + protected function addClassElement(): AbstractModelFile + { + return AbstractModelFile::addClassElement(); + } + /** * Disable this feature within StructArray class. */ diff --git a/tests/resources/generated/ValidBannerInfo.php b/tests/resources/generated/ValidBannerInfo.php index 1d6c7b09..c8b79821 100644 --- a/tests/resources/generated/ValidBannerInfo.php +++ b/tests/resources/generated/ValidBannerInfo.php @@ -79,7 +79,7 @@ class ApiBannerInfo extends AbstractStructBase * - base: soapenc:Array * - nillable: true * - ref: soapenc:arrayType - * @var \StructType\ApiBannerPhraseInfo[] + * @var \StructType\ApiBannerPhraseInfo[]|null */ protected ?array $Phrases = null; /** @@ -89,7 +89,7 @@ class ApiBannerInfo extends AbstractStructBase * - base: soapenc:Array * - nillable: true * - ref: soapenc:arrayType - * @var string[] + * @var string[]|null */ protected ?array $MinusKeywords = null; /** @@ -155,7 +155,7 @@ class ApiBannerInfo extends AbstractStructBase * - base: soapenc:Array * - nillable: true * - ref: soapenc:arrayType - * @var \StructType\ApiSitelink[] + * @var \StructType\ApiSitelink[]|null */ protected ?array $Sitelinks = null; /** @@ -165,7 +165,7 @@ class ApiBannerInfo extends AbstractStructBase * - base: soapenc:Array * - nillable: true * - ref: soapenc:arrayType - * @var string[] + * @var string[]|null */ protected ?array $AdWarnings = null; /** @@ -182,7 +182,7 @@ class ApiBannerInfo extends AbstractStructBase * - base: soapenc:Array * - nillable: true * - ref: soapenc:arrayType - * @var \StructType\ApiRejectReason[] + * @var \StructType\ApiRejectReason[]|null */ protected ?array $ModerateRejectionReasons = null; /** @@ -520,7 +520,7 @@ public function setGeo(?string $geo = null): self } /** * Get Phrases value - * @return \StructType\ApiBannerPhraseInfo[] + * @return \StructType\ApiBannerPhraseInfo[]|null */ public function getPhrases(): ?array { @@ -587,7 +587,7 @@ public function addToPhrases(\StructType\ApiBannerPhraseInfo $item): self } /** * Get MinusKeywords value - * @return string[] + * @return string[]|null */ public function getMinusKeywords(): ?array { @@ -838,7 +838,7 @@ public function setStatusSitelinksModerate(?string $statusSitelinksModerate = nu } /** * Get Sitelinks value - * @return \StructType\ApiSitelink[] + * @return \StructType\ApiSitelink[]|null */ public function getSitelinks(): ?array { @@ -905,7 +905,7 @@ public function addToSitelinks(\StructType\ApiSitelink $item): self } /** * Get AdWarnings value - * @return string[] + * @return string[]|null */ public function getAdWarnings(): ?array { @@ -995,7 +995,7 @@ public function setFixedOnModeration(?string $fixedOnModeration = null): self } /** * Get ModerateRejectionReasons value - * @return \StructType\ApiRejectReason[] + * @return \StructType\ApiRejectReason[]|null */ public function getModerateRejectionReasons(): ?array { diff --git a/tests/resources/generated/ValidHouseProfileData.php b/tests/resources/generated/ValidHouseProfileData.php index 303769a3..edb0268e 100644 --- a/tests/resources/generated/ValidHouseProfileData.php +++ b/tests/resources/generated/ValidHouseProfileData.php @@ -372,7 +372,7 @@ class ApiHouseProfileData extends AbstractStructBase * - base: soap-enc:Array * - nillable: true * - ref: soap-enc:arrayType - * @var \StructType\ApiLift[] + * @var \StructType\ApiLift[]|null */ protected ?array $lifts = null; /** @@ -1691,7 +1691,7 @@ public function setGas_system(?\StructType\ApiGasSystem $gas_system = null): sel } /** * Get lifts value - * @return \StructType\ApiLift[] + * @return \StructType\ApiLift[]|null */ public function getLifts(): ?array { From 921175998123b4e034c80ba3ba410db63147fcc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20DELSOL?= Date: Fri, 21 Jun 2024 06:10:14 +0200 Subject: [PATCH 12/12] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c889df39..171cf45a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## 4.1.13 - 2024-06-21 +- issue #312, pr #313 - Invalid getter and annotation for nullable property + ## 4.1.12 - 2024-04-13 - issue #308, pr #309 - Symfony 7 / added support for symfony 7