From 6164ede03264af58ca8ea13d3e0f326eaf8caa0f Mon Sep 17 00:00:00 2001 From: LiHS Date: Tue, 12 Jul 2022 13:57:39 +0800 Subject: [PATCH] ignore php8.x type check and fix some type hint --- src/Qiniu/Auth.php | 5 +++-- src/Qiniu/Config.php | 4 ++++ src/Qiniu/Http/Client.php | 3 +++ src/Qiniu/Http/Header.php | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Qiniu/Auth.php b/src/Qiniu/Auth.php index dc013008..d99c365c 100644 --- a/src/Qiniu/Auth.php +++ b/src/Qiniu/Auth.php @@ -122,14 +122,15 @@ 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" ) { $data .= $body; } - return array($this->sign(utf8_encode($data)), null); + return array($this->sign($data), null); } public function verifyCallback($contentType, $originAuthorization, $url, $body) diff --git a/src/Qiniu/Config.php b/src/Qiniu/Config.php index 5bf413f7..a7becd6c 100644 --- a/src/Qiniu/Config.php +++ b/src/Qiniu/Config.php @@ -24,6 +24,10 @@ final class Config public $useHTTPS; //BOOL 是否使用CDN加速上传域名 public $useCdnDomains; + /** + * @var Region + */ + public $zone; // Zone Cache private $regionCache; diff --git a/src/Qiniu/Http/Client.php b/src/Qiniu/Http/Client.php index 3735aab4..fc6dace5 100644 --- a/src/Qiniu/Http/Client.php +++ b/src/Qiniu/Http/Client.php @@ -133,6 +133,9 @@ public static function sendRequest($request) private static function escapeQuotes($str) { + if (is_null($str)) { + return null; + } $find = array("\\", "\""); $replace = array("\\\\", "\\\""); return str_replace($find, $replace, $str); diff --git a/src/Qiniu/Http/Header.php b/src/Qiniu/Http/Header.php index 950e171c..944ff20f 100644 --- a/src/Qiniu/Http/Header.php +++ b/src/Qiniu/Http/Header.php @@ -111,6 +111,7 @@ public function getRawData() * * @return boolean */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function offsetExists($offset) { $key = self::normalizeKey($offset); @@ -122,6 +123,7 @@ public function offsetExists($offset) * * @return string|null */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function offsetGet($offset) { $key = self::normalizeKey($offset); @@ -138,6 +140,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function offsetSet($offset, $value) { $key = self::normalizeKey($offset); @@ -151,6 +154,7 @@ public function offsetSet($offset, $value) /** * @return void */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function offsetUnset($offset) { $key = self::normalizeKey($offset); @@ -160,6 +164,7 @@ public function offsetUnset($offset) /** * @return \ArrayIterator */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function getIterator() { $arr = array(); @@ -172,6 +177,7 @@ public function getIterator() /** * @return int */ + #[\ReturnTypeWillChange] // temporarily suppress the type check of php 8.x public function count() { return count($this->data);