Passed
Push — master ( 99bfc0...d990ad )
by ma
19:38
created
src/Gateways/Naver.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
             }
81 81
             $this->token['token_type'] = 'Bearer';
82 82
             $this->token['access_token'] = $_REQUEST['access_token'];
83
-        }else {
83
+        } else {
84 84
             $this->getToken();
85 85
         }
86 86
         $data = $this->call('nid/me', $this->token, 'GET');
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'scope'         => $this->config['scope'],
40 40
             'state'         => $this->config['state'] ?: Str::random(),
41 41
         ];
42
-        return $this->AuthorizeURL . '?' . http_build_query($params);
42
+        return $this->AuthorizeURL.'?'.http_build_query($params);
43 43
     }
44 44
 
45 45
     /**
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getUserInfo()
78 78
     {
79
-        if($this->type == 'app'){//App登录
80
-            if(!isset($_REQUEST['access_token']) ){
79
+        if ($this->type == 'app') {//App登录
80
+            if (!isset($_REQUEST['access_token'])) {
81 81
                 throw new OAuthException("Naver APP登录 需要传输access_token参数! ");
82 82
             }
83 83
             $this->token['token_type'] = 'Bearer';
84 84
             $this->token['access_token'] = $_REQUEST['access_token'];
85
-        }else {
85
+        } else {
86 86
             $this->getToken();
87 87
         }
88 88
         $data = $this->call('nid/me', $this->token, 'GET');
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
         $method  = strtoupper($method);
106 106
         $request = [
107 107
             'method' => $method,
108
-            'uri'    => self::API_BASE . $api,
108
+            'uri'    => self::API_BASE.$api,
109 109
         ];
110 110
 
111
-        $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']];
111
+        $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']];
112 112
 
113 113
         $data = $this->$method($request['uri'], $params, $headers);
114 114
 
Please login to merge, or discard this patch.
src/Gateways/Sina.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
             }
95 95
             $this->token['access_token'] = $_REQUEST['access_token'];
96 96
             $this->token['openid'] = $_REQUEST['uid'];
97
-        }else{
97
+        } else{
98 98
             /** 获取参数 */
99 99
             $params = $this->accessTokenParams();
100 100
             $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             'state'        => $this->config['state'],
39 39
             'display'      => $this->display,
40 40
         ];
41
-        return $this->AuthorizeURL . '?' . http_build_query($params);
41
+        return $this->AuthorizeURL.'?'.http_build_query($params);
42 42
     }
43 43
 
44 44
     /**
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function getUserInfo()
93 93
     {
94
-        if($this->type == 'app'){//App登录
95
-            if(!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])){
94
+        if ($this->type == 'app') {//App登录
95
+            if (!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])) {
96 96
                 throw new OAuthException("Sina APP登录 需要传输access_token和uid参数! ");
97 97
             }
98 98
             $this->token['access_token'] = $_REQUEST['access_token'];
99 99
             $this->token['openid'] = $_REQUEST['uid'];
100
-        }else{
100
+        } else {
101 101
             /** 获取参数 */
102 102
             $params = $this->accessTokenParams();
103
-            $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参
103
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params); //get传参
104 104
             $this->getToken();
105 105
         }
106 106
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $method = strtoupper($method);
122 122
 
123
-        if(isset($this->token['access_token'])){
123
+        if (isset($this->token['access_token'])) {
124 124
             $params['access_token'] = $this->token['access_token'];
125 125
         }
126 126
 
127
-        $data = $this->$method(self::API_BASE . $api, $params);
127
+        $data = $this->$method(self::API_BASE.$api, $params);
128 128
         return json_decode($data, true);
129 129
     }
130 130
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
      * @param $data
166 166
      * @return mixed
167 167
      */
168
-    public function statusesShare($data){
169
-        return $this->call('statuses/share.json', json_encode($data),'POST');
168
+    public function statusesShare($data) {
169
+        return $this->call('statuses/share.json', json_encode($data), 'POST');
170 170
     }
171 171
 
172 172
 }
Please login to merge, or discard this patch.
src/Helper/Str.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
             if (in_array($k, $except)) {
16 16
                 continue;
17 17
             }
18
-            $param_str .= $k . '=';
18
+            $param_str .= $k.'=';
19 19
             $param_str .= $urlencode ? rawurlencode($v) : $v;
20 20
             $param_str .= '&';
21 21
         }
Please login to merge, or discard this patch.
src/Helper/ConstCode.php 2 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,18 +52,18 @@
 block discarded – undo
52 52
             case self::TYPE_QQ:
53 53
                 if($type == 'app'){
54 54
                     $typeConst = self::TYPE_QQ_APP;//qqApp
55
-                }else{
55
+                } else{
56 56
                     $typeConst = $channel;
57 57
                 }
58 58
                 break;
59 59
             case self::TYPE_WECHAT:
60 60
                 if($type == 'app'){
61 61
                     $typeConst = self::TYPE_WECHAT_APP;//微信App
62
-                }else if($type == 'applets'){
62
+                } else if($type == 'applets'){
63 63
                     $typeConst =  self::TYPE_WECHAT_APPLETS;//微信小程序
64
-                }else if(Tool::isWeiXin()){
64
+                } else if(Tool::isWeiXin()){
65 65
                     $typeConst =  self::TYPE_WECHAT_MOBILE;//微信mobile
66
-                }else{
66
+                } else{
67 67
                     $typeConst = $channel;
68 68
                 }
69 69
                 break;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
 
7 7
 use tinymeng\tools\Tool;
8 8
 
9
-class ConstCode{
9
+class ConstCode {
10 10
 
11 11
     /** 公共状态 */
12
-    const STATUS_DELETE = 0;//删除
13
-    const STATUS_NORMAL = 1;//正常
12
+    const STATUS_DELETE = 0; //删除
13
+    const STATUS_NORMAL = 1; //正常
14 14
 
15 15
     /** 性别 */
16
-    const GENDER = 0;//未知
17
-    const GENDER_MAN = 1;//男
18
-    const GENDER_WOMEN = 2;//女
16
+    const GENDER = 0; //未知
17
+    const GENDER_MAN = 1; //男
18
+    const GENDER_WOMEN = 2; //女
19 19
 
20 20
     /** 登录类型 */
21 21
     const TYPE_QQ               = 1; //QQ
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
     const TYPE_FACEBOOK         = 7; //faceBook
28 28
     const TYPE_GOOGLE           = 8; //google
29 29
     const TYPE_TWITTER          = 9; //飞鸽
30
-    const TYPE_LINE             = 10;//line
31
-    const TYPE_NAVER            = 11;//naver
30
+    const TYPE_LINE             = 10; //line
31
+    const TYPE_NAVER            = 11; //naver
32 32
     const TYPE_ALIYUN           = 12; //阿里云
33 33
     const TYPE_BAIDU            = 13; //百度
34 34
     const TYPE_CODING           = 14; //Coding
@@ -53,24 +53,24 @@  discard block
 block discarded – undo
53 53
      * @param bool $type 类型:app applets
54 54
      * @return int
55 55
      */
56
-    static public function getTypeConst($channel,$type="")
56
+    static public function getTypeConst($channel, $type = "")
57 57
     {
58
-        switch ($channel){
58
+        switch ($channel) {
59 59
             case self::TYPE_QQ:
60
-                if($type == 'app'){
61
-                    $typeConst = self::TYPE_QQ_APP;//qqApp
62
-                }else{
60
+                if ($type == 'app') {
61
+                    $typeConst = self::TYPE_QQ_APP; //qqApp
62
+                } else {
63 63
                     $typeConst = $channel;
64 64
                 }
65 65
                 break;
66 66
             case self::TYPE_WECHAT:
67
-                if($type == 'app'){
68
-                    $typeConst = self::TYPE_WECHAT_APP;//微信App
69
-                }else if($type == 'applets'){
70
-                    $typeConst =  self::TYPE_WECHAT_APPLETS;//微信小程序
71
-                }else if(Tool::isWeiXin()){
72
-                    $typeConst =  self::TYPE_WECHAT_MOBILE;//微信mobile
73
-                }else{
67
+                if ($type == 'app') {
68
+                    $typeConst = self::TYPE_WECHAT_APP; //微信App
69
+                } else if ($type == 'applets') {
70
+                    $typeConst = self::TYPE_WECHAT_APPLETS; //微信小程序
71
+                } else if (Tool::isWeiXin()) {
72
+                    $typeConst = self::TYPE_WECHAT_MOBILE; //微信mobile
73
+                } else {
74 74
                     $typeConst = $channel;
75 75
                 }
76 76
                 break;
Please login to merge, or discard this patch.
src/Gateways/Aliyun.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'state'         => $this->config['state'],
40 40
             'scope'         => $this->config['scope'],
41 41
         ];
42
-        return $this->AuthorizeURL . '?' . http_build_query($params);
42
+        return $this->AuthorizeURL.'?'.http_build_query($params);
43 43
     }
44 44
 
45 45
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $this->openid();
80 80
 
81 81
         $headers = ['Authorization: Bearer '.$this->token['access_token']];
82
-        $data = $this->get($this->UserInfoURL, [],$headers);
82
+        $data = $this->get($this->UserInfoURL, [], $headers);
83 83
         return json_decode($data, true);
84 84
     }
85 85
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @author: JiaMeng <[email protected]>
102 102
      * Updater:
103 103
      */
104
-    protected function getToken(){
104
+    protected function getToken() {
105 105
         if (empty($this->token)) {
106 106
             /** 验证state参数 */
107 107
             $this->CheckState();
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             $params = $this->accessTokenParams();
111 111
 
112 112
             /** 获取access_token */
113
-            $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params);
114
-            $token =  $this->post($this->AccessTokenURL);
113
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params);
114
+            $token = $this->post($this->AccessTokenURL);
115 115
             /** 解析token值(子类实现此方法) */
116 116
             $this->token = $this->parseToken($token);
117 117
         }
Please login to merge, or discard this patch.
src/Gateways/Github.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
             'scope'        => $this->config['scope'],
52 52
             'state'        => $this->config['state'],
53 53
             'display'      => $this->display,
54
-            'allow_signup' => true,//是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。
54
+            'allow_signup' => true, //是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。
55 55
         ];
56
-        return $this->AuthorizeURL . '?' . http_build_query($params);
56
+        return $this->AuthorizeURL.'?'.http_build_query($params);
57 57
     }
58 58
 
59 59
     /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $headers = [
114 114
             'User-Agent: '.$this->config['application_name'],
115 115
             'UserModel-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 ',
116
-            'Authorization: token ' . $this->token['access_token'],
116
+            'Authorization: token '.$this->token['access_token'],
117 117
             'Accept: application/json'
118 118
         ];
119 119
         $response = $this->get($this->UserInfoURL, [], $headers);
Please login to merge, or discard this patch.
example/proxy/wx_proxy.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @Author: TinyMeng <[email protected]>
14 14
      */
15
-    public function run(){
15
+    public function run() {
16 16
         if (isset($_GET['code'])) {
17 17
             $state = isset($_GET['state']) ? $_GET['state'] : "";
18
-            header('Location: ' . $_COOKIE['redirect_uri'] . '?code=' . $_GET['code'] . '&state=' . $state);
18
+            header('Location: '.$_COOKIE['redirect_uri'].'?code='.$_GET['code'].'&state='.$state);
19 19
         } else {
20
-            if(!isset($_GET['appid']) || !isset($_GET['response_type']) || !isset($_GET['scope'])){
20
+            if (!isset($_GET['appid']) || !isset($_GET['response_type']) || !isset($_GET['scope'])) {
21 21
                 echo "参数缺失";
22 22
                 return;
23 23
             }
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
             $protocol = $this->is_HTTPS() ? 'https://' : 'http://';
27 27
             $params   = array(
28 28
                 'appid'         => $_GET['appid'],
29
-                'redirect_uri'  => $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_URI'],
29
+                'redirect_uri'  => $protocol.$_SERVER['HTTP_HOST'].$_SERVER['DOCUMENT_URI'],
30 30
                 'response_type' => $_GET['response_type'],
31 31
                 'scope'         => $_GET['scope'],
32 32
                 'state'         => $state,
33 33
             );
34
-            if($_GET['scope'] == 'snsapi_login'){
34
+            if ($_GET['scope'] == 'snsapi_login') {
35 35
                 //扫码登录
36
-                $AuthorizeURL = $this->AuthorizeURL . '/connect/qrconnect';
37
-            }else{
38
-                $AuthorizeURL = $this->AuthorizeURL . '/connect/oauth2/authorize';
36
+                $AuthorizeURL = $this->AuthorizeURL.'/connect/qrconnect';
37
+            } else {
38
+                $AuthorizeURL = $this->AuthorizeURL.'/connect/oauth2/authorize';
39 39
             }
40 40
 
41 41
             setcookie('redirect_uri', urldecode($_GET['redirect_uri']), $_SERVER['REQUEST_TIME'] + 60, '/');
42
-            header('Location: ' . $AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect');
42
+            header('Location: '.$AuthorizeURL.'?'.http_build_query($params).'#wechat_redirect');
43 43
         }
44 44
     }
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @Author: TinyMeng <[email protected]>
49 49
      * @return bool
50 50
      */
51
-    protected function is_HTTPS(){
51
+    protected function is_HTTPS() {
52 52
         if (!isset($_SERVER['HTTPS'])) {
53 53
             return false;
54 54
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
             if($_GET['scope'] == 'snsapi_login'){
34 34
                 //扫码登录
35 35
                 $AuthorizeURL = $this->AuthorizeURL . '/connect/qrconnect';
36
-            }else{
36
+            } else{
37 37
                 $AuthorizeURL = $this->AuthorizeURL . '/connect/oauth2/authorize';
38 38
             }
39 39
 
Please login to merge, or discard this patch.
example/oauth2.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  *
7 7
  */
8
-class oauth2{
8
+class oauth2 {
9 9
 
10 10
     /**
11 11
      * 全部配置文件
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * @param $conf
28 28
      */
29
-    public function __construct($conf){
29
+    public function __construct($conf) {
30 30
         $this->configAll = $conf;
31 31
     }
32 32
 
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
      * Updater:
38 38
      * @param $name
39 39
      */
40
-    public function getConfig($name){
41
-        $this->config = $this->configAll[$name]??[];
42
-        if($name == 'wechat'){
43
-            if(!Tool::isMobile()){
44
-                $this->config = $this->config['pc'];//微信pc扫码登录
45
-            }elseif(Tool::isWeiXin()){
46
-                $this->config = $this->config['mobile'];//微信浏览器中打开
47
-            }else{
48
-                echo '请使用微信打开!';exit();//手机浏览器打开
40
+    public function getConfig($name) {
41
+        $this->config = $this->configAll[$name] ?? [];
42
+        if ($name == 'wechat') {
43
+            if (!Tool::isMobile()) {
44
+                $this->config = $this->config['pc']; //微信pc扫码登录
45
+            }elseif (Tool::isWeiXin()) {
46
+                $this->config = $this->config['mobile']; //微信浏览器中打开
47
+            } else {
48
+                echo '请使用微信打开!'; exit(); //手机浏览器打开
49 49
             }
50 50
         }
51 51
         //可以设置代理服务器,一般用于调试国外平台
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      * Author: JiaMeng <[email protected]>
58 58
      * Updater:
59 59
      */
60
-    public function login($name,$state=""){
60
+    public function login($name, $state = "") {
61 61
         /** 获取配置 */
62
-        if($name == 'wx') $name = 'wechat';
62
+        if ($name == 'wx') $name = 'wechat';
63 63
         $this->getConfig($name);
64 64
         $this->config['state'] = $state;
65 65
 
66 66
         /** 初始化实例类 */
67 67
         $oauth = OAuth::$name($this->config);
68
-        if(Tool::isMobile() || Tool::isWeiXin()){
68
+        if (Tool::isMobile() || Tool::isWeiXin()) {
69 69
             /**
70 70
              * 对于微博,如果登录界面要适用于手机,则需要设定->setDisplay('mobile')
71 71
              * 对于微信,如果是公众号登录,则需要设定->setDisplay('mobile'),否则是WEB网站扫码登录
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     public function callback($name)
95 95
     {
96 96
         /** 获取配置 */
97
-        if($name == 'wx') $name = 'wechat';
97
+        if ($name == 'wx') $name = 'wechat';
98 98
         $this->getConfig($name);
99 99
 
100 100
         /** 初始化实例类 */
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
         if($name == 'wechat'){
43 43
             if(!Tool::isMobile()){
44 44
                 $this->config = $this->config['pc'];//微信pc扫码登录
45
-            }elseif(Tool::isWeiXin()){
45
+            } elseif(Tool::isWeiXin()){
46 46
                 $this->config = $this->config['mobile'];//微信浏览器中打开
47
-            }else{
47
+            } else{
48 48
                 echo '请使用微信打开!';exit();//手机浏览器打开
49 49
             }
50 50
         }
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function login($name,$state=""){
61 61
         /** 获取配置 */
62
-        if($name == 'wx') $name = 'wechat';
62
+        if($name == 'wx') {
63
+            $name = 'wechat';
64
+        }
63 65
         $this->getConfig($name);
64 66
         $this->config['state'] = $state;
65 67
 
@@ -94,7 +96,9 @@  discard block
 block discarded – undo
94 96
     public function callback($name)
95 97
     {
96 98
         /** 获取配置 */
97
-        if($name == 'wx') $name = 'wechat';
99
+        if($name == 'wx') {
100
+            $name = 'wechat';
101
+        }
98 102
         $this->getConfig($name);
99 103
 
100 104
         /** 初始化实例类 */
Please login to merge, or discard this patch.
src/Gateways/Gitee.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'state'         => $this->config['state'],
35 35
             'scope'         => $this->config['scope'],
36 36
         ];
37
-        return $this->AuthorizeURL . '?' . http_build_query($params);
37
+        return $this->AuthorizeURL.'?'.http_build_query($params);
38 38
     }
39 39
 
40 40
     /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $params = [
74 74
             'access_token'=>$this->token['access_token'],
75 75
         ];
76
-        $data = $this->get($this->UserInfoURL,$params);
76
+        $data = $this->get($this->UserInfoURL, $params);
77 77
         return json_decode($data, true);
78 78
     }
79 79
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * Description:  获取AccessToken
93 93
      */
94
-    protected function getToken(){
94
+    protected function getToken() {
95 95
         if (empty($this->token)) {
96 96
             /** 验证state参数 */
97 97
             $this->CheckState();
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
             $params = $this->accessTokenParams();
101 101
 
102 102
             /** 获取access_token */
103
-            $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params);
104
-            $token =  $this->post($this->AccessTokenURL);
103
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params);
104
+            $token = $this->post($this->AccessTokenURL);
105 105
             /** 解析token值(子类实现此方法) */
106 106
             $this->token = $this->parseToken($token);
107 107
         }
Please login to merge, or discard this patch.