Skip to content

Commit b150a40

Browse files
authored
Upgrade Psalm to 6.13 (#1973)
* Use `get_debug_type` for error reporting * Harden code against error cases * Upgrade Psalm to 6.13
1 parent c23ad4c commit b150a40

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
### Changed
1919

2020
- Apply new CodingStandard from latest php-cs-fixer.
21+
- Harden code against error cases
2122

2223
## 2.10.0
2324

src/S3Client.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3313,7 +3313,10 @@ protected function getEndpoint(string $uri, array $query, ?string $region): stri
33133313
return parent::getEndpoint($uri, $query, $region);
33143314
}
33153315

3316-
return preg_replace('|https?://|', '${0}' . $bucket . '.', parent::getEndpoint('/' . $uriWithOutBucket, $query, $region));
3316+
$endpoint = preg_replace('|https?://|', '${0}' . $bucket . '.', parent::getEndpoint('/' . $uriWithOutBucket, $query, $region));
3317+
\assert(null !== $endpoint); // We assume that the regex does not fail as we know it is valid.
3318+
3319+
return $endpoint;
33173320
}
33183321

33193322
protected function getEndpointMetadata(?string $region): array

src/Signer/SignerV4ForS3.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function __construct(string $scopeName, string $region, array $s3SignerOp
5555
$this->sendChunkedBody = $s3SignerOptions[Configuration::OPTION_SEND_CHUNKED_BODY] ?? false;
5656
unset($s3SignerOptions[Configuration::OPTION_SEND_CHUNKED_BODY]);
5757

58+
/**
59+
* @psalm-suppress TypeDoesNotContainType -- this validates the input without trusting the type alone.
60+
*/
5861
if (!empty($s3SignerOptions)) {
5962
throw new InvalidArgument(\sprintf('Invalid option(s) "%s" passed to "%s::%s". ', implode('", "', array_keys($s3SignerOptions)), __CLASS__, __METHOD__));
6063
}

0 commit comments

Comments
 (0)