From b9cf6ee6f892c1763eff360d6fda7a900908758a Mon Sep 17 00:00:00 2001 From: yansongda Date: Sun, 9 Jul 2023 19:24:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20destination=20=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=BA=A6=E6=9D=9F=E5=8E=BB=E6=8E=89=20array=20(#824)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ src/Provider/AbstractProvider.php | 2 +- src/Rocket.php | 6 +++--- tests/Plugin/Unipay/LaunchPluginTest.php | 2 +- tests/Plugin/Wechat/LaunchPluginTest.php | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5cc357b..890404f39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## v3.5.0 +### fixed + +- fix: `destination` 的类型约束去掉 array(#824) + +## v3.5.0 + ### deleted - deleted: 移除 `Yansongda\Pay\Direction\ArrayDirection` 类(#818, #819) diff --git a/src/Provider/AbstractProvider.php b/src/Provider/AbstractProvider.php index f7e088090..8ec82caa5 100644 --- a/src/Provider/AbstractProvider.php +++ b/src/Provider/AbstractProvider.php @@ -56,7 +56,7 @@ public function call(string $plugin, array $params = []): Collection|MessageInte * @throws ContainerException * @throws InvalidParamsException */ - public function pay(array $plugins, array $params): Collection|MessageInterface|array|null + public function pay(array $plugins, array $params): Collection|MessageInterface|null { Logger::info('[AbstractProvider] 即将进行 pay 操作', func_get_args()); diff --git a/src/Rocket.php b/src/Rocket.php index 93adfbd19..22c3bec34 100644 --- a/src/Rocket.php +++ b/src/Rocket.php @@ -32,7 +32,7 @@ class Rocket implements JsonSerializableInterface, ArrayAccess private string $direction = DirectionInterface::class; - private array|null|MessageInterface|Collection $destination = null; + private null|MessageInterface|Collection $destination = null; private null|RequestInterface|ResponseInterface $destinationOrigin = null; @@ -114,12 +114,12 @@ public function setDirection(string $direction): Rocket return $this; } - public function getDestination(): Collection|MessageInterface|array|null + public function getDestination(): Collection|MessageInterface|null { return $this->destination; } - public function setDestination(Collection|MessageInterface|array|null $destination): Rocket + public function setDestination(Collection|MessageInterface|null $destination): Rocket { $this->destination = $destination; diff --git a/tests/Plugin/Unipay/LaunchPluginTest.php b/tests/Plugin/Unipay/LaunchPluginTest.php index f6fc66814..8af51a5be 100644 --- a/tests/Plugin/Unipay/LaunchPluginTest.php +++ b/tests/Plugin/Unipay/LaunchPluginTest.php @@ -155,7 +155,7 @@ public function testArrayDirection() ]; $rocket = new Rocket(); - $rocket->setDestination($response); + $rocket->setDestination(Collection::wrap($response)); $result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; }); diff --git a/tests/Plugin/Wechat/LaunchPluginTest.php b/tests/Plugin/Wechat/LaunchPluginTest.php index 0923fe703..b24144581 100644 --- a/tests/Plugin/Wechat/LaunchPluginTest.php +++ b/tests/Plugin/Wechat/LaunchPluginTest.php @@ -72,12 +72,12 @@ public function testArrayDestination() $rocket = new Rocket(); $rocket->setDirection(OriginResponseDirection::class); - $rocket->setDestination($destination); + $rocket->setDestination(Collection::wrap($destination)); $rocket->setDestinationOrigin(new ServerRequest('POST', 'http://localhost')); $result = $this->plugin->assembly($rocket, function ($rocket) { return $rocket; }); - self::assertEquals($destination, $result->getDestination()); + self::assertEquals($destination, $result->getDestination()->toArray()); } public function testCollectionDestination()