Passed
Pull Request — master (#922)
by Songda
02:01
created
src/Functions.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $direction = Pay::get($direction);
52 52
 
53 53
         $direction = is_string($direction) ? Pay::get($direction) : $direction;
54
-    } catch (ContainerException|ServiceNotFoundException) {
54
+    } catch (ContainerException | ServiceNotFoundException) {
55 55
     }
56 56
 
57 57
     if (!$direction instanceof DirectionInterface) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $packer = Pay::get($packer);
71 71
 
72 72
         $packer = is_string($packer) ? Pay::get($packer) : $packer;
73
-    } catch (ContainerException|ServiceNotFoundException) {
73
+    } catch (ContainerException | ServiceNotFoundException) {
74 74
     }
75 75
 
76 76
     if (!$packer instanceof PackerInterface) {
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
         return file_get_contents($key);
92 92
     }
93 93
 
94
-    return "-----BEGIN RSA PRIVATE KEY-----\n".
95
-        wordwrap($key, 64, "\n", true).
94
+    return "-----BEGIN RSA PRIVATE KEY-----\n" .
95
+        wordwrap($key, 64, "\n", true) .
96 96
         "\n-----END RSA PRIVATE KEY-----";
97 97
 }
98 98
 
99
-function filter_params(null|array|Collection $params, ?Closure $closure = null): array
99
+function filter_params(null | array | Collection $params, ?Closure $closure = null): array
100 100
 {
101 101
     $params = Collection::wrap($params);
102 102
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         return $url;
210 210
     }
211 211
 
212
-    return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
212
+    return Wechat::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url;
213 213
 }
214 214
 
215 215
 /**
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 function get_wechat_type_key(array $params): string
230 230
 {
231
-    $key = ($params['_type'] ?? 'mp').'_app_id';
231
+    $key = ($params['_type'] ?? 'mp') . '_app_id';
232 232
 
233 233
     if ('app_app_id' === $key) {
234 234
         $key = 'app_id';
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
     $buff = '';
272 272
 
273 273
     foreach ($payload as $k => $v) {
274
-        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : '';
274
+        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : '';
275 275
     }
276 276
 
277
-    $sign = md5($buff.'key='.$key);
277
+    $sign = md5($buff . 'key=' . $key);
278 278
 
279 279
     return $upper ? strtoupper($sign) : $sign;
280 280
 }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  * @throws InvalidSignException
288 288
  * @throws ServiceNotFoundException
289 289
  */
290
-function verify_wechat_sign(ResponseInterface|ServerRequestInterface $message, array $params): void
290
+function verify_wechat_sign(ResponseInterface | ServerRequestInterface $message, array $params): void
291 291
 {
292 292
     if ($message instanceof ServerRequestInterface && 'localhost' === $message->getUri()->getHost()) {
293 293
         return;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     $sign = $message->getHeaderLine('Wechatpay-Signature');
300 300
     $body = (string) $message->getBody();
301 301
 
302
-    $content = $timestamp."\n".$random."\n".$body."\n";
302
+    $content = $timestamp . "\n" . $random . "\n" . $body . "\n";
303 303
     $public = get_wechat_config($params)['wechat_public_cert_path'][$wechatSerial] ?? null;
304 304
 
305 305
     if (empty($sign)) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     Pay::get(ConfigInterface::class)->set(
387
-        'wechat.'.get_tenant($params).'.wechat_public_cert_path',
387
+        'wechat.' . get_tenant($params) . '.wechat_public_cert_path',
388 388
         ((array) ($wechatConfig['wechat_public_cert_path'] ?? [])) + ($certs ?? []),
389 389
     );
390 390
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     }
416 416
 
417 417
     foreach ($config['wechat_public_cert_path'] as $serialNo => $cert) {
418
-        file_put_contents($path.'/'.$serialNo.'.crt', $cert);
418
+        file_put_contents($path . '/' . $serialNo . '.crt', $cert);
419 419
     }
420 420
 }
421 421
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 /**
448 448
  * @throws DecryptException
449 449
  */
450
-function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array|string
450
+function decrypt_wechat_resource_aes_256_gcm(string $ciphertext, string $secret, string $nonce, string $associatedData): array | string
451 451
 {
452 452
     $decrypted = openssl_decrypt(
453 453
         substr($ciphertext, 0, -Wechat::AUTH_TAG_LENGTH_BYTE),
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
     $publicKey = $config['wechat_public_cert_path'][$serialNo] ?? null;
509 509
 
510 510
     if (empty($publicKey)) {
511
-        throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -'.$serialNo);
511
+        throw new InvalidParamsException(Exception::PARAMS_WECHAT_SERIAL_NOT_FOUND, '参数异常: 微信公钥序列号为找到 -' . $serialNo);
512 512
     }
513 513
 
514 514
     return $publicKey;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         return $url;
567 567
     }
568 568
 
569
-    return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL].$url;
569
+    return Unipay::URL[$config['mode'] ?? Pay::MODE_NORMAL] . $url;
570 570
 }
571 571
 
572 572
 /**
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
     $buff = '';
600 600
 
601 601
     foreach ($payload as $k => $v) {
602
-        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k.'='.$v.'&' : '';
602
+        $buff .= ('sign' != $k && '' != $v && !is_array($v)) ? $k . '=' . $v . '&' : '';
603 603
     }
604 604
 
605
-    return strtoupper(md5($buff.'key='.$key));
605
+    return strtoupper(md5($buff . 'key=' . $key));
606 606
 }
607 607
 
608 608
 /**
Please login to merge, or discard this patch.
src/Packer/XmlPacker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 class XmlPacker implements PackerInterface
12 12
 {
13
-    public function pack(null|array|Collection $payload): string
13
+    public function pack(null | array | Collection $payload): string
14 14
     {
15 15
         return Collection::wrap($payload)->toXml();
16 16
     }
Please login to merge, or discard this patch.
src/Packer/QueryPacker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 class QueryPacker implements PackerInterface
12 12
 {
13
-    public function pack(null|array|Collection $payload): string
13
+    public function pack(null | array | Collection $payload): string
14 14
     {
15 15
         return Collection::wrap($payload)->query();
16 16
     }
Please login to merge, or discard this patch.
src/Packer/JsonPacker.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 class JsonPacker implements PackerInterface
12 12
 {
13
-    public function pack(null|array|Collection $payload): string
13
+    public function pack(null | array | Collection $payload): string
14 14
     {
15 15
         if (empty($payload)) {
16 16
             return '';
Please login to merge, or discard this patch.
src/Contract/PackerInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 interface PackerInterface
10 10
 {
11
-    public function pack(null|array|Collection $payload): string;
11
+    public function pack(null | array | Collection $payload): string;
12 12
 
13 13
     public function unpack(string $payload): ?array;
14 14
 }
Please login to merge, or discard this patch.
src/Provider/AbstractProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @throws InvalidParamsException
35 35
      * @throws ServiceNotFoundException
36 36
      */
37
-    public function shortcut(string $shortcut, array $params = []): null|Collection|MessageInterface|Rocket
37
+    public function shortcut(string $shortcut, array $params = []): null | Collection | MessageInterface | Rocket
38 38
     {
39 39
         if (!class_exists($shortcut) || !in_array(ShortcutInterface::class, class_implements($shortcut))) {
40 40
             throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_NOT_FOUND, "参数异常: [{$shortcut}] 未实现 `ShortcutInterface`");
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @throws ContainerException
51 51
      * @throws InvalidParamsException
52 52
      */
53
-    public function pay(array $plugins, array $params): null|Collection|MessageInterface|Rocket
53
+    public function pay(array $plugins, array $params): null | Collection | MessageInterface | Rocket
54 54
     {
55 55
         Logger::info('[AbstractProvider] 即将进行 pay 操作', func_get_args());
56 56
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         } catch (Throwable $e) {
113 113
             Logger::error('[AbstractProvider] 请求支付服务商 API 出错', ['message' => $e->getMessage(), 'rocket' => $rocket->toArray(), 'trace' => $e->getTrace()]);
114 114
 
115
-            throw new InvalidResponseException(Exception::REQUEST_RESPONSE_ERROR, '响应异常: 请求支付服务商 API 出错 - '.$e->getMessage(), [], $e);
115
+            throw new InvalidResponseException(Exception::REQUEST_RESPONSE_ERROR, '响应异常: 请求支付服务商 API 出错 - ' . $e->getMessage(), [], $e);
116 116
         }
117 117
 
118 118
         Logger::info('[AbstractProvider] 请求支付服务商 API 成功', ['rocket' => $rocket->toArray()]);
Please login to merge, or discard this patch.