From 092cbac8dddf785f1d6c44c3c22bf543b5a286e6 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Mon, 15 May 2023 11:26:50 +0200 Subject: [PATCH] Remove work arounds for old Guzzle versions --- phpstan.src.neon.dist | 1 - src/Illuminate/Http/Client/Factory.php | 5 ++--- src/Illuminate/Http/Client/Pool.php | 7 +------ src/Illuminate/Http/Client/RequestException.php | 6 +++--- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/phpstan.src.neon.dist b/phpstan.src.neon.dist index 3062fdb4b4e0..e41d8a55fc34 100644 --- a/phpstan.src.neon.dist +++ b/phpstan.src.neon.dist @@ -12,7 +12,6 @@ parameters: - "#Class [a-zA-Z0-9\\\\_]+ not found.#" - "#has invalid type#" - "#should always throw an exception or terminate script execution#" - - "#Function GuzzleHttp\\\\Psr7#" - "#Instantiated class [a-zA-Z0-9\\\\_]+ not found.#" - "#Unsafe usage of new static#" excludePaths: diff --git a/src/Illuminate/Http/Client/Factory.php b/src/Illuminate/Http/Client/Factory.php index 457714bab3f5..ab0c0c53a001 100644 --- a/src/Illuminate/Http/Client/Factory.php +++ b/src/Illuminate/Http/Client/Factory.php @@ -3,6 +3,7 @@ namespace Illuminate\Http\Client; use Closure; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\Response as Psr7Response; use GuzzleHttp\TransferStats; @@ -93,9 +94,7 @@ public static function response($body = null, $status = 200, $headers = []) $response = new Psr7Response($status, $headers, $body); - return class_exists(\GuzzleHttp\Promise\Create::class) - ? \GuzzleHttp\Promise\Create::promiseFor($response) - : \GuzzleHttp\Promise\promise_for($response); + return Create::promiseFor($response); } /** diff --git a/src/Illuminate/Http/Client/Pool.php b/src/Illuminate/Http/Client/Pool.php index bedffcb1d652..7aed87f88a19 100644 --- a/src/Illuminate/Http/Client/Pool.php +++ b/src/Illuminate/Http/Client/Pool.php @@ -39,12 +39,7 @@ class Pool public function __construct(Factory $factory = null) { $this->factory = $factory ?: new Factory(); - - if (method_exists(Utils::class, 'chooseHandler')) { - $this->handler = Utils::chooseHandler(); - } else { - $this->handler = \GuzzleHttp\choose_handler(); - } + $this->handler = Utils::chooseHandler(); } /** diff --git a/src/Illuminate/Http/Client/RequestException.php b/src/Illuminate/Http/Client/RequestException.php index fa4f418398ae..5dd37e306ebc 100644 --- a/src/Illuminate/Http/Client/RequestException.php +++ b/src/Illuminate/Http/Client/RequestException.php @@ -2,6 +2,8 @@ namespace Illuminate\Http\Client; +use GuzzleHttp\Psr7\Message; + class RequestException extends HttpClientException { /** @@ -34,9 +36,7 @@ protected function prepareMessage(Response $response) { $message = "HTTP request returned status code {$response->status()}"; - $summary = class_exists(\GuzzleHttp\Psr7\Message::class) - ? \GuzzleHttp\Psr7\Message::bodySummary($response->toPsrResponse()) - : \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse()); + $summary = Message::bodySummary($response->toPsrResponse()); return is_null($summary) ? $message : $message .= ":\n{$summary}\n"; }