Skip to content

Commit

Permalink
Merge branch 'release/4.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelcom committed Feb 11, 2022
2 parents a4210e6 + 8f3b40c commit 870a576
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 4.1.4 - 2022-02-12
- issue #265 - Use statement for InvalidArgumentException is missing when needed in ServiceType class

## 4.1.3 - 2022-02-11
- issue #264 - Wrong PHPDoc @param name and description

Expand Down
24 changes: 23 additions & 1 deletion src/File/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use WsdlToPhp\PackageGenerator\File\Validation\Rules;
use WsdlToPhp\PackageGenerator\Generator\Generator;
use WsdlToPhp\PackageGenerator\Model\AbstractModel;
use WsdlToPhp\PackageGenerator\Model\Method;
use WsdlToPhp\PackageGenerator\Model\Method as MethodModel;
use WsdlToPhp\PackageGenerator\Model\Service as ServiceModel;
use WsdlToPhp\PackageGenerator\Model\Struct as StructModel;
Expand Down Expand Up @@ -95,6 +96,27 @@ protected function defineUseStatements(): AbstractModelFile
{
$this->getFile()->addUse(SoapFault::class);

/** @var Method $method */
foreach ($this->getModel()->getMethods() as $method) {
$soapHeaderTypes = $method->getMetaValue(TagHeader::META_SOAP_HEADER_TYPES, []);
if (!is_array($soapHeaderTypes)) {
continue;
}
foreach ($soapHeaderTypes as $soapHeaderType) {
$model = $this->getModelByName($soapHeaderType);
if (!$model instanceof StructModel) {
continue;
}
if (!$model->isRestriction()) {
continue;
}

$this->getFile()->addUse(InvalidArgumentException::class);

break 2;
}
}

return parent::defineUseStatements();
}

Expand Down Expand Up @@ -242,7 +264,7 @@ protected function addAnnotationBlockForSoapHeaderMethod(PhpAnnotationBlock $ann
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', $firstParameterType, $firstParameter->getName())))
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_NAMESPACE)))
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_BOOL, self::PARAM_SET_HEADER_MUSTUNDERSTAND)))
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_ACTOR)))
->addChild(new PhpAnnotation(self::ANNOTATION_PARAM, sprintf('%s|null $%s', self::TYPE_STRING, self::PARAM_SET_HEADER_ACTOR)))
->addChild(new PhpAnnotation(self::ANNOTATION_RETURN, $this->getModel()->getPackagedName(true)))
;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/resources/generated/ValidActonApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApiService extends AbstractSoapClientBase
* @param \StructType\ApiClusterHeader $clusterHeader
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiService
*/
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -34,7 +34,7 @@ public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $cluster
* @param \StructType\ApiSessionHeader $sessionHeader
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiService
*/
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down
4 changes: 2 additions & 2 deletions tests/resources/generated/ValidApiDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApiDelete extends AbstractSoapClientBase
* @param \StructType\ApiSessionHeader $sessionHeader
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiDelete
*/
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -34,7 +34,7 @@ public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $session
* @param \StructType\ApiClusterHeader $clusterHeader
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiDelete
*/
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/generated/ValidApiDo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApiDo extends AbstractSoapClientBase
* @param \StructType\ApiCustomSecurityHeaderType $requesterCredentials
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiDo
*/
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down
13 changes: 7 additions & 6 deletions tests/resources/generated/ValidApiFind.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace ServiceType;

use SoapFault;
use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractSoapClientBase;

/**
Expand All @@ -21,7 +22,7 @@ class ApiFind extends AbstractSoapClientBase
* @param \StructType\ApiExchangeImpersonationType $exchangeImpersonation
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpersonationType $exchangeImpersonation, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -34,7 +35,7 @@ public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpers
* @param \StructType\ApiMailboxCultureType $mailboxCulture
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $mailboxCulture, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -47,7 +48,7 @@ public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $m
* @param \StructType\ApiRequestServerVersion $requestServerVersion
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVersion $requestServerVersion, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -60,7 +61,7 @@ public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVe
* @param \StructType\ApiTimeZoneContextType $timeZoneContext
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType $timeZoneContext, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -73,7 +74,7 @@ public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType
* @param \StructType\ApiManagementRoleType $managementRole
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $managementRole, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand All @@ -89,7 +90,7 @@ public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $m
* @param string $dateTimePrecision
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiFind
*/
public function setSoapHeaderDateTimePrecision(string $dateTimePrecision, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/generated/ValidDoWithoutPrefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _Do extends AbstractSoapClientBase
* @param \StructType\CustomSecurityHeaderType $requesterCredentials
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\_Do
*/
public function setSoapHeaderRequesterCredentials(\StructType\CustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/generated/ValidPayPalApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApiService extends AbstractSoapClientBase
* @param \StructType\ApiCustomSecurityHeaderType $requesterCredentials
* @param string $namespace
* @param bool $mustUnderstand
* @param string $actor
* @param string|null $actor
* @return \ServiceType\ApiService
*/
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self
Expand Down

0 comments on commit 870a576

Please sign in to comment.