Skip to content

Commit b3b9f88

Browse files
authored
issue #268 - Fix element contained by a sequence with maxOccurs > 1
1 parent b852688 commit b3b9f88

File tree

18 files changed

+271
-7
lines changed

18 files changed

+271
-7
lines changed

src/ConfigurationReader/GeneratorOptions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ protected function __construct(string $filename)
133133
$this->parseOptions($filename);
134134
}
135135

136-
public static function instance(?string $filename = null): self
137-
{
138-
return parent::instance($filename);
139-
}
140-
141136
public function __call($name, $arguments)
142137
{
143138
if ('set' === substr($name, 0, 3) && 1 === count($arguments)) {
@@ -150,6 +145,11 @@ public function __call($name, $arguments)
150145
throw new \BadMethodCallException(sprintf('Method %s undefined', $name));
151146
}
152147

148+
public static function instance(?string $filename = null): self
149+
{
150+
return parent::instance($filename);
151+
}
152+
153153
public function getOptionValue(string $optionName)
154154
{
155155
if (!array_key_exists($optionName, $this->options)) {

src/ConfigurationReader/XsdTypes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ final class XsdTypes extends AbstractYamlReader
88
{
99
public const MAIN_KEY = 'xsd_types';
1010
public const ANONYMOUS_KEY = 'anonymous';
11+
1112
/**
1213
* This type is returned by the \SoapClient class when
1314
* it does not succeed to define the type of a struct or an attribute.

src/Container/Model/Service.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function getServiceByName(string $name): ?Model
3737
public function getMethods(): Method
3838
{
3939
$methods = new Method($this->generator);
40+
4041
/** @var Model $service */
4142
foreach ($this->objects as $service) {
4243
foreach ($service->getMethods() as $method) {

src/File/Struct.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ protected function getStructMethodsSetAndGetAnnotationBlock(PhpMethod $method):
454454
} else {
455455
$parameterName = mb_substr($method->getName(), 3);
456456
}
457+
457458
/**
458459
* Since properties can be duplicated with different case, we assume that _\d+ is replaceable by an empty string as methods are "duplicated" with this suffix.
459460
*/
@@ -607,6 +608,7 @@ protected function addStructPropertiesToAnnotationBlockParams(PhpAnnotationBlock
607608
protected function getStructMethodsAddToAnnotationBlock(PhpMethod $method): PhpAnnotationBlock
608609
{
609610
$methodParameters = $method->getParameters();
611+
610612
/** @var PhpFunctionParameter $firstParameter */
611613
$firstParameter = array_shift($methodParameters);
612614
$attribute = $this->getModel()->getAttribute($firstParameter->getModel()->getName());

src/File/StructArray.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected function addArrayMethodGetAttributeName(): self
9090
{
9191
/** @var StructModel $model */
9292
$model = $this->getModel();
93+
9394
return $this->addArrayMethodGenericMethod(
9495
self::METHOD_GET_ATTRIBUTE_NAME,
9596
sprintf(
@@ -146,6 +147,7 @@ protected function getArrayMethodGetAttributeNameAnnotationBlock(): PhpAnnotatio
146147
{
147148
/** @var StructModel $model */
148149
$model = $this->getModel();
150+
149151
return new PhpAnnotationBlock([
150152
'Returns the attribute name',
151153
new PhpAnnotation(self::ANNOTATION_SEE, sprintf('%s::%s()', $model->getExtends(true), self::METHOD_GET_ATTRIBUTE_NAME)),

src/File/StructEnum.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ protected function getConstantAnnotationBlock(PhpConstant $constant): ?PhpAnnota
4747
$block = new PhpAnnotationBlock([
4848
sprintf('Constant for value \'%s\'', $constant->getValue()),
4949
]);
50+
5051
/** @var StructModel $model */
5152
$model = $this->getModel();
5253
if (($value = $model->getValue($constant->getValue())) instanceof StructValueModel) {
@@ -92,6 +93,7 @@ protected function getEnumMethodGetValidValues(): PhpMethod
9293
protected function getEnumMethodValues(): array
9394
{
9495
$values = [];
96+
9597
/** @var StructModel $model */
9698
$model = $this->getModel();
9799
foreach ($model->getValues() as $value) {

src/Parser/SoapClient/Functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function parse(): void
4646
$infos = explode(' ', preg_replace('/(list\(.*\)\s)/i', '', $method));
4747
array_unshift($infos, 'array');
4848
}
49+
4950
/**
5051
* Returns type is not defined in some case.
5152
*/

src/Parser/Wsdl/TagElement.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use WsdlToPhp\PackageGenerator\Model\AbstractModel;
88
use WsdlToPhp\PackageGenerator\Model\StructAttribute;
9+
use WsdlToPhp\WsdlHandler\AbstractDocument;
910
use WsdlToPhp\WsdlHandler\Tag\AbstractTag as Tag;
11+
use WsdlToPhp\WsdlHandler\Tag\TagSequence;
1012
use WsdlToPhp\WsdlHandler\Wsdl as WsdlDocument;
1113

1214
final class TagElement extends AbstractAttributesParser
@@ -25,6 +27,11 @@ protected function parseTagAttributes(Tag $tag, AbstractModel $model = null, Str
2527
->setContainsElements($tag->canOccurSeveralTimes())
2628
->setRemovableFromRequest($tag->isRemovable())
2729
;
30+
31+
$sequence = $tag->getSuitableParent(false, [AbstractDocument::TAG_SEQUENCE]);
32+
if ($sequence instanceof TagSequence && $sequence->canOccurSeveralTimes()) {
33+
$structAttribute->setContainsElements();
34+
}
2835
}
2936
}
3037
}

src/Parser/Wsdl/TagRestriction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected function parseRestrictionAttributes(AbstractModel $model, Restriction
8080
if ($restriction->hasAttributes()) {
8181
// ensure inheritance of model is well-defined, SoapClient parser is based on SoapClient::__getTypes which can be false in some case
8282
$model->setInheritance($restriction->getAttributeBase());
83+
8384
/** @var AbstractAttributeHandler $attribute */
8485
foreach ($restriction->getAttributes() as $attribute) {
8586
$model->addMeta($attribute->getName(), $attribute->getValue(true));

tests/File/StructTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,21 @@ public function testStructResultFromUnitTestsWithBooleanAttribute()
481481
}
482482
}
483483

484+
public function testStructValueListTypeFromUnitTests()
485+
{
486+
$generator = self::unitTestsInstance();
487+
if (($model = $generator->getStructByName('ValueListType')) instanceof StructModel) {
488+
$struct = new StructFile($generator, $model->getName());
489+
$struct
490+
->setModel($model)
491+
->write()
492+
;
493+
$this->assertSameFileContent('ValidUnitTestsValueListType', $struct);
494+
} else {
495+
$this->fail('Unable to find ValueListType struct for file generation');
496+
}
497+
}
498+
484499
public function testWriteDeliveryDetails()
485500
{
486501
$generator = self::deliveryServiceInstance();

0 commit comments

Comments
 (0)