From 02588036c2ccef5621dfaa7ad5d8bb93f6ac01c1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Sun, 4 May 2025 11:20:26 +0200 Subject: [PATCH] FIX: oauth: php 8 warnings (#34027) * FIX: oauth: fix php 8 warnings (backport of https://github.com/daviddesberg/PHPoAuthLib/commit/9edfb1d113964c3ad23f32a9eb781c42189d7136) * FIX: oauth: fix php 8 warnings (backport of https://github.com/daviddesberg/PHPoAuthLib/commit/9edfb1d113964c3ad23f32a9eb781c42189d7136), part 2 --- .../OAuth/Common/Http/Client/AbstractClient.php | 17 ++++++++--------- .../OAuth/Common/Http/Client/CurlClient.php | 2 +- .../OAuth/Common/Http/Client/StreamClient.php | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/htdocs/includes/OAuth/Common/Http/Client/AbstractClient.php b/htdocs/includes/OAuth/Common/Http/Client/AbstractClient.php index 94000b18ce6..bbfc6de3759 100644 --- a/htdocs/includes/OAuth/Common/Http/Client/AbstractClient.php +++ b/htdocs/includes/OAuth/Common/Http/Client/AbstractClient.php @@ -59,15 +59,14 @@ abstract class AbstractClient implements ClientInterface /** * @param array $headers */ - public function normalizeHeaders(&$headers) + public function normalizeHeaders($headers): array { - // Normalize headers - array_walk( - $headers, - function (&$val, &$key) { - $key = ucfirst(strtolower($key)); - $val = ucfirst(strtolower($key)) . ': ' . $val; - } - ); + $normalizeHeaders = []; + foreach ($headers as $key => $val) { + $val = ucfirst(strtolower($key)) . ': ' . $val; + $normalizeHeaders[$key] = $val; + } + + return $normalizeHeaders; } } diff --git a/htdocs/includes/OAuth/Common/Http/Client/CurlClient.php b/htdocs/includes/OAuth/Common/Http/Client/CurlClient.php index eae1be3ed05..39650396fc1 100644 --- a/htdocs/includes/OAuth/Common/Http/Client/CurlClient.php +++ b/htdocs/includes/OAuth/Common/Http/Client/CurlClient.php @@ -70,7 +70,7 @@ class CurlClient extends AbstractClient // Normalize method name $method = strtoupper($method); - $this->normalizeHeaders($extraHeaders); + $extraHeaders = $this->normalizeHeaders($extraHeaders); if ($method === 'GET' && !empty($requestBody)) { throw new \InvalidArgumentException('No body expected for "GET" request.'); diff --git a/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php b/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php index 9849afd4a32..204835dd380 100644 --- a/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php +++ b/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php @@ -33,7 +33,7 @@ class StreamClient extends AbstractClient // Normalize method name $method = strtoupper($method); - $this->normalizeHeaders($extraHeaders); + $extraHeaders = $this->normalizeHeaders($extraHeaders); if ($method === 'GET' && !empty($requestBody)) { throw new \InvalidArgumentException('No body expected for "GET" request.');