Skip to content

Commit 80de39b

Browse files
authored
Merge pull request #241 from jemygraw/master
use `phpcs --standard=PSR2` to fix the code style
2 parents 66381af + fb9dc1a commit 80de39b

30 files changed

+119
-114
lines changed

examples/cdn_get_bandwidth.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
$granularity = "day";
2626

2727
//获取带宽数据
28-
list($bandwidthData, $getBandwidthErr) = $cdnManager->getBandwidthData($domains, $startDate, $endDate, $granularity);
28+
list($bandwidthData, $getBandwidthErr) = $cdnManager->getBandwidthData(
29+
$domains,
30+
$startDate,
31+
$endDate,
32+
$granularity
33+
);
34+
2935
if ($getBandwidthErr != null) {
3036
var_dump($getBandwidthErr);
3137
} else {
3238
echo "get bandwidth data success\n";
3339
print_r($bandwidthData);
34-
}
40+
}

examples/cdn_get_log_list.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"phpsdk.qiniudn.com"
1616
);
1717

18-
$logDate='2017-08-20';
18+
$logDate = '2017-08-20';
1919

2020
//获取日志下载链接
2121
//参考文档:http://developer.qiniu.com/article/fusion/api/log.html

examples/cdn_refresh_urls_dirs.php

-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@
5050
echo "refresh request sent\n";
5151
print_r($refreshResult);
5252
}
53-

examples/pfop_vframe.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
$notifyUrl = 'http://375dec79.ngrok.com/notify.php';
2121
$force = false;
2222

23-
$config =new \Qiniu\Config();
24-
$config->useHTTPS=true;
23+
$config = new \Qiniu\Config();
24+
$config->useHTTPS = true;
2525
$pfop = new PersistentFop($auth, $config);
2626

2727
//要进行视频截图操作
28-
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90|saveas/" . \Qiniu\base64_urlSafeEncode($bucket . ":qiniu_480x360.jpg");
28+
$fops = "vframe/jpg/offset/1/w/480/h/360/rotate/90|saveas/" .
29+
\Qiniu\base64_urlSafeEncode($bucket . ":qiniu_480x360.jpg");
2930

3031
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
3132
echo "\n====> pfop avthumb result: \n";

examples/pfop_watermark.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
$base64URL = Qiniu\base64_urlSafeEncode('http://devtools.qiniu.com/qiniu.png');
3232

3333
//水印参数
34-
$fops = "avthumb/mp4/s/640x360/vb/1.4m/image/" . $base64URL . "|saveas/" . \Qiniu\base64_urlSafeEncode($bucket . ":qiniu_wm.mp4");
34+
$fops = "avthumb/mp4/s/640x360/vb/1.4m/image/" . $base64URL . "|saveas/"
35+
. \Qiniu\base64_urlSafeEncode($bucket . ":qiniu_wm.mp4");
3536

3637
list($id, $err) = $pfop->execute($bucket, $key, $fops, $pipeline, $notifyUrl, $force);
3738
echo "\n====> pfop avthumb result: \n";

examples/qetag.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
require_once __DIR__ . '/../autoload.php';
33
use Qiniu\Etag;
44

5-
$localFile="/Users/jemy/Documents/qiniu.mp4";
5+
$localFile = "/Users/jemy/Documents/qiniu.mp4";
66
list($etag, $err) = Etag::sum($localFile);
77
if ($err == null) {
8-
echo "Etag: $etag";
8+
echo "Etag: $etag";
99
} else {
1010
var_dump($err);
1111
}

examples/rs_change_mime.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
$bucket = getenv('QINIU_TEST_BUCKET');
99

1010
$key = 'qiniu.mp4';
11-
$newMime='video/x-mp4';
11+
$newMime = 'video/x-mp4';
1212

1313
$auth = new Auth($accessKey, $secretKey);
1414
$config = new \Qiniu\Config();
1515
$bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
1616

17-
$err = $bucketManager->changeMime($bucket,$key,$newMime);
17+
$err = $bucketManager->changeMime($bucket, $key, $newMime);
1818
if ($err) {
1919
print_r($err);
2020
}

examples/rs_delete.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
$err = $bucketManager->delete($bucket, $key);
1515
if ($err) {
1616
print_r($err);
17-
}
17+
}

examples/rs_stat.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
$secretKey = getenv('QINIU_SECRET_KEY');
88
$bucket = getenv('QINIU_TEST_BUCKET');
99

10-
$key="qiniu.mp4";
10+
$key = "qiniu.mp4";
1111
$auth = new Auth($accessKey, $secretKey);
1212
$config = new \Qiniu\Config();
1313
$bucketManager = new \Qiniu\Storage\BucketManager($auth, $config);
14-
list($fileInfo,$err)=$bucketManager->stat($bucket, $key);
14+
list($fileInfo, $err) = $bucketManager->stat($bucket, $key);
1515
if ($err) {
1616
print_r($err);
1717
} else {

examples/rsf_list_files.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
echo "\n====> list file err: \n";
3131
var_dump($err);
3232
} else {
33-
if(array_key_exists('marker',$ret)) {
33+
if (array_key_exists('marker', $ret)) {
3434
echo "Marker:" . $ret["marker"] . "\n";
3535
}
3636
echo "\nList Iterms====>\n";

examples/saveas.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
$secretKey = 'Secret_Key';
1010

1111
//生成EncodedEntryURI的值
12-
$entry='<bucket>:<Key>';//<Key>为生成缩略图的文件名
12+
$entry = '<bucket>:<Key>';//<Key>为生成缩略图的文件名
1313
//生成的值
14-
$encodedEntryURI=\Qiniu\base64_urlSafeEncode($entry);
14+
$encodedEntryURI = \Qiniu\base64_urlSafeEncode($entry);
1515

1616
//使用SecretKey对新的下载URL进行HMAC1-SHA1签名
17-
$newurl = "78re52.com1.z0.glb.clouddn.com/resource/Ship.jpg?imageView2/2/w/200/h/200|saveas/".$encodedEntryURI;
17+
$newurl = "78re52.com1.z0.glb.clouddn.com/resource/Ship.jpg?imageView2/2/w/200/h/200|saveas/" . $encodedEntryURI;
1818

1919
$sign = hash_hmac("sha1", $newurl, $secretKey, true);
2020

2121
//对签名进行URL安全的Base64编码
2222
$encodedSign = \Qiniu\base64_urlSafeEncode($sign);
2323
//最终得到的完整下载URL
24-
$finalURL = "http://".$newurl."/sign/".$accessKey.":".$encodedSign;
24+
$finalURL = "http://" . $newurl . "/sign/" . $accessKey . ":" . $encodedSign;
2525

2626
$callbackBody = file_get_contents("$finalURL");
2727

examples/upload_and_pfop.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$token = $auth->uploadToken($bucket);
1616
$uploadMgr = new UploadManager();
1717

18-
$pfop = "imageMogr2/rotate/90|saveas/".\Qiniu\base64_urlSafeEncode($bucket.":php-logo-rotate.png");
18+
$pfop = "imageMogr2/rotate/90|saveas/" . \Qiniu\base64_urlSafeEncode($bucket . ":php-logo-rotate.png");
1919

2020
//转码完成后通知到你的业务服务器。(公网可以访问,并相应200 OK)
2121
$notifyUrl = 'http://notify.fake.com';

examples/upload_tokens.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
'persistentNotifyUrl' => "http://api.example.com/qiniu/pfop/notify",
6666
);
6767
$upToken = $auth->uploadToken($bucket, null, $expires, $policy, true);
68-
print($upToken . "\n");
68+
print($upToken . "\n");

src/Qiniu/Auth.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function uploadToken(
8787
$args = self::copyPolicy($args, $policy, $strictPolicy);
8888
$args['scope'] = $scope;
8989
$args['deadline'] = $deadline;
90-
90+
9191
$b = json_encode($args);
9292
return $this->signWithData($b);
9393
}
@@ -118,7 +118,7 @@ public function uploadToken(
118118
'persistentOps',
119119
'persistentNotifyUrl',
120120
'persistentPipeline',
121-
121+
122122
'deleteAfterDays',
123123
'fileType',
124124
'isPrefixalScope',
@@ -130,7 +130,7 @@ private static function copyPolicy(&$policy, $originPolicy, $strictPolicy)
130130
return array();
131131
}
132132
foreach ($originPolicy as $key => $value) {
133-
if (!$strictPolicy || in_array((string) $key, self::$policyFields, true)) {
133+
if (!$strictPolicy || in_array((string)$key, self::$policyFields, true)) {
134134
$policy[$key] = $value;
135135
}
136136
}

src/Qiniu/Cdn/CdnManager.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(Auth $auth)
1919
}
2020

2121
/**
22-
* @param array $urls 待刷新的文件链接数组
22+
* @param array $urls 待刷新的文件链接数组
2323
* @return array
2424
*/
2525
public function refreshUrls(array $urls)
@@ -28,7 +28,7 @@ public function refreshUrls(array $urls)
2828
}
2929

3030
/**
31-
* @param array $dirs 待刷新的文件链接数组
31+
* @param array $dirs 待刷新的文件链接数组
3232
* @return array
3333
* 目前客户默认没有目录刷新权限,刷新会有400038报错,参考:https://developer.qiniu.com/fusion/api/1229/cache-refresh
3434
* 需要刷新目录请工单联系技术支持 https://support.qiniu.com/tickets/category
@@ -82,9 +82,9 @@ public function prefetchUrls(array $urls)
8282
}
8383

8484
/**
85-
* @param array $domains 待获取带宽数据的域名数组
86-
* @param string $startDate 开始的日期,格式类似 2017-01-01
87-
* @param string $endDate 结束的日期,格式类似 2017-01-01
85+
* @param array $domains 待获取带宽数据的域名数组
86+
* @param string $startDate 开始的日期,格式类似 2017-01-01
87+
* @param string $endDate 结束的日期,格式类似 2017-01-01
8888
* @param string $granularity 获取数据的时间间隔,可以是 5min, hour 或者 day
8989
*
9090
* @return array 带宽数据和错误信息,参考 examples/cdn_manager.php 代码
@@ -105,9 +105,9 @@ public function getBandwidthData(array $domains, $startDate, $endDate, $granular
105105
}
106106

107107
/**
108-
* @param array $domains 待获取流量数据的域名数组
109-
* @param string $startDate 开始的日期,格式类似 2017-01-01
110-
* @param string $endDate 结束的日期,格式类似 2017-01-01
108+
* @param array $domains 待获取流量数据的域名数组
109+
* @param string $startDate 开始的日期,格式类似 2017-01-01
110+
* @param string $endDate 结束的日期,格式类似 2017-01-01
111111
* @param string $granularity 获取数据的时间间隔,可以是 5min, hour 或者 day
112112
*
113113
* @return array 流量数据和错误信息,参考 examples/cdn_manager.php 代码
@@ -128,7 +128,7 @@ public function getFluxData(array $domains, $startDate, $endDate, $granularity)
128128
}
129129

130130
/**
131-
* @param array $domains 待获取日志下载链接的域名数组
131+
* @param array $domains 待获取日志下载链接的域名数组
132132
* @param string $logDate 获取指定日期的日志下载链接,格式类似 2017-01-01
133133
*
134134
* @return array 日志下载链接数据和错误信息,参考 examples/cdn_manager.php 代码
@@ -161,9 +161,9 @@ private function post($url, $body)
161161
/**
162162
* 构建时间戳防盗链鉴权的访问外链
163163
*
164-
* @param string $rawUrl 需要签名的资源url
165-
* @param string $encryptKey 时间戳防盗链密钥
166-
* @param string $durationInSeconds 链接的有效期(以秒为单位)
164+
* @param string $rawUrl 需要签名的资源url
165+
* @param string $encryptKey 时间戳防盗链密钥
166+
* @param string $durationInSeconds 链接的有效期(以秒为单位)
167167
*
168168
* @return string 带鉴权信息的资源外链,参考 examples/cdn_timestamp_antileech.php 代码
169169
*/

src/Qiniu/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getUpHost($accessKey, $bucket)
4949

5050
public function getUpBackupHost($accessKey, $bucket)
5151
{
52-
$zone=$this->getZone($accessKey, $bucket);
52+
$zone = $this->getZone($accessKey, $bucket);
5353
if ($this->useHTTPS === true) {
5454
$scheme = "https://";
5555
} else {

src/Qiniu/Etag.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function sum($filename)
3838

3939
$fstat = fstat($fhandler);
4040
$fsize = $fstat['size'];
41-
if ((int) $fsize === 0) {
41+
if ((int)$fsize === 0) {
4242
fclose($fhandler);
4343
return array('Fto5o-5ea0sNMlW_75VgGJCv2AcJ', null);
4444
}
@@ -52,12 +52,12 @@ public static function sum($filename)
5252
fclose($fhandler);
5353
return array(null, $err);
5454
}
55-
list($sha1Code, ) = self::calcSha1($fdata);
55+
list($sha1Code,) = self::calcSha1($fdata);
5656
$sha1Buf = array_merge($sha1Buf, $sha1Code);
5757
} else {
5858
array_push($sha1Buf, 0x96);
5959
$sha1BlockBuf = array();
60-
for ($i=0; $i < $blockCnt; $i++) {
60+
for ($i = 0; $i < $blockCnt; $i++) {
6161
$fdata = fread($fhandler, Config::BLOCK_SIZE);
6262
list($sha1Code, $err) = self::calcSha1($fdata);
6363
if ($err !== null) {
@@ -67,7 +67,7 @@ public static function sum($filename)
6767
$sha1BlockBuf = array_merge($sha1BlockBuf, $sha1Code);
6868
}
6969
$tmpData = self::packArray('C*', $sha1BlockBuf);
70-
list($sha1Final, ) = self::calcSha1($tmpData);
70+
list($sha1Final,) = self::calcSha1($tmpData);
7171
$sha1Buf = array_merge($sha1Buf, $sha1Final);
7272
}
7373
$etag = \Qiniu\base64_urlSafeEncode(self::packArray('C*', $sha1Buf));

src/Qiniu/Http/Client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function sendRequest($request)
8282
CURLOPT_SSL_VERIFYHOST => false,
8383
CURLOPT_HEADER => true,
8484
CURLOPT_NOBODY => false,
85-
CURLOPT_CUSTOMREQUEST => $request->method,
85+
CURLOPT_CUSTOMREQUEST => $request->method,
8686
CURLOPT_URL => $request->url
8787
);
8888

@@ -106,7 +106,7 @@ public static function sendRequest($request)
106106
curl_setopt_array($ch, $options);
107107
$result = curl_exec($ch);
108108
$t2 = microtime(true);
109-
$duration = round($t2-$t1, 3);
109+
$duration = round($t2 - $t1, 3);
110110
$ret = curl_errno($ch);
111111
if ($ret !== 0) {
112112
$r = new Response(-1, $duration, array(), null, curl_error($ch));
@@ -128,7 +128,7 @@ private static function parseHeaders($raw)
128128
foreach ($headerLines as $line) {
129129
$headerLine = trim($line);
130130
$kv = explode(':', $headerLine);
131-
if (count($kv) >1) {
131+
if (count($kv) > 1) {
132132
$headers[$kv[0]] = trim($kv[1]);
133133
}
134134
}

src/Qiniu/Http/Response.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct($code, $duration, array $headers = array(), $body =
104104
if (self::isJson($headers)) {
105105
try {
106106
$jsonData = self::bodyJson($body);
107-
if ($code >=400) {
107+
if ($code >= 400) {
108108
$this->error = $body;
109109
if ($jsonData['error'] !== null) {
110110
$this->error = $jsonData['error'];
@@ -117,7 +117,7 @@ public function __construct($code, $duration, array $headers = array(), $body =
117117
$this->error = $e->getMessage();
118118
}
119119
}
120-
} elseif ($code >=400) {
120+
} elseif ($code >= 400) {
121121
$this->error = $body;
122122
}
123123
return;
@@ -130,7 +130,7 @@ public function json()
130130

131131
private static function bodyJson($body)
132132
{
133-
return \Qiniu\json_decode((string) $body, true, 512);
133+
return \Qiniu\json_decode((string)$body, true, 512);
134134
}
135135

136136
public function xVia()
@@ -163,7 +163,7 @@ public function ok()
163163
public function needRetry()
164164
{
165165
$code = $this->statusCode;
166-
if ($code< 0 || ($code / 100 === 5 and $code !== 579) || $code === 996) {
166+
if ($code < 0 || ($code / 100 === 5 and $code !== 579) || $code === 996) {
167167
return true;
168168
}
169169
}

0 commit comments

Comments
 (0)