@@ -17,7 +17,7 @@ |
||
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 |
@@ -17,7 +17,7 @@ |
||
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 |
@@ -17,7 +17,7 @@ discard block |
||
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 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | if (intval($type) === 3) { |
49 | 49 | $chars = "{$numbs}{$chars}"; |
50 | 50 | } |
51 | - $string = $prefix . $chars[rand(1, strlen($chars) - 1)]; |
|
51 | + $string = $prefix.$chars[rand(1, strlen($chars)-1)]; |
|
52 | 52 | if (isset($chars)) { |
53 | 53 | while (strlen($string) < $size) { |
54 | - $string .= $chars[rand(0, strlen($chars) - 1)]; |
|
54 | + $string .= $chars[rand(0, strlen($chars)-1)]; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | return $string; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | if ($size < 14) { |
69 | 69 | $size = 14; |
70 | 70 | } |
71 | - $string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s'); |
|
71 | + $string = $prefix.date('Ymd').(date('H')+date('i')).date('s'); |
|
72 | 72 | while (strlen($string) < $size) { |
73 | 73 | $string .= rand(0, 9); |
74 | 74 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function number($size = 12, $prefix = ''): string |
85 | 85 | { |
86 | - $time = time() . ''; |
|
86 | + $time = time().''; |
|
87 | 87 | if ($size < 10) { |
88 | 88 | $size = 10; |
89 | 89 | } |
90 | - $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9); |
|
90 | + $string = $prefix.($time[0].$time[1]).substr($time, 2).rand(0, 9); |
|
91 | 91 | while (strlen($string) < $size) { |
92 | 92 | $string .= rand(0, 9); |
93 | 93 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $this->scope = $scope; |
166 | 166 | } elseif ($scope === "snsapi_userinfo") { |
167 | 167 | $this->scope = $scope; |
168 | - } else { |
|
168 | + }else { |
|
169 | 169 | throw new DtaException("请检查scope参数"); |
170 | 170 | } |
171 | 171 | return $this; |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | // 获取数据 |
314 | 314 | $accessToken = $this->getAccessToken(); |
315 | 315 | if (!isset($accessToken['access_token'])) { |
316 | - throw new DtaException("获取access_token错误," . $accessToken['errmsg']); |
|
316 | + throw new DtaException("获取access_token错误,".$accessToken['errmsg']); |
|
317 | 317 | } |
318 | 318 | $res = HttpService::instance() |
319 | 319 | ->url("{$this->api_url}cgi-bin/ticket/getticket?access_token={$accessToken['access_token']}&type=jsapi") |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | // 获取数据 |
323 | 323 | $accessToken = $this->getAccessToken(); |
324 | 324 | if (!isset($accessToken['access_token'])) { |
325 | - throw new DtaException("获取access_token错误," . $accessToken['errmsg']); |
|
325 | + throw new DtaException("获取access_token错误,".$accessToken['errmsg']); |
|
326 | 326 | } |
327 | 327 | $res = HttpService::instance() |
328 | 328 | ->url("{$this->api_url}cgi-bin/ticket/getticket?access_token={$accessToken['access_token']}&type=jsapi") |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
356 | 356 | $str = ""; |
357 | 357 | for ($i = 0; $i < $length; $i++) { |
358 | - $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); |
|
358 | + $str .= substr($chars, mt_rand(0, strlen($chars)-1), 1); |
|
359 | 359 | } |
360 | 360 | return $str; |
361 | 361 | } |
@@ -627,22 +627,22 @@ discard block |
||
627 | 627 | $accessToken_res = HttpService::instance() |
628 | 628 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
629 | 629 | ->toArray(); |
630 | - $accessToken_res['expires_time'] = time() + 6000; |
|
630 | + $accessToken_res['expires_time'] = time()+6000; |
|
631 | 631 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
632 | 632 | $accessToken = $accessToken_res; |
633 | - } else if (!isset($accessToken['access_token'])) { |
|
633 | + }else if (!isset($accessToken['access_token'])) { |
|
634 | 634 | // 内容不存在 |
635 | 635 | $accessToken_res = HttpService::instance() |
636 | 636 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
637 | 637 | ->toArray(); |
638 | - $accessToken_res['expires_time'] = time() + 6000; |
|
638 | + $accessToken_res['expires_time'] = time()+6000; |
|
639 | 639 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
640 | 640 | $accessToken = $accessToken_res; |
641 | - } else if ($accessToken['expires_time'] <= time()) { |
|
641 | + }else if ($accessToken['expires_time'] <= time()) { |
|
642 | 642 | $accessToken_res = HttpService::instance() |
643 | 643 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
644 | 644 | ->toArray(); |
645 | - $accessToken_res['expires_time'] = time() + 6000; |
|
645 | + $accessToken_res['expires_time'] = time()+6000; |
|
646 | 646 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
647 | 647 | $accessToken = $accessToken_res; |
648 | 648 | } |
@@ -653,12 +653,12 @@ discard block |
||
653 | 653 | $accessToken_res = HttpService::instance() |
654 | 654 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
655 | 655 | ->toArray(); |
656 | - $accessToken_res['expires_time'] = time() + 6000; |
|
656 | + $accessToken_res['expires_time'] = time()+6000; |
|
657 | 657 | file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); |
658 | 658 | $accessToken = $accessToken_res; |
659 | 659 | } |
660 | 660 | return $accessToken; |
661 | - } else if ($this->cache == "mysql") { |
|
661 | + }else if ($this->cache == "mysql") { |
|
662 | 662 | $access_token = []; |
663 | 663 | // 文件名 |
664 | 664 | $file = "{$this->app_id}_access_token"; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $cache_mysql_value = dtacache($file); |
667 | 667 | if (!empty($cache_mysql_value)) { |
668 | 668 | $access_token['access_token'] = $cache_mysql_value; |
669 | - } else { |
|
669 | + }else { |
|
670 | 670 | $accessToken_res = HttpService::instance() |
671 | 671 | ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") |
672 | 672 | ->toArray(); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $access_token['access_token'] = $accessToken_res['access_token']; |
685 | 685 | } |
686 | 686 | return $access_token; |
687 | - } else { |
|
687 | + }else { |
|
688 | 688 | throw new DtaException("驱动方式错误"); |
689 | 689 | } |
690 | 690 | } |
@@ -735,11 +735,11 @@ discard block |
||
735 | 735 | // 转成字符串 |
736 | 736 | $stringA = Urls::toParams($array); |
737 | 737 | // 在字符串接商户支付秘钥 |
738 | - $stringSignTemp = "{$stringA}&key=" . $this->mch_key; |
|
738 | + $stringSignTemp = "{$stringA}&key=".$this->mch_key; |
|
739 | 739 | //步骤四:MD5或HMAC-SHA256C加密 |
740 | 740 | if ($hmacsha256) { |
741 | 741 | $str = hash_hmac("sha256", $stringSignTemp, $this->mch_key); |
742 | - } else { |
|
742 | + }else { |
|
743 | 743 | $str = md5($stringSignTemp); |
744 | 744 | } |
745 | 745 | //符转大写 |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
760 | 760 | |
761 | 761 | //试试手气新增,增加之后 curl 不报 60# 错误,可以请求到微信的响应 |
762 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证 SSL 证书 |
|
763 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//不验证 SSL 证书域名 |
|
762 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证 SSL 证书 |
|
763 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不验证 SSL 证书域名 |
|
764 | 764 | //post提交方式 |
765 | 765 | curl_setopt($ch, CURLOPT_POST, TRUE); |
766 | 766 | curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); |
@@ -770,10 +770,10 @@ discard block |
||
770 | 770 | if ($data) { |
771 | 771 | curl_close($ch); |
772 | 772 | return $data; |
773 | - } else { |
|
773 | + }else { |
|
774 | 774 | $error = curl_errno($ch); |
775 | 775 | curl_close($ch); |
776 | - return "curl error, error code " . $error; |
|
776 | + return "curl error, error code ".$error; |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | } |
@@ -17,7 +17,7 @@ discard block |
||
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 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | if (!isset($array) || empty($array)) { |
61 | 61 | return $arrRet; |
62 | 62 | } |
63 | - $iCount = count($array) / $num; |
|
63 | + $iCount = count($array)/$num; |
|
64 | 64 | if (!is_int($iCount)) { |
65 | 65 | $iCount = ceil($iCount); |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | $iCount += 1; |
68 | 68 | } |
69 | 69 | for ($i = 0; $i < $iCount; ++$i) { |
70 | - $arrInfos = array_slice($array, $i * $num, $num); |
|
70 | + $arrInfos = array_slice($array, $i*$num, $num); |
|
71 | 71 | if (empty($arrInfos)) { |
72 | 72 | continue; |
73 | 73 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | foreach ($arrays as $array) { |
110 | 110 | if (is_array($array)) { |
111 | 111 | $key_arrays[] = $array[$sort_key]; |
112 | - } else { |
|
112 | + }else { |
|
113 | 113 | return []; |
114 | 114 | } |
115 | 115 | } |
116 | - } else { |
|
116 | + }else { |
|
117 | 117 | return []; |
118 | 118 | } |
119 | 119 | array_multisort($key_arrays, $sort_order, $sort_type, $arrays); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | foreach ($arr as $key => $value) { |
134 | 134 | if (is_array($value)) { |
135 | 135 | $arr[$key] = $this->TrimArray($value); |
136 | - } else { |
|
136 | + }else { |
|
137 | 137 | $arr[$key] = $this->trimAll(trim($value)); |
138 | 138 | } |
139 | 139 | } |