Skip to content

Commit

Permalink
Remove work arounds for old Guzzle versions (#47084)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored May 15, 2023
1 parent 89e549d commit ab18c4a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion phpstan.src.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/Illuminate/Http/Client/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Http/Client/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Illuminate\Http\Client;

use GuzzleHttp\Psr7\Message;

class RequestException extends HttpClientException
{
/**
Expand Down Expand Up @@ -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";
}
Expand Down

0 comments on commit ab18c4a

Please sign in to comment.