Skip to content

Commit 801906e

Browse files
committed
update PhpGenerator and tests
1 parent db8a42c commit 801906e

14 files changed

Lines changed: 62 additions & 23 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ phpstan:
2525
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpstan analyze src --level=2
2626

2727
phpunit:
28-
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpunit
28+
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/phpunit --stop-on-failure --stop-on-error $(ARGS)
2929

3030
rector:
3131
$(DOCKER_EXEC_CONTAINER) $(PHP_VERSION) vendor/bin/rector process

src/File/Struct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected function getStructMethodParameter(StructAttributeModel $attribute): Ph
182182
break;
183183

184184
default:
185-
$type = (($attribute->isRequired() && !$attribute->isNullable()) ? '' : '?').$this->getStructAttributeTypeAsPhpType($attribute);
185+
$type = $this->getStructAttributeTypeAsPhpType($attribute);
186186

187187
break;
188188
}
@@ -192,7 +192,7 @@ protected function getStructMethodParameter(StructAttributeModel $attribute): Ph
192192

193193
return new PhpFunctionParameter(
194194
lcfirst($attribute->getUniqueString($attribute->getCleanName(), 'method')),
195-
$attribute->isRequired() && !$attribute->isAChoice() ? AssignedValueElementInterface::NO_VALUE : (str_contains($type ?? '', '?') ? $defaultValue ?? null : $defaultValue),
195+
$attribute->isRequired() && !$attribute->isAChoice() ? AssignedValueElementInterface::NO_VALUE : (($attribute->isRequired() && !$attribute->isNullable()) ? $defaultValue ?? null : $defaultValue),
196196
$type,
197197
$attribute
198198
);

src/File/Validation/AbstractRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ final protected function addArrayValidationMethod(string $parameterName, $value)
9494
ucfirst($this->getAttribute()->getCleanName())
9595
);
9696
$method = new PhpMethod($this->getValidationMethodName($parameterName), [
97-
new PhpFunctionParameter('values', null, '?array'),
97+
new PhpFunctionParameter('values', null, 'array'),
9898
], AbstractModelFile::TYPE_STRING, PhpMethod::ACCESS_PUBLIC, false, true);
9999

100100
$method

tests/File/Validation/AbstractRule.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,25 @@ abstract class AbstractRule extends AbstractTestCase
1919
{
2020
private static array $generators = [];
2121

22+
/**
23+
* @throws \ReflectionException
24+
*/
2225
public static function getActonItemInstance(bool $reset = false)
2326
{
2427
return self::getClassInstance('actonGeneratorInstance', 'Item', $reset);
2528
}
2629

30+
/**
31+
* @throws \ReflectionException
32+
*/
2733
public static function getWhlAddressTypeInstance(bool $reset = false)
2834
{
2935
return self::getClassInstance('whlInstance', 'AddressType', $reset);
3036
}
3137

38+
/**
39+
* @throws \ReflectionException
40+
*/
3241
public static function getWhlBookingChannelInstance(bool $reset = false)
3342
{
3443
return self::getClassInstance('whlInstance', 'BookingChannel', $reset);
@@ -159,6 +168,12 @@ protected static function createClassInstance(Struct $struct)
159168
@unlink($structFile->getFileName());
160169
}
161170

171+
/**
172+
* @param mixed $instanceMethod
173+
* @param mixed $structName
174+
* @param mixed $reset
175+
* @throws \ReflectionException
176+
*/
162177
private static function getClassInstance($instanceMethod, $structName, $reset = false)
163178
{
164179
$key = implode('_', [

tests/File/Validation/ArrayRuleTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ final class ArrayRuleTest extends AbstractRule
1515
{
1616
/**
1717
* The AddressLine
18-
* Meta informations extracted from the WSDL
18+
* Meta information extracted from the WSDL
1919
* - documentation: When the address is unformatted (FormattedInd="false") these lines will contain free form address details. When the address is formatted and street number and street name must be sent independently, the street number will be sent
2020
* using StreetNmbr, and the street name will be sent in the first AddressLine occurrence. | Used for Character Strings, length 1 to 255.
2121
* - maxOccurs: 5
2222
* - minOccurs: 0
2323
* - base: xs:string
2424
* - maxLength: 255
2525
* - minLength: 1.
26+
* @throws \ReflectionException
2627
*/
2728
public function testSetAddressLineWithNullOnOneItemMustThrowAnException(): void
2829
{
@@ -42,7 +43,7 @@ public function testSetAddressLineWithNullOnOneItemMustThrowAnException(): void
4243

4344
/**
4445
* The AddressLine
45-
* Meta informations extracted from the WSDL
46+
* Meta information extracted from the WSDL
4647
* - documentation: When the address is unformatted (FormattedInd="false") these lines will contain free form address details. When the address is formatted and street number and street name must be sent independently, the street number will be sent
4748
* using StreetNmbr, and the street name will be sent in the first AddressLine occurrence. | Used for Character Strings, length 1 to 255.
4849
* - maxOccurs: 5
@@ -51,6 +52,7 @@ public function testSetAddressLineWithNullOnOneItemMustThrowAnException(): void
5152
* - maxLength: 255
5253
* - minLength: 1.
5354
*
55+
* @throws \ReflectionException
5456
* @var string[]
5557
*/
5658
public function testSetAddressLineWithStringsMustPass(): void

tests/File/Validation/XmlRuleTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111
final class XmlRuleTest extends AbstractRule
1212
{
13+
/**
14+
* @throws \ReflectionException
15+
*/
1316
public function testSetAnyWithEmptyStringMustThrowAnException(): void
1417
{
1518
$this->expectException(\InvalidArgumentException::class);
@@ -19,6 +22,9 @@ public function testSetAnyWithEmptyStringMustThrowAnException(): void
1922
$instance->setAny('');
2023
}
2124

25+
/**
26+
* @throws \ReflectionException
27+
*/
2228
public function testSetAnyWithInvalidXmlStringMustThrowAnException(): void
2329
{
2430
$this->expectException(\InvalidArgumentException::class);
@@ -28,6 +34,9 @@ public function testSetAnyWithInvalidXmlStringMustThrowAnException(): void
2834
@$instance->setAny('<attribute>1</attribute');
2935
}
3036

37+
/**
38+
* @throws \ReflectionException
39+
*/
3140
public function testSetAnyWithValidXmlStringMustPass(): void
3241
{
3342
$instance = self::getActonItemInstance();
@@ -37,6 +46,9 @@ public function testSetAnyWithValidXmlStringMustPass(): void
3746
$this->assertSame($string, $instance->getAny());
3847
}
3948

49+
/**
50+
* @throws \ReflectionException
51+
*/
4052
public function testSetAnyWithIntMustThrowAnException(): void
4153
{
4254
$this->expectException(\InvalidArgumentException::class);
@@ -46,6 +58,10 @@ public function testSetAnyWithIntMustThrowAnException(): void
4658
$instance->setAny(2);
4759
}
4860

61+
/**
62+
* @throws \DOMException
63+
* @throws \ReflectionException
64+
*/
4965
public function testSetAnyWithDomDocumentMustPass(): void
5066
{
5167
$instance = self::getActonItemInstance();
@@ -57,6 +73,9 @@ public function testSetAnyWithDomDocumentMustPass(): void
5773
$this->assertSame('<element>147</element>', $instance->getAny());
5874
}
5975

76+
/**
77+
* @throws \ReflectionException
78+
*/
6079
public function testSetAnyWithInvalidObjectMustThrowAnException(): void
6180
{
6281
$this->expectException(\InvalidArgumentException::class);
@@ -66,6 +85,9 @@ public function testSetAnyWithInvalidObjectMustThrowAnException(): void
6685
$instance->setAny(new \stdClass());
6786
}
6887

88+
/**
89+
* @throws \ReflectionException
90+
*/
6991
public function testSetAnyWithArrayMustThrowAnException(): void
7092
{
7193
$this->expectException(\InvalidArgumentException::class);

tests/resources/generated/ValidActonApiService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ApiService extends AbstractSoapClientBase
2424
* @param string|null $actor
2525
* @return \ServiceType\ApiService
2626
*/
27-
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
27+
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ??string $actor = null): self
2828
{
2929
return $this->setSoapHeader($namespace, 'ClusterHeader', $clusterHeader, $mustUnderstand, $actor);
3030
}
@@ -37,7 +37,7 @@ public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $cluster
3737
* @param string|null $actor
3838
* @return \ServiceType\ApiService
3939
*/
40-
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
40+
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ??string $actor = null): self
4141
{
4242
return $this->setSoapHeader($namespace, 'SessionHeader', $sessionHeader, $mustUnderstand, $actor);
4343
}

tests/resources/generated/ValidApiDelete.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ApiDelete extends AbstractSoapClientBase
2424
* @param string|null $actor
2525
* @return \ServiceType\ApiDelete
2626
*/
27-
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
27+
public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $sessionHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ??string $actor = null): self
2828
{
2929
return $this->setSoapHeader($namespace, 'SessionHeader', $sessionHeader, $mustUnderstand, $actor);
3030
}
@@ -37,7 +37,7 @@ public function setSoapHeaderSessionHeader(\StructType\ApiSessionHeader $session
3737
* @param string|null $actor
3838
* @return \ServiceType\ApiDelete
3939
*/
40-
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ?string $actor = null): self
40+
public function setSoapHeaderClusterHeader(\StructType\ApiClusterHeader $clusterHeader, string $namespace = 'urn:api.actonsoftware.com', bool $mustUnderstand = false, ??string $actor = null): self
4141
{
4242
return $this->setSoapHeader($namespace, 'ClusterHeader', $clusterHeader, $mustUnderstand, $actor);
4343
}

tests/resources/generated/ValidApiDo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ApiDo extends AbstractSoapClientBase
2424
* @param string|null $actor
2525
* @return \ServiceType\ApiDo
2626
*/
27-
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ?string $actor = null): self
27+
public function setSoapHeaderRequesterCredentials(\StructType\ApiCustomSecurityHeaderType $requesterCredentials, string $namespace = 'urn:ebay:api:PayPalAPI', bool $mustUnderstand = false, ??string $actor = null): self
2828
{
2929
return $this->setSoapHeader($namespace, 'RequesterCredentials', $requesterCredentials, $mustUnderstand, $actor);
3030
}

tests/resources/generated/ValidApiFind.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ApiFind extends AbstractSoapClientBase
2525
* @param string|null $actor
2626
* @return \ServiceType\ApiFind
2727
*/
28-
public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpersonationType $exchangeImpersonation, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
28+
public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpersonationType $exchangeImpersonation, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
2929
{
3030
return $this->setSoapHeader($namespace, 'ExchangeImpersonation', $exchangeImpersonation, $mustUnderstand, $actor);
3131
}
@@ -38,7 +38,7 @@ public function setSoapHeaderExchangeImpersonation(\StructType\ApiExchangeImpers
3838
* @param string|null $actor
3939
* @return \ServiceType\ApiFind
4040
*/
41-
public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $mailboxCulture, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
41+
public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $mailboxCulture, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
4242
{
4343
return $this->setSoapHeader($namespace, 'MailboxCulture', $mailboxCulture, $mustUnderstand, $actor);
4444
}
@@ -51,7 +51,7 @@ public function setSoapHeaderMailboxCulture(\StructType\ApiMailboxCultureType $m
5151
* @param string|null $actor
5252
* @return \ServiceType\ApiFind
5353
*/
54-
public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVersion $requestServerVersion, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
54+
public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVersion $requestServerVersion, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
5555
{
5656
return $this->setSoapHeader($namespace, 'RequestServerVersion', $requestServerVersion, $mustUnderstand, $actor);
5757
}
@@ -64,7 +64,7 @@ public function setSoapHeaderRequestServerVersion(\StructType\ApiRequestServerVe
6464
* @param string|null $actor
6565
* @return \ServiceType\ApiFind
6666
*/
67-
public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType $timeZoneContext, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
67+
public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType $timeZoneContext, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
6868
{
6969
return $this->setSoapHeader($namespace, 'TimeZoneContext', $timeZoneContext, $mustUnderstand, $actor);
7070
}
@@ -77,7 +77,7 @@ public function setSoapHeaderTimeZoneContext(\StructType\ApiTimeZoneContextType
7777
* @param string|null $actor
7878
* @return \ServiceType\ApiFind
7979
*/
80-
public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $managementRole, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
80+
public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $managementRole, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
8181
{
8282
return $this->setSoapHeader($namespace, 'ManagementRole', $managementRole, $mustUnderstand, $actor);
8383
}
@@ -93,7 +93,7 @@ public function setSoapHeaderManagementRole(\StructType\ApiManagementRoleType $m
9393
* @param string|null $actor
9494
* @return \ServiceType\ApiFind
9595
*/
96-
public function setSoapHeaderDateTimePrecision(string $dateTimePrecision, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ?string $actor = null): self
96+
public function setSoapHeaderDateTimePrecision(string $dateTimePrecision, string $namespace = 'http://schemas.microsoft.com/exchange/services/2006/types', bool $mustUnderstand = false, ??string $actor = null): self
9797
{
9898
// validation for constraint: enumeration
9999
if (!\EnumType\ApiDateTimePrecisionType::valueIsValid($dateTimePrecision)) {

0 commit comments

Comments
 (0)