From 3683c69c1a0dfb5c192495d3754127d132d09bd2 Mon Sep 17 00:00:00 2001 From: yansongda Date: Mon, 10 Jun 2024 22:01:39 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E4=BC=98=E5=8C=96=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=20`ResponsePlugin`=20=E6=8F=92=E4=BB=B6=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20(#996)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ src/Plugin/Wechat/ResponsePlugin.php | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f287eb8f..fc98e69d2 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 90ac4dea4..f284dc1b0 100644 --- a/src/Plugin/Wechat/ResponsePlugin.php +++ b/src/Plugin/Wechat/ResponsePlugin.php @@ -5,14 +5,12 @@ 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 @@ public function assembly(Rocket $rocket, Closure $next): Rocket Logger::debug('[Wechat][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]); - $rocket->setDestination($this->validateResponse($rocket)); + $this->validateResponse($rocket); Logger::info('[Wechat][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]); @@ -36,7 +34,7 @@ public function assembly(Rocket $rocket, Closure $next): Rocket /** * @throws InvalidResponseException */ - protected function validateResponse(Rocket $rocket): null|Collection|MessageInterface + protected function validateResponse(Rocket $rocket): void { $response = $rocket->getDestinationOrigin(); @@ -44,7 +42,5 @@ protected function validateResponse(Rocket $rocket): null|Collection|MessageInte && ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) { throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '微信返回状态码异常,请检查参数是否错误', $rocket->getDestination()); } - - return $rocket->getDestination(); } }