Skip to content

Commit 432a9c9

Browse files
authored
Fix deprecation for null array offset on PHP 8.5 (#1960)
1 parent a528bd5 commit 432a9c9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Changed
66

77
- Apply no CodingStandard from latest php-cs-fixer.
8+
- Fix PHP 8.5 deprecation by avoiding using `null` as an array offset.
89

910
### Fixed
1011

@@ -15,7 +16,7 @@
1516

1617
### Fixed
1718

18-
- SignerV4: fix sort of query parameters to build correct canoncal query string
19+
- SignerV4: fix sort of query parameters to build correct canonical query string
1920

2021
## 1.27.0
2122

src/AbstractApi.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,14 @@ private function getDiscoveredEndpoint(string $uri, array $query, ?string $regio
324324
*/
325325
private function getSigner(?string $region): Signer
326326
{
327-
/** @var string $region */
328327
$region = $region ?? ($this->configuration->isDefault('region') ? null : $this->configuration->get('region'));
329-
if (!isset($this->signers[$region])) {
328+
if (!isset($this->signers[$region ?? ''])) {
330329
$factories = $this->getSignerFactories();
331330
$factory = null;
332331
if ($this->configuration->isDefault('endpoint') || $this->configuration->isDefault('region')) {
333332
$metadata = $this->getEndpointMetadata($region);
334333
} else {
334+
\assert(null !== $region);
335335
// Allow non-aws region with custom endpoint
336336
$metadata = $this->getEndpointMetadata(Configuration::DEFAULT_REGION);
337337
$metadata['signRegion'] = $region;
@@ -349,10 +349,9 @@ private function getSigner(?string $region): Signer
349349
throw new InvalidArgument(\sprintf('None of the signatures "%s" is implemented.', implode(', ', $metadata['signVersions'])));
350350
}
351351

352-
$this->signers[$region] = $factory($metadata['signService'], $metadata['signRegion']);
352+
$this->signers[$region ?? ''] = $factory($metadata['signService'], $metadata['signRegion']);
353353
}
354354

355-
/** @psalm-suppress PossiblyNullArrayOffset */
356-
return $this->signers[$region];
355+
return $this->signers[$region ?? ''];
357356
}
358357
}

0 commit comments

Comments
 (0)