Passed
Push — v6 ( ba732b...0da0a0 )
by 光春
03:16
created
src/service/QqWryService.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
             throw new DtaException('请检查配置文件是否配置了IP数据库文件存放位置');
80 80
         }
81 81
         $this->fp = 0;
82
-        if (($this->fp = fopen($this->ipPath . 'qqwry.dat', 'rb')) !== false) {
82
+        if (($this->fp = fopen($this->ipPath.'qqwry.dat', 'rb')) !== false) {
83 83
             $this->firstIp = $this->getLong();
84 84
             $this->lastIp = $this->getLong();
85
-            $this->totalIp = ($this->lastIp - $this->firstIp) / 7;
85
+            $this->totalIp = ($this->lastIp-$this->firstIp)/7;
86 86
         }
87 87
         parent::__construct($app);
88 88
     }
@@ -163,49 +163,49 @@  discard block
 block discarded – undo
163 163
                 // 如果数据文件没有被正确打开,则直接返回错误
164 164
                 throw new DtaException('数据库文件不存在!');
165 165
             }
166
-            $location['ip'] = $ip;   // 将输入的域名转化为IP地址
167
-            $ip = $this->packIp($location['ip']);   // 将输入的IP地址转化为可比较的IP地址
166
+            $location['ip'] = $ip; // 将输入的域名转化为IP地址
167
+            $ip = $this->packIp($location['ip']); // 将输入的IP地址转化为可比较的IP地址
168 168
             // 不合法的IP地址会被转化为255.255.255.255
169 169
             // 对分搜索
170
-            $l = 0;                         // 搜索的下边界
171
-            $u = $this->totalIp;            // 搜索的上边界
172
-            $findip = $this->lastIp;        // 如果没有找到就返回最后一条IP记录(QQWry.Dat的版本信息)
170
+            $l = 0; // 搜索的下边界
171
+            $u = $this->totalIp; // 搜索的上边界
172
+            $findip = $this->lastIp; // 如果没有找到就返回最后一条IP记录(QQWry.Dat的版本信息)
173 173
             while ($l <= $u) {              // 当上边界小于下边界时,查找失败
174
-                $i = floor(($l + $u) / 2);  // 计算近似中间记录
175
-                fseek($this->fp, $this->firstIp + $i * 7);
176
-                $beginip = strrev(fread($this->fp, 4));     // 获取中间记录的开始IP地址
174
+                $i = floor(($l+$u)/2); // 计算近似中间记录
175
+                fseek($this->fp, $this->firstIp+$i*7);
176
+                $beginip = strrev(fread($this->fp, 4)); // 获取中间记录的开始IP地址
177 177
                 // strrev函数在这里的作用是将little-endian的压缩IP地址转化为big-endian的格式
178 178
                 // 以便用于比较,后面相同。
179 179
                 if ($ip < $beginip) {       // 用户的IP小于中间记录的开始IP地址时
180
-                    $u = $i - 1;            // 将搜索的上边界修改为中间记录减一
181
-                } else {
180
+                    $u = $i-1; // 将搜索的上边界修改为中间记录减一
181
+                }else {
182 182
                     fseek($this->fp, $this->getLong3());
183
-                    $endip = strrev(fread($this->fp, 4));   // 获取中间记录的结束IP地址
183
+                    $endip = strrev(fread($this->fp, 4)); // 获取中间记录的结束IP地址
184 184
                     if ($ip > $endip) {     // 用户的IP大于中间记录的结束IP地址时
185
-                        $l = $i + 1;        // 将搜索的下边界修改为中间记录加一
186
-                    } else {                  // 用户的IP在中间记录的IP范围内时
187
-                        $findip = $this->firstIp + $i * 7;
188
-                        break;              // 则表示找到结果,退出循环
185
+                        $l = $i+1; // 将搜索的下边界修改为中间记录加一
186
+                    }else {                  // 用户的IP在中间记录的IP范围内时
187
+                        $findip = $this->firstIp+$i*7;
188
+                        break; // 则表示找到结果,退出循环
189 189
                     }
190 190
                 }
191 191
             }
192 192
             //获取查找到的IP地理位置信息
193 193
             fseek($this->fp, $findip);
194
-            $location['beginip'] = long2ip($this->getLong());   // 用户IP所在范围的开始地址
194
+            $location['beginip'] = long2ip($this->getLong()); // 用户IP所在范围的开始地址
195 195
             $offset = $this->getLong3();
196 196
             fseek($this->fp, $offset);
197
-            $location['endip'] = long2ip($this->getLong());     // 用户IP所在范围的结束地址
198
-            $byte = fread($this->fp, 1);    // 标志字节
197
+            $location['endip'] = long2ip($this->getLong()); // 用户IP所在范围的结束地址
198
+            $byte = fread($this->fp, 1); // 标志字节
199 199
             switch (ord($byte)) {
200 200
                 case 1:                     // 标志字节为1,表示国家和区域信息都被同时重定向
201
-                    $countryOffset = $this->getLong3();         // 重定向地址
201
+                    $countryOffset = $this->getLong3(); // 重定向地址
202 202
                     fseek($this->fp, $countryOffset);
203
-                    $byte = fread($this->fp, 1);    // 标志字节
203
+                    $byte = fread($this->fp, 1); // 标志字节
204 204
                     switch (ord($byte)) {
205 205
                         case 2:             // 标志字节为2,表示国家信息又被重定向
206 206
                             fseek($this->fp, $this->getLong3());
207 207
                             $location['all'] = $this->getString();
208
-                            fseek($this->fp, $countryOffset + 4);
208
+                            fseek($this->fp, $countryOffset+4);
209 209
                             $location['extend'] = $this->getExtendString();
210 210
                             break;
211 211
                         default:            // 否则,表示国家信息没有被重定向
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 case 2:                     // 标志字节为2,表示国家信息被重定向
218 218
                     fseek($this->fp, $this->getLong3());
219 219
                     $location['all'] = $this->getString();
220
-                    fseek($this->fp, $offset + 8);
220
+                    fseek($this->fp, $offset+8);
221 221
                     $location['extend'] = $this->getExtendString();
222 222
                     break;
223 223
                 default:                    // 否则,表示国家信息没有被重定向
@@ -275,14 +275,14 @@  discard block
 block discarded – undo
275 275
             if (count($preg) == 4) {        //匹配 "浙江省杭州市"
276 276
                 $state = $preg[1] ? $preg[1] : ($preg[2] ? $preg[2] : $preg[3]);
277 277
                 $city = $preg[3];
278
-            } else if (count($preg) == 7) { //匹配 "浙江省杭州市江干区"
278
+            }else if (count($preg) == 7) { //匹配 "浙江省杭州市江干区"
279 279
                 $state = $preg[1] ? $preg[1] : ($preg[2] ? $preg[2] : $preg[3]);
280 280
                 $city = $preg[3];
281 281
                 $area = $preg[5];
282
-            } else if (count($preg) == 3) { //匹配 "香港"
282
+            }else if (count($preg) == 3) { //匹配 "香港"
283 283
                 $state = $preg[1] ? $preg[1] : $preg[2];
284 284
                 $city = $state;
285
-            } else if (count($preg) == 2) {  //匹配 "浙江省"
285
+            }else if (count($preg) == 2) {  //匹配 "浙江省"
286 286
                 $state = $preg[1] ? $preg[1] : $this->unknown;
287 287
             }
288 288
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     private function getLong3()
308 308
     {
309 309
         //将读取的little-endian编码的3个字节转化为长整型数
310
-        $result = unpack('Vlong', fread($this->fp, 3) . chr(0));
310
+        $result = unpack('Vlong', fread($this->fp, 3).chr(0));
311 311
         return $result['long'];
312 312
     }
313 313
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
     {
335 335
         $char = fread($this->fp, 1);
336 336
         while (ord($char) > 0) {        // 字符串按照C格式保存,以\0结束
337
-            $data .= $char;             // 将读取的字符连接到给定字符串之后
337
+            $data .= $char; // 将读取的字符连接到给定字符串之后
338 338
             $char = fread($this->fp, 1);
339 339
         }
340 340
         return $data;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      */
347 347
     private function getExtendString()
348 348
     {
349
-        $byte = fread($this->fp, 1);    // 标志字节
349
+        $byte = fread($this->fp, 1); // 标志字节
350 350
         switch (ord($byte)) {
351 351
             case 0:                     // 没有区域信息
352 352
                 $area = "";
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                 }
394 394
                 $IPParts[$i] = str_pad(decHex($IPPart), 2, '0', STR_PAD_LEFT);
395 395
             }
396
-            return '0000:0000:0000:0000:0000:ffff:' . $IPParts[1] . $IPParts[2] . ':' . $IPParts[3] . $IPParts[4];
396
+            return '0000:0000:0000:0000:0000:ffff:'.$IPParts[1].$IPParts[2].':'.$IPParts[3].$IPParts[4];
397 397
         }
398 398
         return '';
399 399
     }
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         $district['lng'] = '';
426 426
 
427 427
         if (!empty($province_name)) {
428
-            $json_province = json_decode(file_get_contents($this->ipPath . 'province.json'), true);
428
+            $json_province = json_decode(file_get_contents($this->ipPath.'province.json'), true);
429 429
             foreach ($json_province['rows'] as $key => $value) {
430 430
                 if ($value['name'] == $province_name) {
431 431
                     $province['name'] = $value['name'];
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             }
437 437
         }
438 438
         if (!empty($city_name)) {
439
-            $json_city = json_decode(file_get_contents($this->ipPath . 'city.json'), true);
439
+            $json_city = json_decode(file_get_contents($this->ipPath.'city.json'), true);
440 440
             foreach ($json_city['rows'] as $key => $value) {
441 441
                 if ($value['name'] == $city_name) {
442 442
                     $city['name'] = $value['name'];
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             }
448 448
         }
449 449
         if (!empty($district_name)) {
450
-            $json_district = json_decode(file_get_contents($this->ipPath . 'district.json'), true);
450
+            $json_district = json_decode(file_get_contents($this->ipPath.'district.json'), true);
451 451
             foreach ($json_district['rows'] as $key => $value) {
452 452
                 if ($value['name'] == $district_name) {
453 453
                     $district['name'] = $value['name'];
Please login to merge, or discard this patch.
src/service/curl/BtService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     private function http()
131 131
     {
132 132
         $ch = curl_init();
133
-        curl_setopt($ch, CURLOPT_URL, $this->panel . $this->url);
133
+        curl_setopt($ch, CURLOPT_URL, $this->panel.$this->url);
134 134
         curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
135 135
         curl_setopt($ch, CURLOPT_POST, 1);
136 136
         curl_setopt($ch, CURLOPT_POSTFIELDS, array_merge($this->getKeyData(), $this->data));
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     {
155 155
         $time = time();
156 156
         return array(
157
-            'request_token' => md5($time . '' . md5($this->key)),
157
+            'request_token' => md5($time.''.md5($this->key)),
158 158
             'request_time' => $time
159 159
         );
160 160
     }
Please login to merge, or discard this patch.
src/service/curl/HttpService.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         if (is_array($str)) {
56 56
             $this->data = json_encode($str, JSON_UNESCAPED_UNICODE);
57
-        } else {
57
+        }else {
58 58
             $this->data = $str;
59 59
         }
60 60
         return $this;
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
         }
151 151
         if ($this->method === 'GET') {
152 152
             $this->httpGet();
153
-        } else if ($this->method === 'POST') {
153
+        }else if ($this->method === 'POST') {
154 154
             $this->httpPost();
155
-        } else if ($this->method === 'XML') {
155
+        }else if ($this->method === 'XML') {
156 156
             $this->httpXml();
157
-        } else if ($this->method === 'FILE') {
157
+        }else if ($this->method === 'FILE') {
158 158
             $this->httpFile();
159
-        } else {
159
+        }else {
160 160
             throw new HttpException(404, '请求方式异常');
161 161
         }
162 162
         if (empty($is)) {
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
     {
199 199
         $ch = curl_init();
200 200
         curl_setopt($ch, CURLOPT_URL, $this->url);
201
-        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: ' . $this->headers));
201
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: '.$this->headers));
202 202
         curl_setopt($ch, CURLOPT_HEADER, 0);
203 203
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
204 204
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
205 205
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
206
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);  // 从证书中检查SSL加密算法是否存在
206
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
207 207
         curl_setopt($ch, CURLOPT_POST, 1);
208 208
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->data);
209 209
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         curl_setopt($ch, CURLOPT_TIMEOUT, 40);
240 240
         set_time_limit(0);
241 241
         if (!empty($this->headers)) {
242
-            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: ' . $this->headers));
242
+            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: '.$this->headers));
243 243
         }
244 244
         //运行curl
245 245
         $data = curl_exec($ch);
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
             curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM');
267 267
             curl_setopt($ch, CURLOPT_SSLCERT, $this->cert['cert']);
268 268
             curl_setopt($ch, CURLOPT_SSLKEY, $this->cert['key']);
269
-        } else {
269
+        }else {
270 270
             if (substr($this->url, 0, 5) == 'https') {
271 271
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书
272 272
                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 检查证书中是否设置域名
273 273
             }
274 274
         }
275 275
         if (!empty($this->headers)) {
276
-            curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type: ' . $this->headers));
276
+            curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type: '.$this->headers));
277 277
         }
278
-        curl_setopt($ch, CURLOPT_HEADER, true);    // 是否需要响应 header
278
+        curl_setopt($ch, CURLOPT_HEADER, true); // 是否需要响应 header
279 279
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
280 280
         $output = curl_exec($ch);
281
-        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);    // 获得响应结果里的:头大小
281
+        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); // 获得响应结果里的:头大小
282 282
         $response_body = substr($output, $header_size);
283 283
         curl_close($ch);
284 284
         $this->output = $response_body;
Please login to merge, or discard this patch.
src/cache/Mysql.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         $result = Db::table($this->table)
136 136
             ->where('cache_name', $this->cache_name)
137 137
             ->update([
138
-                'cache_value' => $cache_value + $int
138
+                'cache_value' => $cache_value+$int
139 139
             ]);
140 140
         return $result ? true : false;
141 141
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $result = Db::table($this->table)
154 154
             ->where('cache_name', $this->cache_name)
155 155
             ->update([
156
-                'cache_value' => $cache_value - $int
156
+                'cache_value' => $cache_value-$int
157 157
             ]);
158 158
         return $result ? true : false;
159 159
     }
Please login to merge, or discard this patch.
src/helper/Decimals.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
18 18
 // +----------------------------------------------------------------------
19 19
 
20
-declare (strict_types=1);
20
+declare(strict_types=1);
21 21
 
22 22
 namespace DtApp\ThinkLibrary\helper;
23 23
 
Please login to merge, or discard this patch.
src/helper/Pregs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
18 18
 // +----------------------------------------------------------------------
19 19
 
20
-declare (strict_types=1);
20
+declare(strict_types=1);
21 21
 
22 22
 namespace DtApp\ThinkLibrary\helper;
23 23
 
Please login to merge, or discard this patch.
src/facade/Strings.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
18 18
 // +----------------------------------------------------------------------
19 19
 
20
-declare (strict_types=1);
20
+declare(strict_types=1);
21 21
 
22 22
 namespace DtApp\ThinkLibrary\facade;
23 23
 
Please login to merge, or discard this patch.
src/facade/Ints.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
18 18
 // +----------------------------------------------------------------------
19 19
 
20
-declare (strict_types=1);
20
+declare(strict_types=1);
21 21
 
22 22
 namespace DtApp\ThinkLibrary\facade;
23 23
 
Please login to merge, or discard this patch.
src/facade/Decimals.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 // | Packagist 地址 :https://packagist.org/packages/liguangchun/think-library
18 18
 // +----------------------------------------------------------------------
19 19
 
20
-declare (strict_types=1);
20
+declare(strict_types=1);
21 21
 
22 22
 namespace DtApp\ThinkLibrary\facade;
23 23
 
Please login to merge, or discard this patch.