Skip to content

Commit 7aac71c

Browse files
authored
Use int as the PHP representation of long fields in generated code (#1471)
* Use int as the PHP representation of long fields in generated code * Add changelog entries for signature changes affecting strict types * Remove generator hacks needed for endpoint shapes to force the type Now that long fields are always defined as integer, we don't need such hacks anymore
1 parent f4f7972 commit 7aac71c

File tree

140 files changed

+507
-409
lines changed

Some content is hidden

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

140 files changed

+507
-409
lines changed

src/CodeGenerator/src/Generator/CodeGenerator/PopulatorGenerator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ private function generateProperties(StructureShape $shape, ClassBuilder $classBu
123123
$this->objectGenerator->generate($memberShape, $forEndpoint);
124124
if ($forEndpoint && 'endpoints' === $propertyName) {
125125
$forEndpoint = false;
126-
$returnType = 'array';
127126
}
128127
}
129128
if (!empty($memberShape->getEnum())) {

src/CodeGenerator/src/Generator/CodeGenerator/TypeGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ private function getNativePhpType(string $parameterType): string
187187
case 'structure':
188188
case 'map':
189189
return 'array';
190-
case 'long':
191190
case 'string':
192191
case 'blob':
193192
return 'string';
193+
case 'long':
194194
case 'integer':
195195
return 'int';
196196
case 'float':

src/CodeGenerator/src/Generator/InputGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ private function stringify(string $variable, Member $member, string $part): stri
514514
case 'boolean':
515515
return $variable . ' ? "true" : "false"';
516516
case 'string':
517-
case 'long':
518517
return $variable;
518+
case 'long':
519519
case 'integer':
520520
return '(string) ' . $variable;
521521
}

src/CodeGenerator/src/Generator/ObjectGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function namedConstructor(StructureShape $shape, ClassBuilder $classBuil
219219
*/
220220
private function addProperties(StructureShape $shape, ClassBuilder $classBuilder, bool $forEndpoint): void
221221
{
222-
$forEndpointProps = $forEndpoint ? ['address' => false, 'cachePeriodInMinutes' => false] : ['address' => true, 'cachePeriodInMinutes' => true];
222+
$forEndpointProps = $forEndpoint ? ['address' => false, 'cachePeriodInMinutes' => false] : [];
223223
foreach ($shape->getMembers() as $member) {
224224
$nullable = $returnType = null;
225225
$memberShape = $member->getShape();
@@ -231,9 +231,6 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder
231231
[$returnType, $parameterType, $memberClassNames] = $this->typeGenerator->getPhpType($memberShape);
232232
if ($forEndpoint && isset($forEndpointProps[$propertyName])) {
233233
$forEndpointProps[$propertyName] = true;
234-
if ('cachePeriodInMinutes' === $propertyName) {
235-
$returnType = $parameterType = 'int';
236-
}
237234
}
238235
foreach ($memberClassNames as $memberClassName) {
239236
$classBuilder->addUse($memberClassName->getFqdn());

src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ private function parseElement(string $input, Shape $shape, bool $required, bool
164164

165165
switch ($shape->getType()) {
166166
case 'string':
167-
case 'long':
168167
return $this->parseResponseString($input, $required);
168+
case 'long':
169169
case 'integer':
170170
return $this->parseResponseInteger($input, $required);
171171
case 'float':

src/CodeGenerator/src/Generator/ResponseParser/RestXmlParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ private function parseXmlElement(string $input, Shape $shape, bool $required, bo
162162

163163
switch ($shape->getType()) {
164164
case 'string':
165-
case 'long':
166165
return $this->parseXmlResponseString($input, $required);
166+
case 'long':
167167
case 'integer':
168168
return $this->parseXmlResponseInteger($input, $required);
169169
case 'float':

src/Service/AppSync/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## NOT RELEASED
44

5+
### BC-BREAK
6+
7+
- The type for `\AsyncAws\AppSync\Input\UpdateApiKeyRequest::setExpires` and `\AsyncAws\AppSync\Input\UpdateApiKeyRequest::getExpires` uses `int` instead of `string` to reflect the AWS type.
8+
- The return type for the methods `getDeletes` and `getExpires` of `\AsyncAws\AppSync\ValueObject\ApiKey` uses `int` instead of `string` to reflect the AWS type.
9+
- The return type for `\AsyncAws\AppSync\ValueObject\CachingConfig::getTtl` uses `int` instead of `string` to reflect the AWS type.
10+
- The return type for the methods `getBaseTableTtl` and `getDeltaSyncTableTtl` of `\AsyncAws\AppSync\ValueObject\DeltaSyncConfig` uses `int` instead of `string` to reflect the AWS type.
11+
512
## 1.1.0
613

714
### Added

src/Service/AppSync/src/AppSyncClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function startSchemaCreation($input): StartSchemaCreationResponse
267267
* apiId: string,
268268
* id: string,
269269
* description?: string,
270-
* expires?: string,
270+
* expires?: int,
271271
* '@region'?: string|null,
272272
* }|UpdateApiKeyRequest $input
273273
*

src/Service/AppSync/src/Input/UpdateApiKeyRequest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class UpdateApiKeyRequest extends Input
3838
* From the update time, the time after which the API key expires. The date is represented as seconds since the epoch.
3939
* For more information, see .
4040
*
41-
* @var string|null
41+
* @var int|null
4242
*/
4343
private $expires;
4444

@@ -47,7 +47,7 @@ final class UpdateApiKeyRequest extends Input
4747
* apiId?: string,
4848
* id?: string,
4949
* description?: string,
50-
* expires?: string,
50+
* expires?: int,
5151
* '@region'?: string|null,
5252
* } $input
5353
*/
@@ -65,7 +65,7 @@ public function __construct(array $input = [])
6565
* apiId?: string,
6666
* id?: string,
6767
* description?: string,
68-
* expires?: string,
68+
* expires?: int,
6969
* '@region'?: string|null,
7070
* }|UpdateApiKeyRequest $input
7171
*/
@@ -84,7 +84,7 @@ public function getDescription(): ?string
8484
return $this->description;
8585
}
8686

87-
public function getExpires(): ?string
87+
public function getExpires(): ?int
8888
{
8989
return $this->expires;
9090
}
@@ -139,7 +139,7 @@ public function setDescription(?string $value): self
139139
return $this;
140140
}
141141

142-
public function setExpires(?string $value): self
142+
public function setExpires(?int $value): self
143143
{
144144
$this->expires = $value;
145145

src/Service/AppSync/src/Result/CreateResolverResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function populateResultAppSyncRuntime(array $json): AppSyncRuntime
4343
private function populateResultCachingConfig(array $json): CachingConfig
4444
{
4545
return new CachingConfig([
46-
'ttl' => (string) $json['ttl'],
46+
'ttl' => (int) $json['ttl'],
4747
'cachingKeys' => !isset($json['cachingKeys']) ? null : $this->populateResultCachingKeys($json['cachingKeys']),
4848
]);
4949
}

src/Service/AppSync/src/Result/ListApiKeysResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ private function populateResultApiKey(array $json): ApiKey
4848
return new ApiKey([
4949
'id' => isset($json['id']) ? (string) $json['id'] : null,
5050
'description' => isset($json['description']) ? (string) $json['description'] : null,
51-
'expires' => isset($json['expires']) ? (string) $json['expires'] : null,
52-
'deletes' => isset($json['deletes']) ? (string) $json['deletes'] : null,
51+
'expires' => isset($json['expires']) ? (int) $json['expires'] : null,
52+
'deletes' => isset($json['deletes']) ? (int) $json['deletes'] : null,
5353
]);
5454
}
5555

src/Service/AppSync/src/Result/ListResolversResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function populateResultAppSyncRuntime(array $json): AppSyncRuntime
5959
private function populateResultCachingConfig(array $json): CachingConfig
6060
{
6161
return new CachingConfig([
62-
'ttl' => (string) $json['ttl'],
62+
'ttl' => (int) $json['ttl'],
6363
'cachingKeys' => !isset($json['cachingKeys']) ? null : $this->populateResultCachingKeys($json['cachingKeys']),
6464
]);
6565
}

src/Service/AppSync/src/Result/UpdateApiKeyResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ private function populateResultApiKey(array $json): ApiKey
3232
return new ApiKey([
3333
'id' => isset($json['id']) ? (string) $json['id'] : null,
3434
'description' => isset($json['description']) ? (string) $json['description'] : null,
35-
'expires' => isset($json['expires']) ? (string) $json['expires'] : null,
36-
'deletes' => isset($json['deletes']) ? (string) $json['deletes'] : null,
35+
'expires' => isset($json['expires']) ? (int) $json['expires'] : null,
36+
'deletes' => isset($json['deletes']) ? (int) $json['deletes'] : null,
3737
]);
3838
}
3939
}

src/Service/AppSync/src/Result/UpdateDataSourceResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ private function populateResultDataSource(array $json): DataSource
7575
private function populateResultDeltaSyncConfig(array $json): DeltaSyncConfig
7676
{
7777
return new DeltaSyncConfig([
78-
'baseTableTTL' => isset($json['baseTableTTL']) ? (string) $json['baseTableTTL'] : null,
78+
'baseTableTTL' => isset($json['baseTableTTL']) ? (int) $json['baseTableTTL'] : null,
7979
'deltaSyncTableName' => isset($json['deltaSyncTableName']) ? (string) $json['deltaSyncTableName'] : null,
80-
'deltaSyncTableTTL' => isset($json['deltaSyncTableTTL']) ? (string) $json['deltaSyncTableTTL'] : null,
80+
'deltaSyncTableTTL' => isset($json['deltaSyncTableTTL']) ? (int) $json['deltaSyncTableTTL'] : null,
8181
]);
8282
}
8383

src/Service/AppSync/src/Result/UpdateResolverResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function populateResultAppSyncRuntime(array $json): AppSyncRuntime
4343
private function populateResultCachingConfig(array $json): CachingConfig
4444
{
4545
return new CachingConfig([
46-
'ttl' => (string) $json['ttl'],
46+
'ttl' => (int) $json['ttl'],
4747
'cachingKeys' => !isset($json['cachingKeys']) ? null : $this->populateResultCachingKeys($json['cachingKeys']),
4848
]);
4949
}

src/Service/AppSync/src/ValueObject/ApiKey.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ final class ApiKey
6060
* @param array{
6161
* id?: null|string,
6262
* description?: null|string,
63-
* expires?: null|string,
64-
* deletes?: null|string,
63+
* expires?: null|int,
64+
* deletes?: null|int,
6565
* } $input
6666
*/
6767
public function __construct(array $input)
@@ -76,16 +76,16 @@ public function __construct(array $input)
7676
* @param array{
7777
* id?: null|string,
7878
* description?: null|string,
79-
* expires?: null|string,
80-
* deletes?: null|string,
79+
* expires?: null|int,
80+
* deletes?: null|int,
8181
* }|ApiKey $input
8282
*/
8383
public static function create($input): self
8484
{
8585
return $input instanceof self ? $input : new self($input);
8686
}
8787

88-
public function getDeletes(): ?string
88+
public function getDeletes(): ?int
8989
{
9090
return $this->deletes;
9191
}
@@ -95,7 +95,7 @@ public function getDescription(): ?string
9595
return $this->description;
9696
}
9797

98-
public function getExpires(): ?string
98+
public function getExpires(): ?int
9999
{
100100
return $this->expires;
101101
}

src/Service/AppSync/src/ValueObject/CachingConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class CachingConfig
2525

2626
/**
2727
* @param array{
28-
* ttl: string,
28+
* ttl: int,
2929
* cachingKeys?: null|string[],
3030
* } $input
3131
*/
@@ -37,7 +37,7 @@ public function __construct(array $input)
3737

3838
/**
3939
* @param array{
40-
* ttl: string,
40+
* ttl: int,
4141
* cachingKeys?: null|string[],
4242
* }|CachingConfig $input
4343
*/
@@ -54,7 +54,7 @@ public function getCachingKeys(): array
5454
return $this->cachingKeys ?? [];
5555
}
5656

57-
public function getTtl(): string
57+
public function getTtl(): int
5858
{
5959
return $this->ttl;
6060
}

src/Service/AppSync/src/ValueObject/DeltaSyncConfig.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ final class DeltaSyncConfig
2424

2525
/**
2626
* @param array{
27-
* baseTableTTL?: null|string,
27+
* baseTableTTL?: null|int,
2828
* deltaSyncTableName?: null|string,
29-
* deltaSyncTableTTL?: null|string,
29+
* deltaSyncTableTTL?: null|int,
3030
* } $input
3131
*/
3232
public function __construct(array $input)
@@ -38,17 +38,17 @@ public function __construct(array $input)
3838

3939
/**
4040
* @param array{
41-
* baseTableTTL?: null|string,
41+
* baseTableTTL?: null|int,
4242
* deltaSyncTableName?: null|string,
43-
* deltaSyncTableTTL?: null|string,
43+
* deltaSyncTableTTL?: null|int,
4444
* }|DeltaSyncConfig $input
4545
*/
4646
public static function create($input): self
4747
{
4848
return $input instanceof self ? $input : new self($input);
4949
}
5050

51-
public function getBaseTableTtl(): ?string
51+
public function getBaseTableTtl(): ?int
5252
{
5353
return $this->baseTableTtl;
5454
}
@@ -58,7 +58,7 @@ public function getDeltaSyncTableName(): ?string
5858
return $this->deltaSyncTableName;
5959
}
6060

61-
public function getDeltaSyncTableTtl(): ?string
61+
public function getDeltaSyncTableTtl(): ?int
6262
{
6363
return $this->deltaSyncTableTtl;
6464
}

src/Service/Athena/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## NOT RELEASED
44

5+
### BC-BREAK
6+
7+
- The return type for `\AsyncAws\Athena\Result\GetQueryResultsOutput::getUpdateCount` uses `int` instead of `string` to reflect the AWS type.
8+
- The return type for `\AsyncAws\Athena\ValueObject\CalculationStatistics::getDpuExecutionInMillis` uses `int` instead of `string` to reflect the AWS type.
9+
- The return type for the methods `getDataScannedInBytes`, `getEngineExecutionTimeInMillis`, `getQueryPlanningTimeInMillis`, `getQueryQueueTimeInMillis`, `getServiceProcessingTimeInMillis` and `getTotalExecutionTimeInMillis` of `\AsyncAws\Athena\ValueObject\QueryExecutionStatistics` uses `int` instead of `string` to reflect the AWS type.
10+
- The return type for `\AsyncAws\Athena\ValueObject\SessionConfiguration::getIdleTimeoutSeconds` uses `int` instead of `string` to reflect the AWS type.
11+
- The return type for `\AsyncAws\Athena\ValueObject\SessionStatistics::getDpuExecutionInMillis` uses `int` instead of `string` to reflect the AWS type.
12+
- The return type for `\AsyncAws\Athena\ValueObject\WorkGroupConfiguration::getBytesScannedCutoffPerQuery` uses `int` instead of `string` to reflect the AWS type.
13+
14+
515
## 1.0.0
616

717
### Added

src/Service/Athena/src/Result/GetCalculationExecutionResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function populateResultCalculationResult(array $json): CalculationResult
121121
private function populateResultCalculationStatistics(array $json): CalculationStatistics
122122
{
123123
return new CalculationStatistics([
124-
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null,
124+
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (int) $json['DpuExecutionInMillis'] : null,
125125
'Progress' => isset($json['Progress']) ? (string) $json['Progress'] : null,
126126
]);
127127
}

src/Service/Athena/src/Result/GetCalculationExecutionStatusResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function populateResult(Response $response): void
4444
private function populateResultCalculationStatistics(array $json): CalculationStatistics
4545
{
4646
return new CalculationStatistics([
47-
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null,
47+
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (int) $json['DpuExecutionInMillis'] : null,
4848
'Progress' => isset($json['Progress']) ? (string) $json['Progress'] : null,
4949
]);
5050
}

src/Service/Athena/src/Result/GetQueryExecutionOutput.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ private function populateResultQueryExecutionContext(array $json): QueryExecutio
116116
private function populateResultQueryExecutionStatistics(array $json): QueryExecutionStatistics
117117
{
118118
return new QueryExecutionStatistics([
119-
'EngineExecutionTimeInMillis' => isset($json['EngineExecutionTimeInMillis']) ? (string) $json['EngineExecutionTimeInMillis'] : null,
120-
'DataScannedInBytes' => isset($json['DataScannedInBytes']) ? (string) $json['DataScannedInBytes'] : null,
119+
'EngineExecutionTimeInMillis' => isset($json['EngineExecutionTimeInMillis']) ? (int) $json['EngineExecutionTimeInMillis'] : null,
120+
'DataScannedInBytes' => isset($json['DataScannedInBytes']) ? (int) $json['DataScannedInBytes'] : null,
121121
'DataManifestLocation' => isset($json['DataManifestLocation']) ? (string) $json['DataManifestLocation'] : null,
122-
'TotalExecutionTimeInMillis' => isset($json['TotalExecutionTimeInMillis']) ? (string) $json['TotalExecutionTimeInMillis'] : null,
123-
'QueryQueueTimeInMillis' => isset($json['QueryQueueTimeInMillis']) ? (string) $json['QueryQueueTimeInMillis'] : null,
124-
'QueryPlanningTimeInMillis' => isset($json['QueryPlanningTimeInMillis']) ? (string) $json['QueryPlanningTimeInMillis'] : null,
125-
'ServiceProcessingTimeInMillis' => isset($json['ServiceProcessingTimeInMillis']) ? (string) $json['ServiceProcessingTimeInMillis'] : null,
122+
'TotalExecutionTimeInMillis' => isset($json['TotalExecutionTimeInMillis']) ? (int) $json['TotalExecutionTimeInMillis'] : null,
123+
'QueryQueueTimeInMillis' => isset($json['QueryQueueTimeInMillis']) ? (int) $json['QueryQueueTimeInMillis'] : null,
124+
'QueryPlanningTimeInMillis' => isset($json['QueryPlanningTimeInMillis']) ? (int) $json['QueryPlanningTimeInMillis'] : null,
125+
'ServiceProcessingTimeInMillis' => isset($json['ServiceProcessingTimeInMillis']) ? (int) $json['ServiceProcessingTimeInMillis'] : null,
126126
'ResultReuseInformation' => empty($json['ResultReuseInformation']) ? null : $this->populateResultResultReuseInformation($json['ResultReuseInformation']),
127127
]);
128128
}

src/Service/Athena/src/Result/GetQueryResultsOutput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getResultSet(): ?ResultSet
8686
return $this->resultSet;
8787
}
8888

89-
public function getUpdateCount(): ?string
89+
public function getUpdateCount(): ?int
9090
{
9191
$this->initialize();
9292

@@ -97,7 +97,7 @@ protected function populateResult(Response $response): void
9797
{
9898
$data = $response->toArray();
9999

100-
$this->updateCount = isset($data['UpdateCount']) ? (string) $data['UpdateCount'] : null;
100+
$this->updateCount = isset($data['UpdateCount']) ? (int) $data['UpdateCount'] : null;
101101
$this->resultSet = empty($data['ResultSet']) ? null : $this->populateResultResultSet($data['ResultSet']);
102102
$this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null;
103103
}

src/Service/Athena/src/Result/GetSessionResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ private function populateResultSessionConfiguration(array $json): SessionConfigu
173173
return new SessionConfiguration([
174174
'ExecutionRole' => isset($json['ExecutionRole']) ? (string) $json['ExecutionRole'] : null,
175175
'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null,
176-
'IdleTimeoutSeconds' => isset($json['IdleTimeoutSeconds']) ? (string) $json['IdleTimeoutSeconds'] : null,
176+
'IdleTimeoutSeconds' => isset($json['IdleTimeoutSeconds']) ? (int) $json['IdleTimeoutSeconds'] : null,
177177
'EncryptionConfiguration' => empty($json['EncryptionConfiguration']) ? null : $this->populateResultEncryptionConfiguration($json['EncryptionConfiguration']),
178178
]);
179179
}
180180

181181
private function populateResultSessionStatistics(array $json): SessionStatistics
182182
{
183183
return new SessionStatistics([
184-
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (string) $json['DpuExecutionInMillis'] : null,
184+
'DpuExecutionInMillis' => isset($json['DpuExecutionInMillis']) ? (int) $json['DpuExecutionInMillis'] : null,
185185
]);
186186
}
187187

0 commit comments

Comments
 (0)