Skip to content

Commit d5ccb55

Browse files
committed
fix issue #341: update generated files based on new DomHandler release
1 parent 22d2cec commit d5ccb55

61 files changed

Lines changed: 15315 additions & 13915 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COMPOSER ?= /usr/bin/composer
44
DOCKER_COMPOSE ?= docker compose
55
DOCKER_EXEC_CONTAINER ?= docker exec -t $(CONTAINER_NAME)
66

7-
.PHONY: bash build cs-fixer down install phpstan phpunit rector up update
7+
.PHONY: bash build cs-fixer down install jsons phpstan phpunit rector up update
88

99
bash:
1010
$(DOCKER_EXEC_CONTAINER) bash
@@ -21,6 +21,9 @@ down:
2121
install:
2222
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) $(COMPOSER) install
2323

24+
jsons:
25+
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) tests/generate_serialized_jsons.php
26+
2427
phpstan:
2528
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpstan analyze src --level=2
2629

src/File/Struct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ protected function addStructMethodsSetAndGetAnnotationBlockFromStructAttribute(s
482482
switch ($setOrGet) {
483483
case 'set':
484484
if ($attribute->getRemovableFromRequest()) {
485-
$annotationBlock->addChild('This property is removable from request (nillable=true+minOccurs=0), therefore if the value assigned to this property is null, it is removed from this object');
485+
$annotationBlock->addChild('This property is removable from request (minOccurs=0), therefore if the value assigned to this property is null, it is removed from this object');
486486
}
487487
if ($attribute->isAChoice()) {
488488
$annotationBlock->addChild('This property belongs to a choice that allows only one property to exist. It is therefore removable from the request, consequently if the value assigned to this property is null, the property is removed from this object');
@@ -514,7 +514,7 @@ protected function addStructMethodsSetAndGetAnnotationBlockFromStructAttribute(s
514514

515515
case 'get':
516516
if ($attribute->getRemovableFromRequest()) {
517-
$annotationBlock->addChild('An additional test has been added (isset) before returning the property value as this property may have been unset before, due to the fact that this property is removable from the request (nillable=true+minOccurs=0)');
517+
$annotationBlock->addChild('An additional test has been added (isset) before returning the property value as this property may have been unset before, due to the fact that this property is removable from the request (minOccurs=0)');
518518
}
519519
$this
520520
->addStructMethodsGetAnnotationBlockFromXmlAttribute($annotationBlock, $attribute)

tests/Generator/GeneratorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ public function testJsonSerialize(): void
598598
$generator = self::getBingGeneratorInstance(true);
599599
$generator->setOptionStandalone(false);
600600
$generator->parse();
601+
602+
// uncomment the next line to easily regenerate file :)
603+
// file_put_contents(sprintf('%sjson_serialized.json', self::getTestDirectory()), trim(json_encode($generator, JSON_PRETTY_PRINT)));
604+
601605
$jsonContent = file_get_contents(sprintf('%sjson_serialized.json', self::getTestDirectory()));
602606
$jsonContent = str_replace([
603607
'"__ORIGIN__"',
@@ -606,6 +610,7 @@ public function testJsonSerialize(): void
606610
json_encode(self::wsdlBingPath(), JSON_THROW_ON_ERROR),
607611
json_encode($generator->getOptionDestination(), JSON_THROW_ON_ERROR),
608612
], $jsonContent);
613+
609614
$this->assertSame(trim($jsonContent), trim(json_encode($generator, JSON_PRETTY_PRINT)));
610615
}
611616

tests/Parser/Wsdl/TagElementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testParseBing(): void
4848
], $structs->getStructByName('SearchRequest')->getAttribute('Version')->getMeta());
4949
$this->assertSame('string', $structs->getStructByName('SearchRequest')->getAttribute('Version')->getType());
5050
$this->assertFalse($structs->getStructByName('SearchRequest')->getAttribute('Version')->getContainsElements());
51-
$this->assertFalse($structs->getStructByName('SearchRequest')->getAttribute('Version')->getRemovableFromRequest());
51+
$this->assertTrue($structs->getStructByName('SearchRequest')->getAttribute('Version')->getRemovableFromRequest());
5252
++$count;
5353
}
5454
if ($structs->getStructByName('ArrayOfNewsRelatedSearch') instanceof Struct) {
@@ -58,7 +58,7 @@ public function testParseBing(): void
5858
], $structs->getStructByName('ArrayOfNewsRelatedSearch')->getAttribute('NewsRelatedSearch')->getMeta());
5959
$this->assertSame('NewsRelatedSearch', $structs->getStructByName('ArrayOfNewsRelatedSearch')->getAttribute('NewsRelatedSearch')->getType());
6060
$this->assertTrue($structs->getStructByName('ArrayOfNewsRelatedSearch')->getAttribute('NewsRelatedSearch')->getContainsElements());
61-
$this->assertFalse($structs->getStructByName('ArrayOfNewsRelatedSearch')->getAttribute('NewsRelatedSearch')->getRemovableFromRequest());
61+
$this->assertTrue($structs->getStructByName('ArrayOfNewsRelatedSearch')->getAttribute('NewsRelatedSearch')->getRemovableFromRequest());
6262
++$count;
6363
}
6464
}

tests/resources/generated/ValidAdGroupsSelectionCriteria.php

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ public function __construct(?array $campaignIds = null, ?array $ids = null, ?arr
102102
}
103103
/**
104104
* Get CampaignIds value
105+
* An additional test has been added (isset) before returning the property value as
106+
* this property may have been unset before, due to the fact that this property is
107+
* removable from the request (minOccurs=0)
105108
* @return int[]
106109
*/
107110
public function getCampaignIds(): ?array
108111
{
109-
return $this->CampaignIds;
112+
return $this->CampaignIds ?? null;
110113
}
111114
/**
112115
* This method is responsible for validating the value(s) passed to the setCampaignIds method
@@ -137,6 +140,8 @@ public static function validateCampaignIdsForArrayConstraintFromSetCampaignIds(?
137140
}
138141
/**
139142
* Set CampaignIds value
143+
* This property is removable from request (minOccurs=0), therefore if the value
144+
* assigned to this property is null, it is removed from this object
140145
* @throws InvalidArgumentException
141146
* @param int[] $campaignIds
142147
* @return \StructType\ApiAdGroupsSelectionCriteria
@@ -147,7 +152,11 @@ public function setCampaignIds(?array $campaignIds = null): self
147152
if ('' !== ($campaignIdsArrayErrorMessage = self::validateCampaignIdsForArrayConstraintFromSetCampaignIds($campaignIds))) {
148153
throw new InvalidArgumentException($campaignIdsArrayErrorMessage, __LINE__);
149154
}
150-
$this->CampaignIds = $campaignIds;
155+
if (is_null($campaignIds) || (is_array($campaignIds) && empty($campaignIds))) {
156+
unset($this->CampaignIds);
157+
} else {
158+
$this->CampaignIds = $campaignIds;
159+
}
151160

152161
return $this;
153162
}
@@ -169,11 +178,14 @@ public function addToCampaignIds(int $item): self
169178
}
170179
/**
171180
* Get Ids value
181+
* An additional test has been added (isset) before returning the property value as
182+
* this property may have been unset before, due to the fact that this property is
183+
* removable from the request (minOccurs=0)
172184
* @return int[]
173185
*/
174186
public function getIds(): ?array
175187
{
176-
return $this->Ids;
188+
return $this->Ids ?? null;
177189
}
178190
/**
179191
* This method is responsible for validating the value(s) passed to the setIds method
@@ -204,6 +216,8 @@ public static function validateIdsForArrayConstraintFromSetIds(?array $values =
204216
}
205217
/**
206218
* Set Ids value
219+
* This property is removable from request (minOccurs=0), therefore if the value
220+
* assigned to this property is null, it is removed from this object
207221
* @throws InvalidArgumentException
208222
* @param int[] $ids
209223
* @return \StructType\ApiAdGroupsSelectionCriteria
@@ -214,7 +228,11 @@ public function setIds(?array $ids = null): self
214228
if ('' !== ($idsArrayErrorMessage = self::validateIdsForArrayConstraintFromSetIds($ids))) {
215229
throw new InvalidArgumentException($idsArrayErrorMessage, __LINE__);
216230
}
217-
$this->Ids = $ids;
231+
if (is_null($ids) || (is_array($ids) && empty($ids))) {
232+
unset($this->Ids);
233+
} else {
234+
$this->Ids = $ids;
235+
}
218236

219237
return $this;
220238
}
@@ -236,11 +254,14 @@ public function addToIds(int $item): self
236254
}
237255
/**
238256
* Get Types value
257+
* An additional test has been added (isset) before returning the property value as
258+
* this property may have been unset before, due to the fact that this property is
259+
* removable from the request (minOccurs=0)
239260
* @return string[]
240261
*/
241262
public function getTypes(): ?array
242263
{
243-
return $this->Types;
264+
return $this->Types ?? null;
244265
}
245266
/**
246267
* This method is responsible for validating the value(s) passed to the setTypes method
@@ -271,6 +292,8 @@ public static function validateTypesForArrayConstraintFromSetTypes(?array $value
271292
}
272293
/**
273294
* Set Types value
295+
* This property is removable from request (minOccurs=0), therefore if the value
296+
* assigned to this property is null, it is removed from this object
274297
* @uses \EnumType\ApiAdGroupTypesEnum::valueIsValid()
275298
* @uses \EnumType\ApiAdGroupTypesEnum::getValidValues()
276299
* @throws InvalidArgumentException
@@ -283,7 +306,11 @@ public function setTypes(?array $types = null): self
283306
if ('' !== ($typesArrayErrorMessage = self::validateTypesForArrayConstraintFromSetTypes($types))) {
284307
throw new InvalidArgumentException($typesArrayErrorMessage, __LINE__);
285308
}
286-
$this->Types = $types;
309+
if (is_null($types) || (is_array($types) && empty($types))) {
310+
unset($this->Types);
311+
} else {
312+
$this->Types = $types;
313+
}
287314

288315
return $this;
289316
}
@@ -307,11 +334,14 @@ public function addToTypes(string $item): self
307334
}
308335
/**
309336
* Get Statuses value
337+
* An additional test has been added (isset) before returning the property value as
338+
* this property may have been unset before, due to the fact that this property is
339+
* removable from the request (minOccurs=0)
310340
* @return string[]
311341
*/
312342
public function getStatuses(): ?array
313343
{
314-
return $this->Statuses;
344+
return $this->Statuses ?? null;
315345
}
316346
/**
317347
* This method is responsible for validating the value(s) passed to the setStatuses method
@@ -342,6 +372,8 @@ public static function validateStatusesForArrayConstraintFromSetStatuses(?array
342372
}
343373
/**
344374
* Set Statuses value
375+
* This property is removable from request (minOccurs=0), therefore if the value
376+
* assigned to this property is null, it is removed from this object
345377
* @uses \EnumType\ApiStatusSelectionEnum::valueIsValid()
346378
* @uses \EnumType\ApiStatusSelectionEnum::getValidValues()
347379
* @throws InvalidArgumentException
@@ -354,7 +386,11 @@ public function setStatuses(?array $statuses = null): self
354386
if ('' !== ($statusesArrayErrorMessage = self::validateStatusesForArrayConstraintFromSetStatuses($statuses))) {
355387
throw new InvalidArgumentException($statusesArrayErrorMessage, __LINE__);
356388
}
357-
$this->Statuses = $statuses;
389+
if (is_null($statuses) || (is_array($statuses) && empty($statuses))) {
390+
unset($this->Statuses);
391+
} else {
392+
$this->Statuses = $statuses;
393+
}
358394

359395
return $this;
360396
}
@@ -378,11 +414,14 @@ public function addToStatuses(string $item): self
378414
}
379415
/**
380416
* Get TagIds value
417+
* An additional test has been added (isset) before returning the property value as
418+
* this property may have been unset before, due to the fact that this property is
419+
* removable from the request (minOccurs=0)
381420
* @return int[]
382421
*/
383422
public function getTagIds(): ?array
384423
{
385-
return $this->TagIds;
424+
return $this->TagIds ?? null;
386425
}
387426
/**
388427
* This method is responsible for validating the value(s) passed to the setTagIds method
@@ -413,6 +452,8 @@ public static function validateTagIdsForArrayConstraintFromSetTagIds(?array $val
413452
}
414453
/**
415454
* Set TagIds value
455+
* This property is removable from request (minOccurs=0), therefore if the value
456+
* assigned to this property is null, it is removed from this object
416457
* @throws InvalidArgumentException
417458
* @param int[] $tagIds
418459
* @return \StructType\ApiAdGroupsSelectionCriteria
@@ -423,7 +464,11 @@ public function setTagIds(?array $tagIds = null): self
423464
if ('' !== ($tagIdsArrayErrorMessage = self::validateTagIdsForArrayConstraintFromSetTagIds($tagIds))) {
424465
throw new InvalidArgumentException($tagIdsArrayErrorMessage, __LINE__);
425466
}
426-
$this->TagIds = $tagIds;
467+
if (is_null($tagIds) || (is_array($tagIds) && empty($tagIds))) {
468+
unset($this->TagIds);
469+
} else {
470+
$this->TagIds = $tagIds;
471+
}
427472

428473
return $this;
429474
}
@@ -445,11 +490,14 @@ public function addToTagIds(int $item): self
445490
}
446491
/**
447492
* Get Tags value
493+
* An additional test has been added (isset) before returning the property value as
494+
* this property may have been unset before, due to the fact that this property is
495+
* removable from the request (minOccurs=0)
448496
* @return string[]
449497
*/
450498
public function getTags(): ?array
451499
{
452-
return $this->Tags;
500+
return $this->Tags ?? null;
453501
}
454502
/**
455503
* This method is responsible for validating the value(s) passed to the setTags method
@@ -480,6 +528,8 @@ public static function validateTagsForArrayConstraintFromSetTags(?array $values
480528
}
481529
/**
482530
* Set Tags value
531+
* This property is removable from request (minOccurs=0), therefore if the value
532+
* assigned to this property is null, it is removed from this object
483533
* @throws InvalidArgumentException
484534
* @param string[] $tags
485535
* @return \StructType\ApiAdGroupsSelectionCriteria
@@ -490,7 +540,11 @@ public function setTags(?array $tags = null): self
490540
if ('' !== ($tagsArrayErrorMessage = self::validateTagsForArrayConstraintFromSetTags($tags))) {
491541
throw new InvalidArgumentException($tagsArrayErrorMessage, __LINE__);
492542
}
493-
$this->Tags = $tags;
543+
if (is_null($tags) || (is_array($tags) && empty($tags))) {
544+
unset($this->Tags);
545+
} else {
546+
$this->Tags = $tags;
547+
}
494548

495549
return $this;
496550
}
@@ -512,11 +566,14 @@ public function addToTags(string $item): self
512566
}
513567
/**
514568
* Get AppIconStatuses value
569+
* An additional test has been added (isset) before returning the property value as
570+
* this property may have been unset before, due to the fact that this property is
571+
* removable from the request (minOccurs=0)
515572
* @return string[]
516573
*/
517574
public function getAppIconStatuses(): ?array
518575
{
519-
return $this->AppIconStatuses;
576+
return $this->AppIconStatuses ?? null;
520577
}
521578
/**
522579
* This method is responsible for validating the value(s) passed to the setAppIconStatuses method
@@ -547,6 +604,8 @@ public static function validateAppIconStatusesForArrayConstraintFromSetAppIconSt
547604
}
548605
/**
549606
* Set AppIconStatuses value
607+
* This property is removable from request (minOccurs=0), therefore if the value
608+
* assigned to this property is null, it is removed from this object
550609
* @uses \EnumType\ApiStatusSelectionEnum::valueIsValid()
551610
* @uses \EnumType\ApiStatusSelectionEnum::getValidValues()
552611
* @throws InvalidArgumentException
@@ -559,7 +618,11 @@ public function setAppIconStatuses(?array $appIconStatuses = null): self
559618
if ('' !== ($appIconStatusesArrayErrorMessage = self::validateAppIconStatusesForArrayConstraintFromSetAppIconStatuses($appIconStatuses))) {
560619
throw new InvalidArgumentException($appIconStatusesArrayErrorMessage, __LINE__);
561620
}
562-
$this->AppIconStatuses = $appIconStatuses;
621+
if (is_null($appIconStatuses) || (is_array($appIconStatuses) && empty($appIconStatuses))) {
622+
unset($this->AppIconStatuses);
623+
} else {
624+
$this->AppIconStatuses = $appIconStatuses;
625+
}
563626

564627
return $this;
565628
}

0 commit comments

Comments
 (0)