From 33be77aab1bbb6c8fcd7d31d32350674cf89b739 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 17 Oct 2025 11:32:55 +0200 Subject: [PATCH] Fix deprecation for null array offset on PHP 8.5 --- src/Core/CHANGELOG.md | 3 ++- src/Core/src/AbstractApi.php | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Core/CHANGELOG.md b/src/Core/CHANGELOG.md index fc8c2e7ae..273924d1e 100644 --- a/src/Core/CHANGELOG.md +++ b/src/Core/CHANGELOG.md @@ -5,6 +5,7 @@ ### Changed - Apply no CodingStandard from latest php-cs-fixer. +- Fix PHP 8.5 deprecation by avoiding using `null` as an array offset. ### Fixed @@ -15,7 +16,7 @@ ### Fixed -- SignerV4: fix sort of query parameters to build correct canoncal query string +- SignerV4: fix sort of query parameters to build correct canonical query string ## 1.27.0 diff --git a/src/Core/src/AbstractApi.php b/src/Core/src/AbstractApi.php index 4350f527c..f70082119 100644 --- a/src/Core/src/AbstractApi.php +++ b/src/Core/src/AbstractApi.php @@ -324,14 +324,14 @@ private function getDiscoveredEndpoint(string $uri, array $query, ?string $regio */ private function getSigner(?string $region): Signer { - /** @var string $region */ $region = $region ?? ($this->configuration->isDefault('region') ? null : $this->configuration->get('region')); - if (!isset($this->signers[$region])) { + if (!isset($this->signers[$region ?? ''])) { $factories = $this->getSignerFactories(); $factory = null; if ($this->configuration->isDefault('endpoint') || $this->configuration->isDefault('region')) { $metadata = $this->getEndpointMetadata($region); } else { + \assert(null !== $region); // Allow non-aws region with custom endpoint $metadata = $this->getEndpointMetadata(Configuration::DEFAULT_REGION); $metadata['signRegion'] = $region; @@ -349,10 +349,9 @@ private function getSigner(?string $region): Signer throw new InvalidArgument(\sprintf('None of the signatures "%s" is implemented.', implode(', ', $metadata['signVersions']))); } - $this->signers[$region] = $factory($metadata['signService'], $metadata['signRegion']); + $this->signers[$region ?? ''] = $factory($metadata['signService'], $metadata['signRegion']); } - /** @psalm-suppress PossiblyNullArrayOffset */ - return $this->signers[$region]; + return $this->signers[$region ?? '']; } }