Skip to content

Commit e80e79f

Browse files
authored
#2024 - Fixed deprecation warning for DateTimeInterface::RFC7231 (#2025)
* FIxed deprecation warning for DateTimeInterface::RFC7231 * fixed generated code * use string instead of constant * fixed generator * cs fix
1 parent facdf49 commit e80e79f

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

src/CodeGenerator/src/Generator/InputGenerator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,8 @@ private function stringify(string $variable, Member $member, string $part): stri
595595
throw new \InvalidArgumentException('Constant "\DateTimeInterface::' . $format . '" does not exists.');
596596
}
597597

598-
if ('RFC822' === $format) {
599-
$variable .= '->setTimezone(new \\DateTimeZone("GMT"))';
600-
$format = 'RFC7231';
598+
if ('RFC822' === $format || 'RFC7231' === $format) {
599+
return $variable . '->setTimezone(new \\DateTimeZone("GMT"))->format(\'D, d M Y H:i:s \G\M\T\')';
601600
}
602601

603602
return $variable . '->format(\DateTimeInterface::' . $format . ')';

src/Service/S3/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- AWS enhancement: Documentation updates.
2828
- Use a more stable sorting for the list of generated region metadata
2929
- Remove unnecessary `use` statements
30+
- Fix PHP 8.5 deprecation warning for `DateTimeInterface::RFC7231`
3031

3132
## 2.10.0
3233

src/Service/S3/src/Input/AbortMultipartUploadRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function request(): Request
178178
$headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
179179
}
180180
if (null !== $this->ifMatchInitiatedTime) {
181-
$headers['x-amz-if-match-initiated-time'] = $this->ifMatchInitiatedTime->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
181+
$headers['x-amz-if-match-initiated-time'] = $this->ifMatchInitiatedTime->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
182182
}
183183

184184
// Prepare query

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,13 @@ public function request(): Request
11671167
$headers['x-amz-copy-source-if-match'] = $this->copySourceIfMatch;
11681168
}
11691169
if (null !== $this->copySourceIfModifiedSince) {
1170-
$headers['x-amz-copy-source-if-modified-since'] = $this->copySourceIfModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
1170+
$headers['x-amz-copy-source-if-modified-since'] = $this->copySourceIfModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
11711171
}
11721172
if (null !== $this->copySourceIfNoneMatch) {
11731173
$headers['x-amz-copy-source-if-none-match'] = $this->copySourceIfNoneMatch;
11741174
}
11751175
if (null !== $this->copySourceIfUnmodifiedSince) {
1176-
$headers['x-amz-copy-source-if-unmodified-since'] = $this->copySourceIfUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
1176+
$headers['x-amz-copy-source-if-unmodified-since'] = $this->copySourceIfUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
11771177
}
11781178
if (null !== $this->expires) {
11791179
$headers['Expires'] = $this->expires;

src/Service/S3/src/Input/DeleteObjectRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function request(): Request
268268
$headers['If-Match'] = $this->ifMatch;
269269
}
270270
if (null !== $this->ifMatchLastModifiedTime) {
271-
$headers['x-amz-if-match-last-modified-time'] = $this->ifMatchLastModifiedTime->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
271+
$headers['x-amz-if-match-last-modified-time'] = $this->ifMatchLastModifiedTime->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
272272
}
273273
if (null !== $this->ifMatchSize) {
274274
$headers['x-amz-if-match-size'] = (string) $this->ifMatchSize;

src/Service/S3/src/Input/GetObjectRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,13 +501,13 @@ public function request(): Request
501501
$headers['If-Match'] = $this->ifMatch;
502502
}
503503
if (null !== $this->ifModifiedSince) {
504-
$headers['If-Modified-Since'] = $this->ifModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
504+
$headers['If-Modified-Since'] = $this->ifModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
505505
}
506506
if (null !== $this->ifNoneMatch) {
507507
$headers['If-None-Match'] = $this->ifNoneMatch;
508508
}
509509
if (null !== $this->ifUnmodifiedSince) {
510-
$headers['If-Unmodified-Since'] = $this->ifUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
510+
$headers['If-Unmodified-Since'] = $this->ifUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
511511
}
512512
if (null !== $this->range) {
513513
$headers['Range'] = $this->range;
@@ -557,7 +557,7 @@ public function request(): Request
557557
$query['response-content-type'] = $this->responseContentType;
558558
}
559559
if (null !== $this->responseExpires) {
560-
$query['response-expires'] = $this->responseExpires->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
560+
$query['response-expires'] = $this->responseExpires->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
561561
}
562562
if (null !== $this->versionId) {
563563
$query['versionId'] = $this->versionId;

src/Service/S3/src/Input/HeadObjectRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,13 @@ public function request(): Request
466466
$headers['If-Match'] = $this->ifMatch;
467467
}
468468
if (null !== $this->ifModifiedSince) {
469-
$headers['If-Modified-Since'] = $this->ifModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
469+
$headers['If-Modified-Since'] = $this->ifModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
470470
}
471471
if (null !== $this->ifNoneMatch) {
472472
$headers['If-None-Match'] = $this->ifNoneMatch;
473473
}
474474
if (null !== $this->ifUnmodifiedSince) {
475-
$headers['If-Unmodified-Since'] = $this->ifUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
475+
$headers['If-Unmodified-Since'] = $this->ifUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
476476
}
477477
if (null !== $this->range) {
478478
$headers['Range'] = $this->range;
@@ -522,7 +522,7 @@ public function request(): Request
522522
$query['response-content-type'] = $this->responseContentType;
523523
}
524524
if (null !== $this->responseExpires) {
525-
$query['response-expires'] = $this->responseExpires->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
525+
$query['response-expires'] = $this->responseExpires->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
526526
}
527527
if (null !== $this->versionId) {
528528
$query['versionId'] = $this->versionId;

src/Service/S3/src/Input/UploadPartCopyRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,13 @@ public function request(): Request
468468
$headers['x-amz-copy-source-if-match'] = $this->copySourceIfMatch;
469469
}
470470
if (null !== $this->copySourceIfModifiedSince) {
471-
$headers['x-amz-copy-source-if-modified-since'] = $this->copySourceIfModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
471+
$headers['x-amz-copy-source-if-modified-since'] = $this->copySourceIfModifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
472472
}
473473
if (null !== $this->copySourceIfNoneMatch) {
474474
$headers['x-amz-copy-source-if-none-match'] = $this->copySourceIfNoneMatch;
475475
}
476476
if (null !== $this->copySourceIfUnmodifiedSince) {
477-
$headers['x-amz-copy-source-if-unmodified-since'] = $this->copySourceIfUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
477+
$headers['x-amz-copy-source-if-unmodified-since'] = $this->copySourceIfUnmodifiedSince->setTimezone(new \DateTimeZone('GMT'))->format('D, d M Y H:i:s \G\M\T');
478478
}
479479
if (null !== $this->copySourceRange) {
480480
$headers['x-amz-copy-source-range'] = $this->copySourceRange;

0 commit comments

Comments
 (0)