From e992c14f5cea182b3341cfe687b6b00e0f2c88bb Mon Sep 17 00:00:00 2001 From: tianyiw Date: Sat, 26 Mar 2022 22:51:22 +0800 Subject: [PATCH 1/3] fix bugs: Auth.php > count($body) Header.php > During inheritance of ArrayAccess Header.php > count($this->data[$key] > 0) --- src/Qiniu/Auth.php | 5 +---- src/Qiniu/Http/Header.php | 8 +++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Qiniu/Auth.php b/src/Qiniu/Auth.php index 34dc2ee0..80da1c71 100644 --- a/src/Qiniu/Auth.php +++ b/src/Qiniu/Auth.php @@ -114,10 +114,7 @@ public function signQiniuAuthorization($urlString, $method = "GET", $body = "", // append body $data .= "\n\n"; - if (count($body) > 0 - && isset($headers["Content-Type"]) - && $headers["Content-Type"] != "application/octet-stream" - ) { + if (isset($headers["Content-Type"]) && $headers["Content-Type"] != "application/octet-stream") { $data .= $body; } diff --git a/src/Qiniu/Http/Header.php b/src/Qiniu/Http/Header.php index 2bf65c21..7fa3fafb 100644 --- a/src/Qiniu/Http/Header.php +++ b/src/Qiniu/Http/Header.php @@ -111,6 +111,7 @@ public function getRawData() * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { $key = self::normalizeKey($offset); @@ -122,6 +123,7 @@ public function offsetExists($offset) * * @return string|null */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { $key = self::normalizeKey($offset); @@ -138,10 +140,11 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { $key = self::normalizeKey($offset); - if (isset($this->data[$key]) && count($this->data[$key] > 0)) { + if (isset($this->data[$key]) && count($this->data[$key]) > 0) { $this->data[$key][0] = self::normalizeValue($value); } else { $this->data[$key] = array(self::normalizeValue($value)); @@ -151,6 +154,7 @@ public function offsetSet($offset, $value) /** * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { $key = self::normalizeKey($offset); @@ -160,6 +164,7 @@ public function offsetUnset($offset) /** * @return \ArrayIterator */ + #[\ReturnTypeWillChange] public function getIterator() { $arr = array(); @@ -172,6 +177,7 @@ public function getIterator() /** * @return int */ + #[\ReturnTypeWillChange] public function count() { return count($this->data); From cbb414d7e7cb60f021ca8cefea739ff7fed8e200 Mon Sep 17 00:00:00 2001 From: tianyiw Date: Sat, 26 Mar 2022 23:03:48 +0800 Subject: [PATCH 2/3] push From 746da87c8993e76213112b3e6a58c385eabe424a Mon Sep 17 00:00:00 2001 From: tianyiw Date: Thu, 7 Jul 2022 15:36:20 +0800 Subject: [PATCH 3/3] Compatible with PHP 8.2 --- src/Qiniu/Auth.php | 4 +++- src/Qiniu/Config.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Qiniu/Auth.php b/src/Qiniu/Auth.php index dc013008..6ba3bb41 100644 --- a/src/Qiniu/Auth.php +++ b/src/Qiniu/Auth.php @@ -122,7 +122,9 @@ public function signQiniuAuthorization($urlString, $method = "GET", $body = "", // append body $data .= "\n\n"; - if (strlen($body) > 0 + if ( + !is_null($body) + && strlen($body) > 0 && isset($headers["Content-Type"]) && $headers["Content-Type"] != "application/octet-stream" ) { diff --git a/src/Qiniu/Config.php b/src/Qiniu/Config.php index 5bf413f7..c20b53ab 100644 --- a/src/Qiniu/Config.php +++ b/src/Qiniu/Config.php @@ -1,6 +1,7 @@