Skip to content

Commit d058fe2

Browse files
authored
Fix blank line after if block in headers generation (#1382)
Fix blank line afweter if in Headers generation
1 parent d5854a5 commit d058fe2

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/CodeGenerator/src/Generator/InputGenerator.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild
306306
$body['querystring'] = '$query = [];' . "\n";
307307

308308
$usesEndpointDiscovery = $operation->usesEndpointDiscovery();
309-
foreach (['header' => '$headers', 'querystring' => '$query', 'uri' => '$uri'] as $requestPart => $varName) {
309+
$requestParts = ['header' => '$headers', 'querystring' => '$query', 'uri' => '$uri'];
310+
foreach ($requestParts as $requestPart => $varName) {
310311
foreach ($inputShape->getMembers() as $member) {
311312
// If location is not specified, it will go in the request body.
312313
if ($requestPart !== $member->getLocation()) {
@@ -373,9 +374,6 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild
373374
}
374375
$body[$requestPart] .= $bodyCode . "\n";
375376
}
376-
if (isset($body[$requestPart])) {
377-
$body[$requestPart] = implode("\n", array_filter(array_map('trim', explode("\n", $body[$requestPart]))));
378-
}
379377
}
380378

381379
// "headers" are not "header"
@@ -406,7 +404,13 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild
406404
'LOCATION' => $member->getLocationName() ?? $member->getName(),
407405
'VALUE' => $inputElement,
408406
]);
409-
$body['header'] .= implode("\n", array_filter(array_map('trim', explode("\n", $bodyCode))));
407+
$body['header'] .= $bodyCode . "\n";
408+
}
409+
410+
foreach (array_keys($requestParts) as $requestPart) {
411+
if (isset($body[$requestPart])) {
412+
$body[$requestPart] = implode("\n", array_filter(array_map('trim', explode("\n", $body[$requestPart]))));
413+
}
410414
}
411415

412416
if ($operation->hasBody()) {

src/Service/S3/src/Input/CopyObjectRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ public function request(): Request
820820
}
821821
if (null !== $this->expectedSourceBucketOwner) {
822822
$headers['x-amz-source-expected-bucket-owner'] = $this->expectedSourceBucketOwner;
823-
}if (null !== $this->metadata) {
823+
}
824+
if (null !== $this->metadata) {
824825
foreach ($this->metadata as $key => $value) {
825826
$headers["x-amz-meta-$key"] = $value;
826827
}

src/Service/S3/src/Input/CreateMultipartUploadRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ public function request(): Request
608608
throw new InvalidArgument(sprintf('Invalid parameter "ChecksumAlgorithm" for "%s". The value "%s" is not a valid "ChecksumAlgorithm".', __CLASS__, $this->checksumAlgorithm));
609609
}
610610
$headers['x-amz-checksum-algorithm'] = $this->checksumAlgorithm;
611-
}if (null !== $this->metadata) {
611+
}
612+
if (null !== $this->metadata) {
612613
foreach ($this->metadata as $key => $value) {
613614
$headers["x-amz-meta-$key"] = $value;
614615
}

src/Service/S3/src/Input/PutObjectRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ public function request(): Request
775775
}
776776
if (null !== $this->expectedBucketOwner) {
777777
$headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
778-
}if (null !== $this->metadata) {
778+
}
779+
if (null !== $this->metadata) {
779780
foreach ($this->metadata as $key => $value) {
780781
$headers["x-amz-meta-$key"] = $value;
781782
}

0 commit comments

Comments
 (0)