From ab9be2a6f09ca28ce4a9902556edbb1d8f9f495d Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Mon, 10 Jul 2023 21:52:49 +0000 Subject: [PATCH] feat: Guzzle Promises 2.0.0 --- src/OAuth2Middleware.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OAuth2Middleware.php b/src/OAuth2Middleware.php index 72e3a39..0670907 100644 --- a/src/OAuth2Middleware.php +++ b/src/OAuth2Middleware.php @@ -83,6 +83,11 @@ private function onFulfilled(RequestInterface $request, array $options, $handler private function onRejected(RequestInterface $request, array $options, $handler) { return function ($reason) use ($request, $options) { + if (class_exists('\GuzzleHttp\Promise\Create')) { + return \GuzzleHttp\Promise\Create::rejectionFor($reason); + } + + // As of Guzzle Promises 2.0.0, the rejection_for function is deprecated and replaced with Create::rejectionFor return \GuzzleHttp\Promise\rejection_for($reason); }; }