From 8371ba0f3148bdcea44920130aa47e00473d3d6a Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 27 Aug 2023 10:49:26 +0100 Subject: [PATCH] Fix issue where PHP transforms numeric strings in array keys to ints --- src/Message.php | 2 +- src/MessageTrait.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Message.php b/src/Message.php index 9b74b8d4..6e6c3e51 100644 --- a/src/Message.php +++ b/src/Message.php @@ -33,7 +33,7 @@ public static function toString(MessageInterface $message): string } foreach ($message->getHeaders() as $name => $values) { - if (strtolower($name) === 'set-cookie') { + if (is_string($name) && strtolower($name) === 'set-cookie') { foreach ($values as $value) { $msg .= "\r\n{$name}: ".$value; } diff --git a/src/MessageTrait.php b/src/MessageTrait.php index a85d3ab2..e05ebea8 100644 --- a/src/MessageTrait.php +++ b/src/MessageTrait.php @@ -12,10 +12,10 @@ */ trait MessageTrait { - /** @var array Map of all registered headers, as original name => array of values */ + /** @var string[][] Map of all registered headers, as original name => array of values */ private $headers = []; - /** @var array Map of lowercase header name => original name at registration */ + /** @var string[] Map of lowercase header name => original name at registration */ private $headerNames = []; /** @var string */