Passed
Push — master ( 6e1678...84a651 )
by Songda
03:16 queued 01:01
created
src/Functions.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         return $url;
158 158
     }
159 159
 
160
-    return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
160
+    return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url;
161 161
 }
162 162
 
163 163
 /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 function get_wechat_type_key(array $params): string
178 178
 {
179
-    $key = ($params['_type'] ?? 'mp').'_app_id';
179
+    $key = ($params['_type'] ?? 'mp') . '_app_id';
180 180
 
181 181
     if ('app_app_id' === $key) {
182 182
         $key = 'app_id';
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
     $buff = '';
220 220
 
221 221
     foreach ($payload as $k => $v) {
222
-        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : '';
222
+        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : '';
223 223
     }
224 224
 
225
-    $sign = md5($buff.'key='.$key);
225
+    $sign = md5($buff . 'key=' . $key);
226 226
 
227 227
     return $upper ? strtoupper($sign) : $sign;
228 228
 }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
  * @throws InvalidSignException
236 236
  * @throws ServiceNotFoundException
237 237
  */
238
-function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void
238
+function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void
239 239
 {
240 240
     if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) {
241 241
         return;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     $sign = $message->getHeaderLine('Wechatpay-Signature');
248 248
     $body = (string) $message->getBody();
249 249
 
250
-    $content = $timestamp."\n".$random."\n".$body."\n";
250
+    $content = $timestamp . "\n" . $random . "\n" . $body . "\n";
251 251
     $public = get_provider_config('wechat', $params)['wechat_public_cert_path'][$wechatSerial] ?? null;
252 252
 
253 253
     if (empty($sign)) {
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     }
333 333
 
334 334
     Pay::get(ConfigInterface::class)->set(
335
-        'wechat.'.get_tenant($params).'.wechat_public_cert_path',
335
+        'wechat.' . get_tenant($params) . '.wechat_public_cert_path',
336 336
         ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []),
337 337
     );
338 338
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     }
364 364
 
365 365
     foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) {
366
-        file_put_contents($path.'/'.$serialNo.'.crt', $cert);
366
+        file_put_contents($path . '/' . $serialNo . '.crt', $cert);
367 367
     }
368 368
 }
369 369
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 /**
396 396
  * @throws DecryptException
397 397
  */
398
-function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string
398
+function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string
399 399
 {
400 400
     $decrypted = openssl_decrypt(
401 401
         substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE),
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
     $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null;
457 457
 
458 458
     if (empty($publicKey)) {
459
-        throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号未找到 - '.$serialNo);
459
+        throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号未找到 - ' . $serialNo);
460 460
     }
461 461
 
462 462
     return $publicKey;
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         throw new InvalidConfigException(Exception::CONFIG_WECHAT_INVALID, '配置异常: 缺少微信配置 -- [mini_app_key_virtual_pay]');
472 472
     }
473 473
 
474
-    return hash_hmac('sha256', $url.'&'.$payload, $config['mini_app_key_virtual_pay']);
474
+    return hash_hmac('sha256', $url . '&' . $payload, $config['mini_app_key_virtual_pay']);
475 475
 }
476 476
 
477 477
 function get_wechat_miniprogram_user_sign(string $sessionKey, string $payload): string
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
         return $url;
533 533
     }
534 534
 
535
-    return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
535
+    return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url;
536 536
 }
537 537
 
538 538
 /**
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
     $buff = '';
566 566
 
567 567
     foreach ($payload as $k => $v) {
568
-        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : '';
568
+        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : '';
569 569
     }
570 570
 
571
-    return strtoupper(md5($buff.'key='.$key));
571
+    return strtoupper(md5($buff . 'key=' . $key));
572 572
 }
573 573
 
574 574
 /**
@@ -647,5 +647,5 @@  discard block
 block discarded – undo
647 647
         return $url;
648 648
     }
649 649
 
650
-    return Douyin::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
650
+    return Douyin::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url;
651 651
 }
Please login to merge, or discard this patch.
src/Provider/Alipay.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
      * @throws InvalidParamsException
54 54
      * @throws ServiceNotFoundException
55 55
      */
56
-    public function __call(string $shortcut, array $params): null|Collection|MessageInterface|Rocket
56
+    public function __call(string $shortcut, array $params): null | Collection | MessageInterface | Rocket
57 57
     {
58
-        $plugin = '\Yansongda\Pay\Shortcut\Alipay\\'.Str::studly($shortcut).'Shortcut';
58
+        $plugin = '\Yansongda\Pay\Shortcut\Alipay\\' . Str::studly($shortcut) . 'Shortcut';
59 59
 
60 60
         return Artful::shortcut($plugin, ...$params);
61 61
     }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @throws ContainerException
65 65
      * @throws InvalidParamsException
66 66
      */
67
-    public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket
67
+    public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket
68 68
     {
69 69
         return Artful::artful($plugins, $params);
70 70
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @throws InvalidParamsException
75 75
      * @throws ServiceNotFoundException
76 76
      */
77
-    public function query(array $order): Collection|Rocket
77
+    public function query(array $order): Collection | Rocket
78 78
     {
79 79
         Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null));
80 80
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @throws InvalidParamsException
87 87
      * @throws ServiceNotFoundException
88 88
      */
89
-    public function cancel(array $order): Collection|Rocket
89
+    public function cancel(array $order): Collection | Rocket
90 90
     {
91 91
         Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null));
92 92
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @throws InvalidParamsException
99 99
      * @throws ServiceNotFoundException
100 100
      */
101
-    public function close(array $order): Collection|Rocket
101
+    public function close(array $order): Collection | Rocket
102 102
     {
103 103
         Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null));
104 104
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      * @throws InvalidParamsException
111 111
      * @throws ServiceNotFoundException
112 112
      */
113
-    public function refund(array $order): Collection|Rocket
113
+    public function refund(array $order): Collection | Rocket
114 114
     {
115 115
         Event::dispatch(new MethodCalled('alipay', __METHOD__, $order, null));
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      * @throws ContainerException
122 122
      * @throws InvalidParamsException
123 123
      */
124
-    public function callback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection
124
+    public function callback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection
125 125
     {
126 126
         $request = $this->getCallbackParams($contents);
127 127
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @throws ContainerException
135 135
      * @throws InvalidParamsException
136 136
      */
137
-    public function appCallback(null|array|ServerRequestInterface $contents = null, ?array $params = null): Collection
137
+    public function appCallback(null | array | ServerRequestInterface $contents = null, ?array $params = null): Collection
138 138
     {
139 139
         $request = $this->getCallbackParams($contents);
140 140
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         );
156 156
     }
157 157
 
158
-    protected function getCallbackParams(null|array|ServerRequestInterface $contents = null): Collection
158
+    protected function getCallbackParams(null | array | ServerRequestInterface $contents = null): Collection
159 159
     {
160 160
         if (is_array($contents)) {
161 161
             return Collection::wrap($contents);
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/AddPayloadSignaturePlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
         $urlPath = parse_url($url, PHP_URL_PATH);
62 62
         $urlQuery = parse_url($url, PHP_URL_QUERY);
63 63
 
64
-        return get_wechat_method($payload)."\n"
65
-            .$urlPath.(empty($urlQuery) ? '' : '?'.$urlQuery)."\n"
66
-            .$timestamp."\n"
67
-            .$random."\n"
68
-            .get_wechat_body($payload)."\n";
64
+        return get_wechat_method($payload) . "\n"
65
+            .$urlPath . (empty($urlQuery) ? '' : '?' . $urlQuery) . "\n"
66
+            .$timestamp . "\n"
67
+            .$random . "\n"
68
+            .get_wechat_body($payload) . "\n";
69 69
     }
70 70
 
71 71
     /**
@@ -94,6 +94,6 @@  discard block
 block discarded – undo
94 94
             get_wechat_sign($config, $contents),
95 95
         );
96 96
 
97
-        return 'WECHATPAY2-SHA256-RSA2048 '.$auth;
97
+        return 'WECHATPAY2-SHA256-RSA2048 ' . $auth;
98 98
     }
99 99
 }
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/Pay/App/InvokePlugin.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             'prepayid' => $prepayId,
75 75
             'package' => 'Sign=WXPay',
76 76
             'noncestr' => Str::random(32),
77
-            'timestamp' => time().'',
77
+            'timestamp' => time() . '',
78 78
         ]);
79 79
 
80 80
         $invokeConfig->set('sign', $this->getSign($invokeConfig, $config));
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function getSign(Collection $invokeConfig, array $config): string
89 89
     {
90
-        $contents = $invokeConfig->get('appid', '')."\n"
91
-            .$invokeConfig->get('timestamp', '')."\n"
92
-            .$invokeConfig->get('noncestr', '')."\n"
93
-            .$invokeConfig->get('prepayid', '')."\n";
90
+        $contents = $invokeConfig->get('appid', '') . "\n"
91
+            .$invokeConfig->get('timestamp', '') . "\n"
92
+            .$invokeConfig->get('noncestr', '') . "\n"
93
+            .$invokeConfig->get('prepayid', '') . "\n";
94 94
 
95 95
         return get_wechat_sign($config, $contents);
96 96
     }
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/Pay/Mini/InvokePlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $invokeConfig = new Config([
72 72
             'appId' => $this->getAppId($payload, $config),
73
-            'timeStamp' => time().'',
73
+            'timeStamp' => time() . '',
74 74
             'nonceStr' => Str::random(32),
75
-            'package' => 'prepay_id='.$prepayId,
75
+            'package' => 'prepay_id=' . $prepayId,
76 76
             'signType' => 'RSA',
77 77
         ]);
78 78
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      */
87 87
     protected function getSign(Collection $invokeConfig, array $config): string
88 88
     {
89
-        $contents = $invokeConfig->get('appId', '')."\n"
90
-            .$invokeConfig->get('timeStamp', '')."\n"
91
-            .$invokeConfig->get('nonceStr', '')."\n"
92
-            .$invokeConfig->get('package', '')."\n";
89
+        $contents = $invokeConfig->get('appId', '') . "\n"
90
+            .$invokeConfig->get('timeStamp', '') . "\n"
91
+            .$invokeConfig->get('nonceStr', '') . "\n"
92
+            .$invokeConfig->get('package', '') . "\n";
93 93
 
94 94
         return get_wechat_sign($config, $contents);
95 95
     }
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/Pay/Combine/JsapiInvokePlugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $invokeConfig = new Config([
73 73
             'appId' => $this->getAppId($payload, $config, $params),
74
-            'timeStamp' => time().'',
74
+            'timeStamp' => time() . '',
75 75
             'nonceStr' => Str::random(32),
76
-            'package' => 'prepay_id='.$prepayId,
76
+            'package' => 'prepay_id=' . $prepayId,
77 77
             'signType' => 'RSA',
78 78
         ]);
79 79
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function getSign(Collection $invokeConfig, array $config): string
89 89
     {
90
-        $contents = $invokeConfig->get('appId', '')."\n"
91
-            .$invokeConfig->get('timeStamp', '')."\n"
92
-            .$invokeConfig->get('nonceStr', '')."\n"
93
-            .$invokeConfig->get('package', '')."\n";
90
+        $contents = $invokeConfig->get('appId', '') . "\n"
91
+            .$invokeConfig->get('timeStamp', '') . "\n"
92
+            .$invokeConfig->get('nonceStr', '') . "\n"
93
+            .$invokeConfig->get('package', '') . "\n";
94 94
 
95 95
         return get_wechat_sign($config, $contents);
96 96
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     protected function getAppId(?Collection $payload, array $config, array $params): string
99 99
     {
100 100
         if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
101
-            return $payload?->get('_invoke_appid') ?? $config['sub_'.get_wechat_type_key($params)] ?? '';
101
+            return $payload?->get('_invoke_appid') ?? $config['sub_' . get_wechat_type_key($params)] ?? '';
102 102
         }
103 103
 
104 104
         return $payload?->get('_invoke_appid') ?? $config[get_wechat_type_key($params)] ?? '';
Please login to merge, or discard this patch.
src/Plugin/Alipay/V2/ResponseHtmlPlugin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     protected function buildRedirect(string $endpoint, Collection $payload): Response
37 37
     {
38
-        $url = $endpoint.(!str_contains($endpoint, '?') ? '?' : '&').$payload->query();
38
+        $url = $endpoint . (!str_contains($endpoint, '?') ? '?' : '&') . $payload->query();
39 39
 
40 40
         $content = sprintf(
41 41
             '<!DOCTYPE html>
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 
59 59
     protected function buildHtml(string $endpoint, Collection $payload): Response
60 60
     {
61
-        $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='POST'>";
61
+        $sHtml = "<form id='alipay_submit' name='alipay_submit' action='" . $endpoint . "' method='POST'>";
62 62
         foreach ($payload->all() as $key => $val) {
63 63
             $val = str_replace("'", '&apos;', $val);
64
-            $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>";
64
+            $sHtml .= "<input type='hidden' name='" . $key . "' value='" . $val . "'/>";
65 65
         }
66 66
         $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>";
67 67
         $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>";
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/Pay/Jsapi/InvokePlugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $invokeConfig = new Config([
73 73
             'appId' => $this->getAppId($payload, $config, $params),
74
-            'timeStamp' => time().'',
74
+            'timeStamp' => time() . '',
75 75
             'nonceStr' => Str::random(32),
76
-            'package' => 'prepay_id='.$prepayId,
76
+            'package' => 'prepay_id=' . $prepayId,
77 77
             'signType' => 'RSA',
78 78
         ]);
79 79
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected function getSign(Collection $invokeConfig, array $config): string
89 89
     {
90
-        $contents = $invokeConfig->get('appId', '')."\n"
91
-            .$invokeConfig->get('timeStamp', '')."\n"
92
-            .$invokeConfig->get('nonceStr', '')."\n"
93
-            .$invokeConfig->get('package', '')."\n";
90
+        $contents = $invokeConfig->get('appId', '') . "\n"
91
+            .$invokeConfig->get('timeStamp', '') . "\n"
92
+            .$invokeConfig->get('nonceStr', '') . "\n"
93
+            .$invokeConfig->get('package', '') . "\n";
94 94
 
95 95
         return get_wechat_sign($config, $contents);
96 96
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     protected function getAppId(?Collection $payload, array $config, array $params): string
99 99
     {
100 100
         if (Pay::MODE_SERVICE === ($config['mode'] ?? Pay::MODE_NORMAL)) {
101
-            return $payload?->get('_invoke_appid') ?? $config['sub_'.get_wechat_type_key($params)] ?? '';
101
+            return $payload?->get('_invoke_appid') ?? $config['sub_' . get_wechat_type_key($params)] ?? '';
102 102
         }
103 103
 
104 104
         return $payload?->get('_invoke_appid') ?? $config[get_wechat_type_key($params)] ?? '';
Please login to merge, or discard this patch.
src/Plugin/Wechat/V3/Pay/Combine/MiniInvokePlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $invokeConfig = new Config([
72 72
             'appId' => $this->getAppId($payload, $config),
73
-            'timeStamp' => time().'',
73
+            'timeStamp' => time() . '',
74 74
             'nonceStr' => Str::random(32),
75
-            'package' => 'prepay_id='.$prepayId,
75
+            'package' => 'prepay_id=' . $prepayId,
76 76
             'signType' => 'RSA',
77 77
         ]);
78 78
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      */
87 87
     protected function getSign(Collection $invokeConfig, array $config): string
88 88
     {
89
-        $contents = $invokeConfig->get('appId', '')."\n"
90
-            .$invokeConfig->get('timeStamp', '')."\n"
91
-            .$invokeConfig->get('nonceStr', '')."\n"
92
-            .$invokeConfig->get('package', '')."\n";
89
+        $contents = $invokeConfig->get('appId', '') . "\n"
90
+            .$invokeConfig->get('timeStamp', '') . "\n"
91
+            .$invokeConfig->get('nonceStr', '') . "\n"
92
+            .$invokeConfig->get('package', '') . "\n";
93 93
 
94 94
         return get_wechat_sign($config, $contents);
95 95
     }
Please login to merge, or discard this patch.