@@ -212,7 +212,8 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * 连接签名方法 |
| 215 | - * @param $method string 请求方式 {GET, POST, PUT, DELETE} |
|
| 215 | + * @param string $method string 请求方式 {GET, POST, PUT, DELETE} |
|
| 216 | + * @param string $date |
|
| 216 | 217 | * @return string 签名字符串 |
| 217 | 218 | */ |
| 218 | 219 | private function sign($method, $uri, $date, $length) |
@@ -229,7 +230,7 @@ discard block |
||
| 229 | 230 | * @param array $headers 请求需要的特殊HTTP HEADERS |
| 230 | 231 | * @param array $body 需要POST发送的数据 |
| 231 | 232 | * @param null $file_handle |
| 232 | - * @return mixed |
|
| 233 | + * @return string |
|
| 233 | 234 | * @throws UpYunAuthorizationException |
| 234 | 235 | * @throws UpYunException |
| 235 | 236 | * @throws UpYunForbiddenException |
@@ -373,7 +374,7 @@ discard block |
||
| 373 | 374 | * |
| 374 | 375 | * @param string $header_string |
| 375 | 376 | * |
| 376 | - * @return mixed |
|
| 377 | + * @return string |
|
| 377 | 378 | */ |
| 378 | 379 | private function _getErrorMessage($header_string) |
| 379 | 380 | { |
@@ -405,6 +406,9 @@ discard block |
||
| 405 | 406 | |
| 406 | 407 | class UpYunAuthorizationException extends UpYunException |
| 407 | 408 | { |
| 409 | + /** |
|
| 410 | + * @param string|null $message |
|
| 411 | + */ |
|
| 408 | 412 | public function __construct($message, $code = 0, Exception $previous = null) |
| 409 | 413 | { |
| 410 | 414 | parent::__construct($message, 401, $previous); |
@@ -413,6 +417,9 @@ discard block |
||
| 413 | 417 | |
| 414 | 418 | class UpYunForbiddenException extends UpYunException |
| 415 | 419 | { |
| 420 | + /** |
|
| 421 | + * @param string|null $message |
|
| 422 | + */ |
|
| 416 | 423 | public function __construct($message, $code = 0, Exception $previous = null) |
| 417 | 424 | { |
| 418 | 425 | parent::__construct($message, 403, $previous); |
@@ -421,6 +428,9 @@ discard block |
||
| 421 | 428 | |
| 422 | 429 | class UpYunNotFoundException extends UpYunException |
| 423 | 430 | { |
| 431 | + /** |
|
| 432 | + * @param string|null $message |
|
| 433 | + */ |
|
| 424 | 434 | public function __construct($message, $code = 0, Exception $previous = null) |
| 425 | 435 | { |
| 426 | 436 | parent::__construct($message, 404, $previous); |
@@ -429,6 +439,9 @@ discard block |
||
| 429 | 439 | |
| 430 | 440 | class UpYunNotAcceptableException extends UpYunException |
| 431 | 441 | { |
| 442 | + /** |
|
| 443 | + * @param string|null $message |
|
| 444 | + */ |
|
| 432 | 445 | public function __construct($message, $code = 0, Exception $previous = null) |
| 433 | 446 | { |
| 434 | 447 | parent::__construct($message, 406, $previous); |
@@ -437,6 +450,9 @@ discard block |
||
| 437 | 450 | |
| 438 | 451 | class UpYunServiceUnavailable extends UpYunException |
| 439 | 452 | { |
| 453 | + /** |
|
| 454 | + * @param string|null $message |
|
| 455 | + */ |
|
| 440 | 456 | public function __construct($message, $code = 0, Exception $previous = null) |
| 441 | 457 | { |
| 442 | 458 | parent::__construct($message, 503, $previous); |
@@ -71,7 +71,9 @@ discard block |
||
| 71 | 71 | public function makeDir($path, $auto_mkdir = true) |
| 72 | 72 | { |
| 73 | 73 | $headers = array('Folder' => 'true'); |
| 74 | - if ($auto_mkdir) $headers['Mkdir'] = 'true'; |
|
| 74 | + if ($auto_mkdir) { |
|
| 75 | + $headers['Mkdir'] = 'true'; |
|
| 76 | + } |
|
| 75 | 77 | return $this->_do_request('PUT', $path, $headers); |
| 76 | 78 | } |
| 77 | 79 | |
@@ -97,12 +99,20 @@ discard block |
||
| 97 | 99 | */ |
| 98 | 100 | public function writeFile($path, $file, $auto_mkdir = true, $opts = NULL) |
| 99 | 101 | { |
| 100 | - if (is_null($opts)) $opts = array(); |
|
| 102 | + if (is_null($opts)) { |
|
| 103 | + $opts = array(); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | - if (!is_null($this->_content_md5)) $opts[self::CONTENT_MD5] = $this->_content_md5; |
|
| 103 | - if (!is_null($this->_file_secret)) $opts[self::CONTENT_SECRET] = $this->_file_secret; |
|
| 106 | + if (!is_null($this->_content_md5)) { |
|
| 107 | + $opts[self::CONTENT_MD5] = $this->_content_md5; |
|
| 108 | + } |
|
| 109 | + if (!is_null($this->_file_secret)) { |
|
| 110 | + $opts[self::CONTENT_SECRET] = $this->_file_secret; |
|
| 111 | + } |
|
| 104 | 112 | |
| 105 | - if ($auto_mkdir === true) $opts['Mkdir'] = 'true'; |
|
| 113 | + if ($auto_mkdir === true) { |
|
| 114 | + $opts['Mkdir'] = 'true'; |
|
| 115 | + } |
|
| 106 | 116 | |
| 107 | 117 | return $this->_do_request('PUT', $path, $opts, $file); |
| 108 | 118 | } |
@@ -299,7 +309,9 @@ discard block |
||
| 299 | 309 | $response = curl_exec($ch); |
| 300 | 310 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
| 301 | 311 | |
| 302 | - if ($http_code == 0) throw new UpYunException('Connection Failed', $http_code); |
|
| 312 | + if ($http_code == 0) { |
|
| 313 | + throw new UpYunException('Connection Failed', $http_code); |
|
| 314 | + } |
|
| 303 | 315 | |
| 304 | 316 | curl_close($ch); |
| 305 | 317 | |
@@ -48,8 +48,7 @@ |
||
| 48 | 48 | fclose($fh); |
| 49 | 49 | var_dump($rsp); |
| 50 | 50 | echo "=========DONE\r\n\r\n"; |
| 51 | -} |
|
| 52 | -catch(Exception $e) { |
|
| 51 | +} catch(Exception $e) { |
|
| 53 | 52 | echo $e->getCode(); |
| 54 | 53 | echo $e->getMessage(); |
| 55 | 54 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | $list = $upyun->getList('/demo/'); |
| 14 | 14 | var_dump($list); |
| 15 | 15 | echo "=========DONE\r\n\r\n"; |
| 16 | -} |
|
| 17 | -catch(Exception $e) { |
|
| 16 | +} catch(Exception $e) { |
|
| 18 | 17 | echo $e->getCode(); |
| 19 | 18 | echo $e->getMessage(); |
| 20 | 19 | } |