Skip to content

Commit

Permalink
update to guzzle7 and make implementation psr-18 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Butcher committed Aug 2, 2021
1 parent 42a0a58 commit b4c1b31
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"php": "^7.3 || ^8.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.0",
"php-http/httplug": "^1.0",
"php-http/message": "^1.0",
"php-http/httplug": "^2.2.0",
"php-http/message": "^1.11.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"guzzlehttp/psr7": "^2.0",
"mockery/mockery": "^1.0",
"php-http/guzzle6-adapter": "^1.0",
"php-http/guzzle7-adapter": "^1.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
Expand Down
3 changes: 2 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Facebook\Exception\SDKException;
use Http\Client\HttpClient;
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;

class Client
Expand Down Expand Up @@ -189,7 +190,7 @@ public function sendRequest(Request $request)
list($url, $method, $headers, $body) = $this->prepareRequestMessage($request);

$psr7Response = $this->httpClient->sendRequest(
Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $url, $headers, $body)
MessageFactoryDiscovery::find()->createRequest($method, $url, $headers, $body)
);

static::$requestCount++;
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/FakeGraphApiForResumableUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use GuzzleHttp\Psr7\Response;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class FakeGraphApiForResumableUpload implements HttpClient
{
Expand All @@ -42,7 +43,7 @@ public function failOnTransfer()
$this->respondWith = 'FAIL_ON_TRANSFER';
}

public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
$body = $request->getBody()->__toString();
// Could be start, transfer or finish
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/FooHttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
use GuzzleHttp\Psr7\Response;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class FooHttpClientInterface implements HttpClient
{
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
return new Response(
200,
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/MyFooBatchHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
use GuzzleHttp\Psr7\Response;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class MyFooBatchHttpClient implements HttpClient
{
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
return new Response(
200,
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/MyFooHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
use GuzzleHttp\Psr7\Response;
use Http\Client\HttpClient;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class MyFooHttpClient implements HttpClient
{
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
return new Response(
200,
Expand Down

0 comments on commit b4c1b31

Please sign in to comment.