From 599a1d2c5cd07bf3c03ae5f234063e11da805208 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 30 Aug 2023 09:12:39 +0800 Subject: [PATCH] * Fix bug #37757. --- .../Utility/CaseInsensitiveDictionary.php | 162 +++++++++--------- 1 file changed, 84 insertions(+), 78 deletions(-) diff --git a/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php b/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php index 4914480c54..049add14b7 100644 --- a/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php +++ b/lib/requests/Requests/Utility/CaseInsensitiveDictionary.php @@ -13,91 +13,97 @@ * @subpackage Utilities */ class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate { - /** - * Actual item data - * - * @var array - */ - protected $data = array(); + /** + * Actual item data + * + * @var array + */ + protected $data = array(); - /** - * Creates a case insensitive dictionary. - * - * @param array $data Dictionary/map to convert to case-insensitive - */ - public function __construct(array $data = array()) { - foreach ($data as $key => $value) { - $this->offsetSet($key, $value); - } - } + /** + * Creates a case insensitive dictionary. + * + * @param array $data Dictionary/map to convert to case-insensitive + */ + public function __construct(array $data = array()) { + foreach ($data as $key => $value) { + $this->offsetSet($key, $value); + } + } - /** - * Check if the given item exists - * - * @param string $key Item key - * @return boolean Does the item exist? - */ - public function offsetExists($key): bool { - $key = strtolower($key); - return isset($this->data[$key]); - } + /** + * Check if the given item exists + * + * @param string $key Item key + * @return boolean Does the item exist? + */ + #[\ReturnTypeWillChange] + public function offsetExists($key): bool { + $key = strtolower($key); + return isset($this->data[$key]); + } - /** - * Get the value for the item - * - * @param string $key Item key - * @return string|null Item value (null if offsetExists is false) - */ - public function offsetGet($key): string|null { - $key = strtolower($key); - if (!isset($this->data[$key])) { - return null; - } + /** + * Get the value for the item + * + * @param string $key Item key + * @return string|null Item value (null if offsetExists is false) + */ + #[\ReturnTypeWillChange] + public function offsetGet($key): string|null { + $key = strtolower($key); + if (!isset($this->data[$key])) { + return null; + } - return $this->data[$key]; - } + return $this->data[$key]; + } - /** - * Set the given item - * - * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) - * - * @param string $key Item name - * @param string $value Item value - */ - public function offsetSet($key, $value): void { - if ($key === null) { - throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); - } + /** + * Set the given item + * + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) + * + * @param string $key Item name + * @param string $value Item value + */ + #[\ReturnTypeWillChange] + public function offsetSet($key, $value): void { + if ($key === null) { + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); + } - $key = strtolower($key); - $this->data[$key] = $value; - } + $key = strtolower($key); + $this->data[$key] = $value; + } - /** - * Unset the given header - * - * @param string $key - */ - public function offsetUnset($key): void { - unset($this->data[strtolower($key)]); - } + /** + * Unset the given header + * + * @param string $key + */ + #[\ReturnTypeWillChange] + public function offsetUnset($key): void { + unset($this->data[strtolower($key)]); + } - /** - * Get an iterator for the data - * - * @return ArrayIterator - */ - public function getIterator(): ArrayIterator { - return new ArrayIterator($this->data); - } + /** + * Get an iterator for the data + * + * @return ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator(): ArrayIterator { + return new ArrayIterator($this->data); + } - /** - * Get the headers as an array - * - * @return array Header data - */ - public function getAll() { - return $this->data; - } + /** + * Get the headers as an array + * + * @return array Header data + */ + #[\ReturnTypeWillChange] + public function getAll() { + return $this->data; + } }