Skip to content

Commit 25d6c0e

Browse files
authored
Merge branch 'WsdlToPhp:develop' into superbiche-patch-280
2 parents e014998 + f7f1d23 commit 25d6c0e

Some content is hidden

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

44 files changed

+123
-45
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# CHANGELOG
22

3+
## 4.1.13 - 2024-06-21
4+
- issue #312, pr #313 - Invalid getter and annotation for nullable property
5+
6+
## 4.1.12 - 2024-04-13
7+
- issue #308, pr #309 - Symfony 7 / added support for symfony 7
8+
9+
## 4.1.11 - 2023-10-18
10+
- issue #304, pr #305 - Override required PHP version in composer.json
11+
12+
## 4.1.10 - 2023-09-11
13+
- issue #298, pr #303 - Undefined constant "WsdlToPhp\PackageGenerator\Generator\SOAP_1_1"
14+
15+
## 4.1.9 - 2023-08-25
16+
- issue #299, pr #301 - Deprecated Warnings for Dynamic Properties
17+
- issue #300, pr #302 - Incorrect default value for integer attribute
18+
319
## 4.1.8 - 2023-04-20
420
- issue #285, pr #288 - Type-Error when using regex pattern for decimal restriction
521
- issue #292, pr #293 - Wrong type for gYearMonth and gMonthDay

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ Developers who helped on this project are listed in the [composer.json](composer
163163
- [Arnaud POINTET](https://github.com/Oipnet)
164164
- [dypa](https://github.com/dypa)
165165
- [tbreuss](https://github.com/tbreuss)
166+
- [Paul Melekhov](https://github.com/gugglegum)
167+
- [Alex Krátký](https://github.com/AlexKratky)
166168

167169
## FAQ
168170

composer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,18 @@
8989
"role": "Contributor"
9090
},
9191
{
92-
"name": "tbreuss",
93-
"email": "thomasbreuss@gmx.ch",
92+
"name": "gugglegum",
93+
"email": "gugglegum@gmail.com",
9494
"role": "Contributor"
95+
},
96+
{
97+
"name": "tbreuss",
98+
"email": "thomasbreuss@gmx.ch",
99+
"role": "Contributor"
100+
},
101+
{
102+
"name": "Alex Krátký",
103+
"role": "Contributor"
95104
}
96105
],
97106
"support" : {
@@ -105,8 +114,8 @@
105114
"ext-mbstring": "*",
106115
"ext-soap": "*",
107116
"composer/composer": "^2.0",
108-
"symfony/console": "^4.0|^5.0|^6.0",
109-
"symfony/yaml": "^4.0|^5.0|^6.0",
117+
"symfony/console": "^4.0|^5.0|^6.0|^7.0",
118+
"symfony/yaml": "^4.0|^5.0|^6.0|^7.0",
110119
"wsdltophp/packagebase": "^5.0",
111120
"wsdltophp/phpgenerator": "^4.0",
112121
"wsdltophp/wsdlhandler": "^1.0"

src/File/AbstractModelFile.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,12 @@ protected function getStructAttributeTypeGetAnnotation(StructAttributeModel $att
400400
return '\\DOMDocument|string|null';
401401
}
402402

403-
return sprintf('%s%s%s', $this->getStructAttributeTypeAsPhpType($attribute, false), $this->useBrackets($attribute, $returnArrayType) ? '[]' : '', !$nullableItemType && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null');
403+
return sprintf(
404+
'%s%s%s',
405+
$this->getStructAttributeTypeAsPhpType($attribute, false),
406+
$this->useBrackets($attribute, $returnArrayType) ? '[]' : '',
407+
!$nullableItemType && !$attribute->isNullable() && ($attribute->isRequired() || $attribute->isArray() || $attribute->isList()) ? '' : '|null'
408+
);
404409
}
405410

406411
protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $attribute, bool $returnArrayType = true, bool $itemType = false): string
@@ -413,7 +418,11 @@ protected function getStructAttributeTypeSetAnnotation(StructAttributeModel $att
413418
return 'array|string';
414419
}
415420

416-
return sprintf('%s%s', $this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType), $this->useBrackets($attribute, !$itemType) ? '[]' : '');
421+
return sprintf(
422+
'%s%s',
423+
$this->getStructAttributeTypeAsPhpType($attribute, $returnArrayType),
424+
$this->useBrackets($attribute, !$itemType) ? '[]' : ''
425+
);
417426
}
418427

419428
protected function useBrackets(StructAttributeModel $attribute, bool $returnArrayType = true): bool

src/File/Composer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function addAutoloadToComposerJson(array &$content): Composer
9191

9292
protected function addComposerSettings(array &$content): Composer
9393
{
94-
$content = array_merge_recursive($content, $this->getGenerator()->getOptionComposerSettings());
94+
$content = array_replace_recursive($content, $this->getGenerator()->getOptionComposerSettings());
9595

9696
return $this;
9797
}

src/File/Struct.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ public function getModel(): ?StructModel
4343
return parent::getModel();
4444
}
4545

46+
protected function addClassElement(): AbstractModelFile
47+
{
48+
$this->getFile()->addString('#[\AllowDynamicProperties]');
49+
50+
return parent::addClassElement();
51+
}
52+
4653
protected function defineUseStatements(): self
4754
{
4855
if ($this->getGenerator()->getOptionValidation()) {
49-
$this->getFile()->addUse(\InvalidArgumentException::class, null, false);
56+
$this->getFile()->addUse(\InvalidArgumentException::class);
5057
}
5158

5259
return parent::defineUseStatements();
@@ -175,7 +182,7 @@ protected function getStructMethodParameter(StructAttributeModel $attribute): Ph
175182
}
176183

177184
try {
178-
$defaultValue = $attribute->getDefaultValue();
185+
$defaultValue = $attribute->getDefaultValue($this->getStructAttributeTypeAsPhpType($attribute));
179186

180187
return new PhpFunctionParameter(
181188
lcfirst($attribute->getUniqueString($attribute->getCleanName(), 'method')),
@@ -340,17 +347,16 @@ protected function addStructMethodGetBodyReturn(PhpMethod $method, StructAttribu
340347

341348
protected function addStructMethodGet(StructAttributeModel $attribute): self
342349
{
343-
switch (true) {
344-
// it can either be a string, a DOMDocument or null...
345-
case $attribute->isXml():
346-
$returnType = '';
347-
348-
break;
349-
350-
default:
351-
$returnType = (!$attribute->getRemovableFromRequest() && !$attribute->isAChoice() && $attribute->isRequired() ? '' : '?').$this->getStructAttributeTypeAsPhpType($attribute);
352-
353-
break;
350+
// it can either be a string, a DOMDocument or null...
351+
if ($attribute->isXml()) {
352+
$returnType = '';
353+
} else {
354+
$returnType = (
355+
!$attribute->getRemovableFromRequest()
356+
&& !$attribute->isAChoice()
357+
&& $attribute->isRequired()
358+
&& !$attribute->isNullable() ? '' : '?'
359+
).$this->getStructAttributeTypeAsPhpType($attribute);
354360
}
355361

356362
$method = new PhpMethod(

src/File/StructArray.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public function setModel(AbstractModel $model): self
4949
return parent::setModel($model);
5050
}
5151

52+
protected function addClassElement(): AbstractModelFile
53+
{
54+
return AbstractModelFile::addClassElement();
55+
}
56+
5257
/**
5358
* Disable this feature within StructArray class.
5459
*/

src/File/StructEnum.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function setModel(AbstractModel $model): self
2727
return parent::setModel($model);
2828
}
2929

30+
protected function addClassElement(): AbstractModelFile
31+
{
32+
return AbstractModelFile::addClassElement();
33+
}
34+
3035
protected function fillClassConstants(ConstantContainer $constants): void
3136
{
3237
/** @var StructModel $model */

src/Generator/GeneratorSoapClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public function __construct(Generator $generator)
1919
public function initSoapClient(): self
2020
{
2121
try {
22-
$soapClient = new SoapClient($this->getSoapClientOptions(SOAP_1_1));
22+
$soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_1));
2323
} catch (\SoapFault $fault) {
2424
try {
25-
$soapClient = new SoapClient($this->getSoapClientOptions(SOAP_1_2));
25+
$soapClient = new SoapClient($this->getSoapClientOptions(\SOAP_1_2));
2626
} catch (\SoapFault $fault) {
2727
throw new \InvalidArgumentException(sprintf('Unable to load WSDL at "%s"!', $this->getGenerator()->getOptionOrigin()), __LINE__, $fault);
2828
}

src/Generator/Utils.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,17 @@ public static function getStreamContextOptions(?string $basicAuthLogin = null, ?
104104
public static function getValueWithinItsType($value, ?string $knownType = null)
105105
{
106106
if (is_int($value) || (!is_null($value) && in_array($knownType, [
107-
'time',
108-
'positiveInteger',
109-
'unsignedLong',
110-
'unsignedInt',
111-
'short',
112-
'long',
113107
'int',
114108
'integer',
115109
], true))) {
116-
return intval($value);
110+
return (int) $value;
117111
}
118112
if (is_float($value) || (!is_null($value) && in_array($knownType, [
119113
'float',
120114
'double',
121115
'decimal',
122116
], true))) {
123-
return floatval($value);
117+
return (float) $value;
124118
}
125119
if (is_bool($value) || (!is_null($value) && in_array($knownType, [
126120
'bool',

0 commit comments

Comments
 (0)