Skip to content

Commit 4ce350e

Browse files
authored
Differentiate empty list to not set list (#668)
1 parent 99a1c57 commit 4ce350e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Input/PublishLayerVersionRequest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final class PublishLayerVersionRequest extends Input
4141
*
4242
* @see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
4343
*
44-
* @var list<Runtime::*>
44+
* @var null|list<Runtime::*>
4545
*/
4646
private $CompatibleRuntimes;
4747

@@ -67,7 +67,7 @@ public function __construct(array $input = [])
6767
$this->LayerName = $input['LayerName'] ?? null;
6868
$this->Description = $input['Description'] ?? null;
6969
$this->Content = isset($input['Content']) ? LayerVersionContentInput::create($input['Content']) : null;
70-
$this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? [];
70+
$this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? null;
7171
$this->LicenseInfo = $input['LicenseInfo'] ?? null;
7272
parent::__construct($input);
7373
}
@@ -82,7 +82,7 @@ public static function create($input): self
8282
*/
8383
public function getCompatibleRuntimes(): array
8484
{
85-
return $this->CompatibleRuntimes;
85+
return $this->CompatibleRuntimes ?? [];
8686
}
8787

8888
public function getContent(): ?LayerVersionContentInput
@@ -181,16 +181,17 @@ private function requestBody(): array
181181
throw new InvalidArgument(sprintf('Missing parameter "Content" for "%s". The value cannot be null.', __CLASS__));
182182
}
183183
$payload['Content'] = $v->requestBody();
184-
185-
$index = -1;
186-
foreach ($this->CompatibleRuntimes as $listValue) {
187-
++$index;
188-
if (!Runtime::exists($listValue)) {
189-
throw new InvalidArgument(sprintf('Invalid parameter "CompatibleRuntimes" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $listValue));
184+
if (null !== $v = $this->CompatibleRuntimes) {
185+
$index = -1;
186+
$payload['CompatibleRuntimes'] = [];
187+
foreach ($v as $listValue) {
188+
++$index;
189+
if (!Runtime::exists($listValue)) {
190+
throw new InvalidArgument(sprintf('Invalid parameter "CompatibleRuntimes" for "%s". The value "%s" is not a valid "Runtime".', __CLASS__, $listValue));
191+
}
192+
$payload['CompatibleRuntimes'][$index] = $listValue;
190193
}
191-
$payload['CompatibleRuntimes'][$index] = $listValue;
192194
}
193-
194195
if (null !== $v = $this->LicenseInfo) {
195196
$payload['LicenseInfo'] = $v;
196197
}

src/ValueObject/LayerVersionsListItem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(array $input)
5252
$this->Version = $input['Version'] ?? null;
5353
$this->Description = $input['Description'] ?? null;
5454
$this->CreatedDate = $input['CreatedDate'] ?? null;
55-
$this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? [];
55+
$this->CompatibleRuntimes = $input['CompatibleRuntimes'] ?? null;
5656
$this->LicenseInfo = $input['LicenseInfo'] ?? null;
5757
}
5858

@@ -66,7 +66,7 @@ public static function create($input): self
6666
*/
6767
public function getCompatibleRuntimes(): array
6868
{
69-
return $this->CompatibleRuntimes;
69+
return $this->CompatibleRuntimes ?? [];
7070
}
7171

7272
public function getCreatedDate(): ?string

0 commit comments

Comments
 (0)