Skip to content

Commit 870a576

Browse files
committed
Merge branch 'release/4.1.4'
2 parents a4210e6 + 8f3b40c commit 870a576

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

CHANGELOG.md

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

3+
## 4.1.4 - 2022-02-12
4+
- issue #265 - Use statement for InvalidArgumentException is missing when needed in ServiceType class
5+
36
## 4.1.3 - 2022-02-11
47
- issue #264 - Wrong PHPDoc @param name and description
58

src/File/Service.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use WsdlToPhp\PackageGenerator\File\Validation\Rules;
1414
use WsdlToPhp\PackageGenerator\Generator\Generator;
1515
use WsdlToPhp\PackageGenerator\Model\AbstractModel;
16+
use WsdlToPhp\PackageGenerator\Model\Method;
1617
use WsdlToPhp\PackageGenerator\Model\Method as MethodModel;
1718
use WsdlToPhp\PackageGenerator\Model\Service as ServiceModel;
1819
use WsdlToPhp\PackageGenerator\Model\Struct as StructModel;
@@ -95,6 +96,27 @@ protected function defineUseStatements(): AbstractModelFile
9596
{
9697
$this->getFile()->addUse(SoapFault::class);
9798

99+
/** @var Method $method */
100+
foreach ($this->getModel()->getMethods() as $method) {
101+
$soapHeaderTypes = $method->getMetaValue(TagHeader::META_SOAP_HEADER_TYPES, []);
102+
if (!is_array($soapHeaderTypes)) {
103+
continue;
104+
}
105+
foreach ($soapHeaderTypes as $soapHeaderType) {
106+
$model = $this->getModelByName($soapHeaderType);
107+
if (!$model instanceof StructModel) {
108+
continue;
109+
}
110+
if (!$model->isRestriction()) {
111+
continue;
112+
}
113+
114+
$this->getFile()->addUse(InvalidArgumentException::class);
115+
116+
break 2;
117+
}
118+
}
119+
98120
return parent::defineUseStatements();
99121
}
100122

@@ -242,7 +264,7 @@ protected function addAnnotationBlockForSoapHeaderMethod(PhpAnnotationBlock $ann
242264
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', $firstParameterType, $firstParameter->getName())))
243265
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_NAMESPACE)))
244266
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_BOOL, self::PARAM_SET_HEADER_MUSTUNDERSTAND)))
245-
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_ACTOR)))
267+
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s|null $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_ACTOR)))
246268
->addChild(new PhpAnnotation(self::ANNOTATION_RETURN, $this->getModel()->getPackagedName(true)))
247269
;
248270
}

tests/resources/generated/ValidActonApiService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ApiService extends AbstractSoapClientBase
2121
* @param \StructType\ApiClusterHeader $clusterHeader
2222
* @param string $namespace
2323
* @param bool $mustUnderstand
24-
* @param string $actor
24+
* @param string|null $actor
2525
* @return \ServiceType\ApiService
2626
*/
2727
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
@@ -34,7 +34,7 @@ public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $cluster
3434
* @param \StructType\ApiSessionHeader $sessionHeader
3535
* @param string $namespace
3636
* @param bool $mustUnderstand
37-
* @param string $actor
37+
* @param string|null $actor
3838
* @return \ServiceType\ApiService
3939
*/
4040
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self

tests/resources/generated/ValidApiDelete.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ApiDelete extends AbstractSoapClientBase
2121
* @param \StructType\ApiSessionHeader $sessionHeader
2222
* @param string $namespace
2323
* @param bool $mustUnderstand
24-
* @param string $actor
24+
* @param string|null $actor
2525
* @return \ServiceType\ApiDelete
2626
*/
2727
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
@@ -34,7 +34,7 @@ public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $session
3434
* @param \StructType\ApiClusterHeader $clusterHeader
3535
* @param string $namespace
3636
* @param bool $mustUnderstand
37-
* @param string $actor
37+
* @param string|null $actor
3838
* @return \ServiceType\ApiDelete
3939
*/
4040
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self

tests/resources/generated/ValidApiDo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ApiDo extends AbstractSoapClientBase
2121
* @param \StructType\ApiCustomSecurityHeaderType $requesterCredentials
2222
* @param string $namespace
2323
* @param bool $mustUnderstand
24-
* @param string $actor
24+
* @param string|null $actor
2525
* @return \ServiceType\ApiDo
2626
*/
2727
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self

tests/resources/generated/ValidApiFind.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace ServiceType;
66

77
use SoapFault;
8+
use InvalidArgumentException;
89
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
910

1011
/**
@@ -21,7 +22,7 @@ class ApiFind extends AbstractSoapClientBase
2122
* @param \StructType\ApiExchangeImpersonationType $exchangeImpersonation
2223
* @param string $namespace
2324
* @param bool $mustUnderstand
24-
* @param string $actor
25+
* @param string|null $actor
2526
* @return \ServiceType\ApiFind
2627
*/
2728
public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpersonationType $exchangeImpersonation, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
@@ -34,7 +35,7 @@ public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpers
3435
* @param \StructType\ApiMailboxCultureType $mailboxCulture
3536
* @param string $namespace
3637
* @param bool $mustUnderstand
37-
* @param string $actor
38+
* @param string|null $actor
3839
* @return \ServiceType\ApiFind
3940
*/
4041
public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $mailboxCulture, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
@@ -47,7 +48,7 @@ public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $m
4748
* @param \StructType\ApiRequestServerVersion $requestServerVersion
4849
* @param string $namespace
4950
* @param bool $mustUnderstand
50-
* @param string $actor
51+
* @param string|null $actor
5152
* @return \ServiceType\ApiFind
5253
*/
5354
public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVersion $requestServerVersion, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
@@ -60,7 +61,7 @@ public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVe
6061
* @param \StructType\ApiTimeZoneContextType $timeZoneContext
6162
* @param string $namespace
6263
* @param bool $mustUnderstand
63-
* @param string $actor
64+
* @param string|null $actor
6465
* @return \ServiceType\ApiFind
6566
*/
6667
public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType $timeZoneContext, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
@@ -73,7 +74,7 @@ public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType
7374
* @param \StructType\ApiManagementRoleType $managementRole
7475
* @param string $namespace
7576
* @param bool $mustUnderstand
76-
* @param string $actor
77+
* @param string|null $actor
7778
* @return \ServiceType\ApiFind
7879
*/
7980
public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $managementRole, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
@@ -89,7 +90,7 @@ public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $m
8990
* @param string $dateTimePrecision
9091
* @param string $namespace
9192
* @param bool $mustUnderstand
92-
* @param string $actor
93+
* @param string|null $actor
9394
* @return \ServiceType\ApiFind
9495
*/
9596
public function setSoapHeaderDateTimePrecision(string $dateTimePrecision, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self

tests/resources/generated/ValidDoWithoutPrefix.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class _Do extends AbstractSoapClientBase
2020
* @param \StructType\CustomSecurityHeaderType $requesterCredentials
2121
* @param string $namespace
2222
* @param bool $mustUnderstand
23-
* @param string $actor
23+
* @param string|null $actor
2424
* @return \ServiceType\_Do
2525
*/
2626
public function setSoapHeaderRequesterCredentials(\StructType\CustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self

tests/resources/generated/ValidPayPalApiService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ApiService extends AbstractSoapClientBase
2121
* @param \StructType\ApiCustomSecurityHeaderType $requesterCredentials
2222
* @param string $namespace
2323
* @param bool $mustUnderstand
24-
* @param string $actor
24+
* @param string|null $actor
2525
* @return \ServiceType\ApiService
2626
*/
2727
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self

0 commit comments

Comments
 (0)