Skip to content

Commit 050644c

Browse files
authored
Fix recusion in json object generation (#1210)
1 parent 3b574f6 commit 050644c

File tree

4 files changed

+288
-158
lines changed

4 files changed

+288
-158
lines changed

src/Result/ListFunctionsResponse.php

Lines changed: 131 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,29 @@ private function populateResultArchitecturesList(array $json): array
123123
return $items;
124124
}
125125

126+
private function populateResultDeadLetterConfig(array $json): DeadLetterConfig
127+
{
128+
return new DeadLetterConfig([
129+
'TargetArn' => isset($json['TargetArn']) ? (string) $json['TargetArn'] : null,
130+
]);
131+
}
132+
133+
private function populateResultEnvironmentError(array $json): EnvironmentError
134+
{
135+
return new EnvironmentError([
136+
'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null,
137+
'Message' => isset($json['Message']) ? (string) $json['Message'] : null,
138+
]);
139+
}
140+
141+
private function populateResultEnvironmentResponse(array $json): EnvironmentResponse
142+
{
143+
return new EnvironmentResponse([
144+
'Variables' => !isset($json['Variables']) ? null : $this->populateResultEnvironmentVariables($json['Variables']),
145+
'Error' => empty($json['Error']) ? null : $this->populateResultEnvironmentError($json['Error']),
146+
]);
147+
}
148+
126149
/**
127150
* @return array<string, string>
128151
*/
@@ -136,108 +159,129 @@ private function populateResultEnvironmentVariables(array $json): array
136159
return $items;
137160
}
138161

162+
private function populateResultEphemeralStorage(array $json): EphemeralStorage
163+
{
164+
return new EphemeralStorage([
165+
'Size' => (int) $json['Size'],
166+
]);
167+
}
168+
169+
private function populateResultFileSystemConfig(array $json): FileSystemConfig
170+
{
171+
return new FileSystemConfig([
172+
'Arn' => (string) $json['Arn'],
173+
'LocalMountPath' => (string) $json['LocalMountPath'],
174+
]);
175+
}
176+
139177
/**
140178
* @return FileSystemConfig[]
141179
*/
142180
private function populateResultFileSystemConfigList(array $json): array
143181
{
144182
$items = [];
145183
foreach ($json as $item) {
146-
$items[] = new FileSystemConfig([
147-
'Arn' => (string) $item['Arn'],
148-
'LocalMountPath' => (string) $item['LocalMountPath'],
149-
]);
184+
$items[] = $this->populateResultFileSystemConfig($item);
150185
}
151186

152187
return $items;
153188
}
154189

190+
private function populateResultFunctionConfiguration(array $json): FunctionConfiguration
191+
{
192+
return new FunctionConfiguration([
193+
'FunctionName' => isset($json['FunctionName']) ? (string) $json['FunctionName'] : null,
194+
'FunctionArn' => isset($json['FunctionArn']) ? (string) $json['FunctionArn'] : null,
195+
'Runtime' => isset($json['Runtime']) ? (string) $json['Runtime'] : null,
196+
'Role' => isset($json['Role']) ? (string) $json['Role'] : null,
197+
'Handler' => isset($json['Handler']) ? (string) $json['Handler'] : null,
198+
'CodeSize' => isset($json['CodeSize']) ? (string) $json['CodeSize'] : null,
199+
'Description' => isset($json['Description']) ? (string) $json['Description'] : null,
200+
'Timeout' => isset($json['Timeout']) ? (int) $json['Timeout'] : null,
201+
'MemorySize' => isset($json['MemorySize']) ? (int) $json['MemorySize'] : null,
202+
'LastModified' => isset($json['LastModified']) ? (string) $json['LastModified'] : null,
203+
'CodeSha256' => isset($json['CodeSha256']) ? (string) $json['CodeSha256'] : null,
204+
'Version' => isset($json['Version']) ? (string) $json['Version'] : null,
205+
'VpcConfig' => empty($json['VpcConfig']) ? null : $this->populateResultVpcConfigResponse($json['VpcConfig']),
206+
'DeadLetterConfig' => empty($json['DeadLetterConfig']) ? null : $this->populateResultDeadLetterConfig($json['DeadLetterConfig']),
207+
'Environment' => empty($json['Environment']) ? null : $this->populateResultEnvironmentResponse($json['Environment']),
208+
'KMSKeyArn' => isset($json['KMSKeyArn']) ? (string) $json['KMSKeyArn'] : null,
209+
'TracingConfig' => empty($json['TracingConfig']) ? null : $this->populateResultTracingConfigResponse($json['TracingConfig']),
210+
'MasterArn' => isset($json['MasterArn']) ? (string) $json['MasterArn'] : null,
211+
'RevisionId' => isset($json['RevisionId']) ? (string) $json['RevisionId'] : null,
212+
'Layers' => !isset($json['Layers']) ? null : $this->populateResultLayersReferenceList($json['Layers']),
213+
'State' => isset($json['State']) ? (string) $json['State'] : null,
214+
'StateReason' => isset($json['StateReason']) ? (string) $json['StateReason'] : null,
215+
'StateReasonCode' => isset($json['StateReasonCode']) ? (string) $json['StateReasonCode'] : null,
216+
'LastUpdateStatus' => isset($json['LastUpdateStatus']) ? (string) $json['LastUpdateStatus'] : null,
217+
'LastUpdateStatusReason' => isset($json['LastUpdateStatusReason']) ? (string) $json['LastUpdateStatusReason'] : null,
218+
'LastUpdateStatusReasonCode' => isset($json['LastUpdateStatusReasonCode']) ? (string) $json['LastUpdateStatusReasonCode'] : null,
219+
'FileSystemConfigs' => !isset($json['FileSystemConfigs']) ? null : $this->populateResultFileSystemConfigList($json['FileSystemConfigs']),
220+
'PackageType' => isset($json['PackageType']) ? (string) $json['PackageType'] : null,
221+
'ImageConfigResponse' => empty($json['ImageConfigResponse']) ? null : $this->populateResultImageConfigResponse($json['ImageConfigResponse']),
222+
'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null,
223+
'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null,
224+
'Architectures' => !isset($json['Architectures']) ? null : $this->populateResultArchitecturesList($json['Architectures']),
225+
'EphemeralStorage' => empty($json['EphemeralStorage']) ? null : $this->populateResultEphemeralStorage($json['EphemeralStorage']),
226+
]);
227+
}
228+
155229
/**
156230
* @return FunctionConfiguration[]
157231
*/
158232
private function populateResultFunctionList(array $json): array
159233
{
160234
$items = [];
161235
foreach ($json as $item) {
162-
$items[] = new FunctionConfiguration([
163-
'FunctionName' => isset($item['FunctionName']) ? (string) $item['FunctionName'] : null,
164-
'FunctionArn' => isset($item['FunctionArn']) ? (string) $item['FunctionArn'] : null,
165-
'Runtime' => isset($item['Runtime']) ? (string) $item['Runtime'] : null,
166-
'Role' => isset($item['Role']) ? (string) $item['Role'] : null,
167-
'Handler' => isset($item['Handler']) ? (string) $item['Handler'] : null,
168-
'CodeSize' => isset($item['CodeSize']) ? (string) $item['CodeSize'] : null,
169-
'Description' => isset($item['Description']) ? (string) $item['Description'] : null,
170-
'Timeout' => isset($item['Timeout']) ? (int) $item['Timeout'] : null,
171-
'MemorySize' => isset($item['MemorySize']) ? (int) $item['MemorySize'] : null,
172-
'LastModified' => isset($item['LastModified']) ? (string) $item['LastModified'] : null,
173-
'CodeSha256' => isset($item['CodeSha256']) ? (string) $item['CodeSha256'] : null,
174-
'Version' => isset($item['Version']) ? (string) $item['Version'] : null,
175-
'VpcConfig' => empty($item['VpcConfig']) ? null : new VpcConfigResponse([
176-
'SubnetIds' => !isset($item['VpcConfig']['SubnetIds']) ? null : $this->populateResultSubnetIds($item['VpcConfig']['SubnetIds']),
177-
'SecurityGroupIds' => !isset($item['VpcConfig']['SecurityGroupIds']) ? null : $this->populateResultSecurityGroupIds($item['VpcConfig']['SecurityGroupIds']),
178-
'VpcId' => isset($item['VpcConfig']['VpcId']) ? (string) $item['VpcConfig']['VpcId'] : null,
179-
]),
180-
'DeadLetterConfig' => empty($item['DeadLetterConfig']) ? null : new DeadLetterConfig([
181-
'TargetArn' => isset($item['DeadLetterConfig']['TargetArn']) ? (string) $item['DeadLetterConfig']['TargetArn'] : null,
182-
]),
183-
'Environment' => empty($item['Environment']) ? null : new EnvironmentResponse([
184-
'Variables' => !isset($item['Environment']['Variables']) ? null : $this->populateResultEnvironmentVariables($item['Environment']['Variables']),
185-
'Error' => empty($item['Environment']['Error']) ? null : new EnvironmentError([
186-
'ErrorCode' => isset($item['Environment']['Error']['ErrorCode']) ? (string) $item['Environment']['Error']['ErrorCode'] : null,
187-
'Message' => isset($item['Environment']['Error']['Message']) ? (string) $item['Environment']['Error']['Message'] : null,
188-
]),
189-
]),
190-
'KMSKeyArn' => isset($item['KMSKeyArn']) ? (string) $item['KMSKeyArn'] : null,
191-
'TracingConfig' => empty($item['TracingConfig']) ? null : new TracingConfigResponse([
192-
'Mode' => isset($item['TracingConfig']['Mode']) ? (string) $item['TracingConfig']['Mode'] : null,
193-
]),
194-
'MasterArn' => isset($item['MasterArn']) ? (string) $item['MasterArn'] : null,
195-
'RevisionId' => isset($item['RevisionId']) ? (string) $item['RevisionId'] : null,
196-
'Layers' => !isset($item['Layers']) ? null : $this->populateResultLayersReferenceList($item['Layers']),
197-
'State' => isset($item['State']) ? (string) $item['State'] : null,
198-
'StateReason' => isset($item['StateReason']) ? (string) $item['StateReason'] : null,
199-
'StateReasonCode' => isset($item['StateReasonCode']) ? (string) $item['StateReasonCode'] : null,
200-
'LastUpdateStatus' => isset($item['LastUpdateStatus']) ? (string) $item['LastUpdateStatus'] : null,
201-
'LastUpdateStatusReason' => isset($item['LastUpdateStatusReason']) ? (string) $item['LastUpdateStatusReason'] : null,
202-
'LastUpdateStatusReasonCode' => isset($item['LastUpdateStatusReasonCode']) ? (string) $item['LastUpdateStatusReasonCode'] : null,
203-
'FileSystemConfigs' => !isset($item['FileSystemConfigs']) ? null : $this->populateResultFileSystemConfigList($item['FileSystemConfigs']),
204-
'PackageType' => isset($item['PackageType']) ? (string) $item['PackageType'] : null,
205-
'ImageConfigResponse' => empty($item['ImageConfigResponse']) ? null : new ImageConfigResponse([
206-
'ImageConfig' => empty($item['ImageConfigResponse']['ImageConfig']) ? null : new ImageConfig([
207-
'EntryPoint' => !isset($item['ImageConfigResponse']['ImageConfig']['EntryPoint']) ? null : $this->populateResultStringList($item['ImageConfigResponse']['ImageConfig']['EntryPoint']),
208-
'Command' => !isset($item['ImageConfigResponse']['ImageConfig']['Command']) ? null : $this->populateResultStringList($item['ImageConfigResponse']['ImageConfig']['Command']),
209-
'WorkingDirectory' => isset($item['ImageConfigResponse']['ImageConfig']['WorkingDirectory']) ? (string) $item['ImageConfigResponse']['ImageConfig']['WorkingDirectory'] : null,
210-
]),
211-
'Error' => empty($item['ImageConfigResponse']['Error']) ? null : new ImageConfigError([
212-
'ErrorCode' => isset($item['ImageConfigResponse']['Error']['ErrorCode']) ? (string) $item['ImageConfigResponse']['Error']['ErrorCode'] : null,
213-
'Message' => isset($item['ImageConfigResponse']['Error']['Message']) ? (string) $item['ImageConfigResponse']['Error']['Message'] : null,
214-
]),
215-
]),
216-
'SigningProfileVersionArn' => isset($item['SigningProfileVersionArn']) ? (string) $item['SigningProfileVersionArn'] : null,
217-
'SigningJobArn' => isset($item['SigningJobArn']) ? (string) $item['SigningJobArn'] : null,
218-
'Architectures' => !isset($item['Architectures']) ? null : $this->populateResultArchitecturesList($item['Architectures']),
219-
'EphemeralStorage' => empty($item['EphemeralStorage']) ? null : new EphemeralStorage([
220-
'Size' => (int) $item['EphemeralStorage']['Size'],
221-
]),
222-
]);
236+
$items[] = $this->populateResultFunctionConfiguration($item);
223237
}
224238

225239
return $items;
226240
}
227241

242+
private function populateResultImageConfig(array $json): ImageConfig
243+
{
244+
return new ImageConfig([
245+
'EntryPoint' => !isset($json['EntryPoint']) ? null : $this->populateResultStringList($json['EntryPoint']),
246+
'Command' => !isset($json['Command']) ? null : $this->populateResultStringList($json['Command']),
247+
'WorkingDirectory' => isset($json['WorkingDirectory']) ? (string) $json['WorkingDirectory'] : null,
248+
]);
249+
}
250+
251+
private function populateResultImageConfigError(array $json): ImageConfigError
252+
{
253+
return new ImageConfigError([
254+
'ErrorCode' => isset($json['ErrorCode']) ? (string) $json['ErrorCode'] : null,
255+
'Message' => isset($json['Message']) ? (string) $json['Message'] : null,
256+
]);
257+
}
258+
259+
private function populateResultImageConfigResponse(array $json): ImageConfigResponse
260+
{
261+
return new ImageConfigResponse([
262+
'ImageConfig' => empty($json['ImageConfig']) ? null : $this->populateResultImageConfig($json['ImageConfig']),
263+
'Error' => empty($json['Error']) ? null : $this->populateResultImageConfigError($json['Error']),
264+
]);
265+
}
266+
267+
private function populateResultLayer(array $json): Layer
268+
{
269+
return new Layer([
270+
'Arn' => isset($json['Arn']) ? (string) $json['Arn'] : null,
271+
'CodeSize' => isset($json['CodeSize']) ? (string) $json['CodeSize'] : null,
272+
'SigningProfileVersionArn' => isset($json['SigningProfileVersionArn']) ? (string) $json['SigningProfileVersionArn'] : null,
273+
'SigningJobArn' => isset($json['SigningJobArn']) ? (string) $json['SigningJobArn'] : null,
274+
]);
275+
}
276+
228277
/**
229278
* @return Layer[]
230279
*/
231280
private function populateResultLayersReferenceList(array $json): array
232281
{
233282
$items = [];
234283
foreach ($json as $item) {
235-
$items[] = new Layer([
236-
'Arn' => isset($item['Arn']) ? (string) $item['Arn'] : null,
237-
'CodeSize' => isset($item['CodeSize']) ? (string) $item['CodeSize'] : null,
238-
'SigningProfileVersionArn' => isset($item['SigningProfileVersionArn']) ? (string) $item['SigningProfileVersionArn'] : null,
239-
'SigningJobArn' => isset($item['SigningJobArn']) ? (string) $item['SigningJobArn'] : null,
240-
]);
284+
$items[] = $this->populateResultLayer($item);
241285
}
242286

243287
return $items;
@@ -290,4 +334,20 @@ private function populateResultSubnetIds(array $json): array
290334

291335
return $items;
292336
}
337+
338+
private function populateResultTracingConfigResponse(array $json): TracingConfigResponse
339+
{
340+
return new TracingConfigResponse([
341+
'Mode' => isset($json['Mode']) ? (string) $json['Mode'] : null,
342+
]);
343+
}
344+
345+
private function populateResultVpcConfigResponse(array $json): VpcConfigResponse
346+
{
347+
return new VpcConfigResponse([
348+
'SubnetIds' => !isset($json['SubnetIds']) ? null : $this->populateResultSubnetIds($json['SubnetIds']),
349+
'SecurityGroupIds' => !isset($json['SecurityGroupIds']) ? null : $this->populateResultSecurityGroupIds($json['SecurityGroupIds']),
350+
'VpcId' => isset($json['VpcId']) ? (string) $json['VpcId'] : null,
351+
]);
352+
}
293353
}

src/Result/ListLayerVersionsResponse.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,22 @@ private function populateResultLayerVersionsList(array $json): array
134134
{
135135
$items = [];
136136
foreach ($json as $item) {
137-
$items[] = new LayerVersionsListItem([
138-
'LayerVersionArn' => isset($item['LayerVersionArn']) ? (string) $item['LayerVersionArn'] : null,
139-
'Version' => isset($item['Version']) ? (string) $item['Version'] : null,
140-
'Description' => isset($item['Description']) ? (string) $item['Description'] : null,
141-
'CreatedDate' => isset($item['CreatedDate']) ? (string) $item['CreatedDate'] : null,
142-
'CompatibleRuntimes' => !isset($item['CompatibleRuntimes']) ? null : $this->populateResultCompatibleRuntimes($item['CompatibleRuntimes']),
143-
'LicenseInfo' => isset($item['LicenseInfo']) ? (string) $item['LicenseInfo'] : null,
144-
'CompatibleArchitectures' => !isset($item['CompatibleArchitectures']) ? null : $this->populateResultCompatibleArchitectures($item['CompatibleArchitectures']),
145-
]);
137+
$items[] = $this->populateResultLayerVersionsListItem($item);
146138
}
147139

148140
return $items;
149141
}
142+
143+
private function populateResultLayerVersionsListItem(array $json): LayerVersionsListItem
144+
{
145+
return new LayerVersionsListItem([
146+
'LayerVersionArn' => isset($json['LayerVersionArn']) ? (string) $json['LayerVersionArn'] : null,
147+
'Version' => isset($json['Version']) ? (string) $json['Version'] : null,
148+
'Description' => isset($json['Description']) ? (string) $json['Description'] : null,
149+
'CreatedDate' => isset($json['CreatedDate']) ? (string) $json['CreatedDate'] : null,
150+
'CompatibleRuntimes' => !isset($json['CompatibleRuntimes']) ? null : $this->populateResultCompatibleRuntimes($json['CompatibleRuntimes']),
151+
'LicenseInfo' => isset($json['LicenseInfo']) ? (string) $json['LicenseInfo'] : null,
152+
'CompatibleArchitectures' => !isset($json['CompatibleArchitectures']) ? null : $this->populateResultCompatibleArchitectures($json['CompatibleArchitectures']),
153+
]);
154+
}
150155
}

0 commit comments

Comments
 (0)