diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f287eb..fc98e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## TBD - v3.7.5 +### optimized + +- optimize: 优化微信 `ResponsePlugin` 插件去除不必要的返回参数(#996) + ### deprecated - deprecate: 微信 `StartPlugin` 改为使用 `yansongda/artful` 中的插件(#993) diff --git a/src/Plugin/Wechat/ResponsePlugin.php b/src/Plugin/Wechat/ResponsePlugin.php index 90ac4de..f284dc1 100644 --- a/src/Plugin/Wechat/ResponsePlugin.php +++ b/src/Plugin/Wechat/ResponsePlugin.php @@ -5,14 +5,12 @@ declare(strict_types=1); namespace Yansongda\Pay\Plugin\Wechat; use Closure; -use Psr\Http\Message\MessageInterface; use Psr\Http\Message\ResponseInterface; use Yansongda\Artful\Contract\PluginInterface; use Yansongda\Artful\Exception\InvalidResponseException; use Yansongda\Artful\Logger; use Yansongda\Artful\Rocket; use Yansongda\Pay\Exception\Exception; -use Yansongda\Supports\Collection; class ResponsePlugin implements PluginInterface { @@ -26,7 +24,7 @@ class ResponsePlugin implements PluginInterface Logger::debug('[Wechat][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]); - $rocket->setDestination($this->validateResponse($rocket)); + $this->validateResponse($rocket); Logger::info('[Wechat][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]); @@ -36,7 +34,7 @@ class ResponsePlugin implements PluginInterface /** * @throws InvalidResponseException */ - protected function validateResponse(Rocket $rocket): null|Collection|MessageInterface + protected function validateResponse(Rocket $rocket): void { $response = $rocket->getDestinationOrigin(); @@ -44,7 +42,5 @@ class ResponsePlugin implements PluginInterface && ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) { throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '微信返回状态码异常,请检查参数是否错误', $rocket->getDestination()); } - - return $rocket->getDestination(); } }