Skip to content

Commit

Permalink
[8.x] Avoid deprecated guzzle code (#37349)
Browse files Browse the repository at this point in the history
* Avoid deprecated guzzle code

* Fixed typo

* Fixed typo
  • Loading branch information
GrahamCampbell authored May 12, 2021
1 parent 4ffb75c commit 976751b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Http\Client;

use Closure;
use function GuzzleHttp\Promise\promise_for;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;
Expand Down Expand Up @@ -109,7 +108,11 @@ public static function response($body = null, $status = 200, $headers = [])
$headers['Content-Type'] = 'application/json';
}

return promise_for(new Psr7Response($status, $headers, $body));
$response = new Psr7Response($status, $headers, $body);

return class_exists(GuzzleHttp\Promise\Create::class)

This comment has been minimized.

Copy link
@allowing

allowing May 14, 2021

Contributor

Is \ missing here? Should it be a fully qualified class name?

? \GuzzleHttp\Promise\Create::promiseFor($response)
: \GuzzleHttp\Promise\promise_for($response);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Http/Client/RequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ protected function prepareMessage(Response $response)
{
$message = "HTTP request returned status code {$response->status()}";

$summary = \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());
$summary = class_exists(\GuzzleHttp\Psr7\Message::class)
? \GuzzleHttp\Psr7\Message::bodySummary($response->toPsrResponse())
: \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());

return is_null($summary) ? $message : $message .= ":\n{$summary}\n";
}
Expand Down

0 comments on commit 976751b

Please sign in to comment.