| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | 120 |          if (self::$config->offsetExists($key)) { | 
| 121 | - return self::$config[$key]; | |
| 121 | + return self::$config[ $key ]; | |
| 122 | 122 | } | 
| 123 | 123 | |
| 124 | 124 | return $default; | 
| @@ -190,7 +190,7 @@ discard block | ||
| 190 | 190 | |
| 191 | 191 |          foreach ($params as $k => $v) { | 
| 192 | 192 |              if ($v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) { | 
| 193 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); | |
| 193 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); | |
| 194 | 194 | |
| 195 | 195 | $stringToBeSigned .= $k . '=' . $v . '&'; | 
| 196 | 196 | } | 
| @@ -218,7 +218,7 @@ discard block | ||
| 218 | 218 | |
| 219 | 219 |          foreach ($params as $k => $v) { | 
| 220 | 220 |              if ($v !== '' && !is_null($v) && $k != 'sign' && '@' != substr($v, 0, 1)) { | 
| 221 | - $v = self::characet($v, $params['charset'] ?? 'utf-8'); | |
| 221 | + $v = self::characet($v, $params[ 'charset' ] ?? 'utf-8'); | |
| 222 | 222 | |
| 223 | 223 | $stringToBeSigned .= $k . '=' . urlencode($v) . '&'; | 
| 224 | 224 | } | 
| @@ -267,7 +267,7 @@ discard block | ||
| 267 | 267 | new SignFailed( | 
| 268 | 268 |                      self::$config->get('event.driver'), | 
| 269 | 269 |                      self::$config->get('event.method'), | 
| 270 | - [$data], | |
| 270 | + [ $data ], | |
| 271 | 271 | '支付宝RSA公钥错误。请检查 [ ali_public_key ] 配置项的公钥文件格式或路径是否正确' | 
| 272 | 272 | ) | 
| 273 | 273 | ); | 
| @@ -345,7 +345,7 @@ discard block | ||
| 345 | 345 | $data | 
| 346 | 346 | ) | 
| 347 | 347 | ); | 
| 348 | -        $data = array_filter($data, function ($value) { | |
| 348 | +        $data = array_filter($data, function($value) { | |
| 349 | 349 | return ($value == '' || is_null($value)) ? false : true; | 
| 350 | 350 | }); | 
| 351 | 351 | // 请求支付宝网关 | 
| @@ -412,21 +412,21 @@ discard block | ||
| 412 | 412 | ); | 
| 413 | 413 | } | 
| 414 | 414 | |
| 415 | -        $method = str_replace('.', '_', $data['method']) . '_response'; | |
| 415 | +        $method = str_replace('.', '_', $data[ 'method' ]) . '_response'; | |
| 416 | 416 | |
| 417 | 417 | // 签名不存在抛出应用异常,该异常为支付宝网关错误,例如 app_id 配置错误,没有返回签名,建议检查配置项是否正确 | 
| 418 | -        if (!isset($result['sign'])) { | |
| 418 | +        if (!isset($result[ 'sign' ])) { | |
| 419 | 419 | throw new SignException( | 
| 420 | 420 | '[' . $method . '] Get Alipay API Error: msg [' | 
| 421 | - . $result[$method]['msg'] . ']', | |
| 421 | + . $result[ $method ][ 'msg' ] . ']', | |
| 422 | 422 | $result | 
| 423 | 423 | ); | 
| 424 | 424 | } | 
| 425 | 425 | |
| 426 | - $result_method_content = json_encode($result[$method], JSON_UNESCAPED_UNICODE); | |
| 426 | + $result_method_content = json_encode($result[ $method ], JSON_UNESCAPED_UNICODE); | |
| 427 | 427 | $result_method_content = mb_convert_encoding($result_method_content, self::$respCharset, self::$fileCharset); | 
| 428 | 428 | // 验证支付返回的签名,验证失败抛出应用异常 | 
| 429 | -        if (!self::verifySign($result_method_content, $result['sign'])) { | |
| 429 | +        if (!self::verifySign($result_method_content, $result[ 'sign' ])) { | |
| 430 | 430 | Events::dispatch( | 
| 431 | 431 | SignFailed::NAME, | 
| 432 | 432 | new SignFailed( | 
| @@ -445,19 +445,19 @@ discard block | ||
| 445 | 445 | |
| 446 | 446 | // 业务返回处理,返回码 10000 则正常返回成功数据,其他的则抛出业务异常 | 
| 447 | 447 | // 捕获 BusinessException 异常 获取 raw 元素查看完整数据并做处理 | 
| 448 | -        if ($result[$method]['code'] != '10000' && Support::getConfig('business_exception', false)) { | |
| 448 | +        if ($result[ $method ][ 'code' ] != '10000' && Support::getConfig('business_exception', false)) { | |
| 449 | 449 | throw new Exceptions\BusinessException( | 
| 450 | 450 | '[' . $method | 
| 451 | - . '] Business Error: msg [' . $result[$method]['msg'] . ']' | |
| 452 | - . (isset($result[$method]['sub_code']) ? ' - sub_code [' | |
| 453 | - . $result[$method]['sub_code'] . ']' : '') | |
| 454 | - . (isset($result[$method]['sub_msg']) ? ' - sub_msg [' | |
| 455 | - . $result[$method]['sub_msg'] . ']' : ''), | |
| 456 | - $result[$method] | |
| 451 | + . '] Business Error: msg [' . $result[ $method ][ 'msg' ] . ']' | |
| 452 | + . (isset($result[ $method ][ 'sub_code' ]) ? ' - sub_code [' | |
| 453 | + . $result[ $method ][ 'sub_code' ] . ']' : '') | |
| 454 | + . (isset($result[ $method ][ 'sub_msg' ]) ? ' - sub_msg [' | |
| 455 | + . $result[ $method ][ 'sub_msg' ] . ']' : ''), | |
| 456 | + $result[ $method ] | |
| 457 | 457 | ); | 
| 458 | 458 | } | 
| 459 | 459 | |
| 460 | - return new AccessData($result[$method]); | |
| 460 | + return new AccessData($result[ $method ]); | |
| 461 | 461 | } | 
| 462 | 462 | |
| 463 | 463 | /** | 
| @@ -544,15 +544,15 @@ discard block | ||
| 544 | 544 | // 获取公共参数 | 
| 545 | 545 |          $payload = self::$config->get('payload'); | 
| 546 | 546 | // 设置方法 | 
| 547 | - $payload['method'] = $method; | |
| 547 | + $payload[ 'method' ] = $method; | |
| 548 | 548 | // 设置业务参数 | 
| 549 | - $payload['biz_content'] = json_encode($params); | |
| 549 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 550 | 550 | // 过滤空值 | 
| 551 | -        $payload = array_filter($payload, function ($value) { | |
| 551 | +        $payload = array_filter($payload, function($value) { | |
| 552 | 552 | return $value !== '' && !is_null($value); | 
| 553 | 553 | }); | 
| 554 | 554 | // 设置签名 | 
| 555 | - $payload['sign'] = self::generateSign($payload); | |
| 555 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 556 | 556 | // 获取支付宝网关地址 | 
| 557 | 557 |          $base_uri = self::getConfig('base_uri'); | 
| 558 | 558 | |
| @@ -577,23 +577,23 @@ discard block | ||
| 577 | 577 |      { | 
| 578 | 578 | // 请求跳转类接口,返回字符串组装格式get url或post表单形式,默认POST形式 | 
| 579 | 579 | $http_method = 'POST'; | 
| 580 | -        if (isset($params['http_method'])) { | |
| 581 | - $http_method = isset($params['http_method']) | |
| 582 | - ? $params['http_method'] : 'POST'; | |
| 583 | - unset($params['http_method']); | |
| 580 | +        if (isset($params[ 'http_method' ])) { | |
| 581 | + $http_method = isset($params[ 'http_method' ]) | |
| 582 | + ? $params[ 'http_method' ] : 'POST'; | |
| 583 | + unset($params[ 'http_method' ]); | |
| 584 | 584 | } | 
| 585 | 585 | // 获取公共参数 | 
| 586 | 586 |          $payload = self::$config->get('payload'); | 
| 587 | 587 | // 设置方法 | 
| 588 | - $payload['method'] = $method; | |
| 588 | + $payload[ 'method' ] = $method; | |
| 589 | 589 | // 设置业务参数 | 
| 590 | - $payload['biz_content'] = json_encode($params); | |
| 590 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 591 | 591 | // 过滤空值 | 
| 592 | -        $payload = array_filter($payload, function ($value) { | |
| 592 | +        $payload = array_filter($payload, function($value) { | |
| 593 | 593 | return $value !== '' && !is_null($value); | 
| 594 | 594 | }); | 
| 595 | 595 | // 设置签名 | 
| 596 | - $payload['sign'] = self::generateSign($payload); | |
| 596 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 597 | 597 | // 获取支付宝网关地址 | 
| 598 | 598 |          $base_uri = self::getConfig('base_uri'); | 
| 599 | 599 | |
| @@ -616,19 +616,19 @@ discard block | ||
| 616 | 616 | // 获取公共参数 | 
| 617 | 617 |          $payload = self::$config->get('payload'); | 
| 618 | 618 | // 设置方法 | 
| 619 | - $payload['method'] = $method; | |
| 619 | + $payload[ 'method' ] = $method; | |
| 620 | 620 | // 设置业务参数 | 
| 621 | - $payload['biz_content'] = json_encode($params); | |
| 621 | + $payload[ 'biz_content' ] = json_encode($params); | |
| 622 | 622 | // 过滤空值 | 
| 623 | -        $payload = array_filter($payload, function ($value) { | |
| 623 | +        $payload = array_filter($payload, function($value) { | |
| 624 | 624 | return $value !== '' && !is_null($value); | 
| 625 | 625 | }); | 
| 626 | 626 | ksort($payload); | 
| 627 | 627 | // 设置签名 | 
| 628 | - $payload['sign'] = self::generateSign($payload); | |
| 628 | + $payload[ 'sign' ] = self::generateSign($payload); | |
| 629 | 629 | |
| 630 | 630 |          foreach ($payload as &$value) { | 
| 631 | - $value = self::characet($value, $payload['charset']); | |
| 631 | + $value = self::characet($value, $payload[ 'charset' ]); | |
| 632 | 632 | } | 
| 633 | 633 | |
| 634 | 634 | return Response::create(http_build_query($payload)); | 
| @@ -647,14 +647,14 @@ discard block | ||
| 647 | 647 |      { | 
| 648 | 648 | $data = ($data === null) ? self::getRequest() : $data; | 
| 649 | 649 | $sign_type = null; | 
| 650 | -        if (isset($data['sign_type'])) { | |
| 651 | - $sign_type = $data['sign_type']; | |
| 652 | - $data['sign_type'] = null; | |
| 650 | +        if (isset($data[ 'sign_type' ])) { | |
| 651 | + $sign_type = $data[ 'sign_type' ]; | |
| 652 | + $data[ 'sign_type' ] = null; | |
| 653 | 653 | } | 
| 654 | 654 | |
| 655 | 655 | return self::verifySign( | 
| 656 | 656 | Support::getSignContent($data), | 
| 657 | - $data['sign'], | |
| 657 | + $data[ 'sign' ], | |
| 658 | 658 | $sign_type | 
| 659 | 659 | ); | 
| 660 | 660 | } | 
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | * @param $message | 
| 13 | 13 | * @param array $raw | 
| 14 | 14 | */ | 
| 15 | - public function __construct($message, $raw = []) | |
| 15 | + public function __construct($message, $raw = [ ]) | |
| 16 | 16 |      { | 
| 17 | 17 |          parent::__construct('-SIGN_ERROR: ' . $message, $raw); | 
| 18 | 18 | } | 
| @@ -30,9 +30,9 @@ discard block | ||
| 30 | 30 | public static function getSubscribedEvents() | 
| 31 | 31 |      { | 
| 32 | 32 | return [ | 
| 33 | - Events\ApiRequestStart::NAME => ['writeApiRequestStartLog', 256], | |
| 34 | - Events\ApiRequestEnd::NAME => ['writeApiRequestEndLog', 256], | |
| 35 | - Events\SignFailed::NAME => ['writeSignFailedLog', 256], | |
| 33 | + Events\ApiRequestStart::NAME => [ 'writeApiRequestStartLog', 256 ], | |
| 34 | + Events\ApiRequestEnd::NAME => [ 'writeApiRequestEndLog', 256 ], | |
| 35 | + Events\SignFailed::NAME => [ 'writeSignFailedLog', 256 ], | |
| 36 | 36 | ]; | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 |      { | 
| 79 | 79 | Log::error( | 
| 80 | 80 |              "[ Sign Failed ] Alipay::{$event->getDriver()}()->{$event->getMethod()}() error:[{$event->error}] ", | 
| 81 | - [$event->getResult()] | |
| 81 | + [ $event->getResult() ] | |
| 82 | 82 | ); | 
| 83 | 83 | } | 
| 84 | 84 | } | 
| @@ -129,7 +129,7 @@ | ||
| 129 | 129 |          $config->set('payload', $this->commonParams($config)); | 
| 130 | 130 | |
| 131 | 131 | // 设置支付宝网关 | 
| 132 | -        $base_uri = self::URL[$config->get('env', self::ENV_NORMAL)]; | |
| 132 | +        $base_uri = self::URL[ $config->get('env', self::ENV_NORMAL) ]; | |
| 133 | 133 |          $config->set('base_uri', $base_uri); | 
| 134 | 134 | |
| 135 | 135 | $this->registerLogService(); | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | * | 
| 141 | 141 | * @throws Exceptions\ApplicationException | 
| 142 | 142 | */ | 
| 143 | - public function alipayMethod($method, $params = []) | |
| 143 | + public function alipayMethod($method, $params = [ ]) | |
| 144 | 144 |      { | 
| 145 | 145 | $method = Str::studly($method); | 
| 146 | 146 | // 组装命名空间 | 
| @@ -163,7 +163,7 @@ discard block | ||
| 163 | 163 | * | 
| 164 | 164 | * @return mixed | 
| 165 | 165 | */ | 
| 166 | - public function make(string $gateway, $params = []) | |
| 166 | + public function make(string $gateway, $params = [ ]) | |
| 167 | 167 |      { | 
| 168 | 168 | $app = new $gateway(); | 
| 169 | 169 | |
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 |      { | 
| 184 | 184 |          Support::$config->set('event', [ | 
| 185 | 185 | 'driver' => 'Payment', | 
| 186 | - 'method' => $method ? : $this->method, | |
| 186 | + 'method' => $method ?: $this->method, | |
| 187 | 187 | ]); | 
| 188 | 188 | } | 
| 189 | 189 | |