From 15d0f2d3cadae7ee55c31cda4dd6d0bcf1582da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislav=20Janu=CC=8A?= Date: Mon, 24 Apr 2023 12:28:13 +0200 Subject: [PATCH] PSR-7 --- composer.json | 3 +- composer.lock | 460 +++++++++--------- src/BatchRequest.php | 4 +- src/Client.php | 28 +- src/Http/RequestBodyInterface.php | 5 +- src/Http/RequestBodyMultipart.php | 6 +- src/Http/RequestBodyUrlEncoded.php | 11 +- tests/BatchRequestTest.php | 1 + tests/ClientTest.php | 8 +- .../FakeGraphApiForResumableUpload.php | 4 +- tests/Fixtures/FooHttpClientInterface.php | 4 +- tests/Fixtures/MyFooBatchHttpClient.php | 4 +- tests/Fixtures/MyFooHttpClient.php | 4 +- 13 files changed, 282 insertions(+), 260 deletions(-) diff --git a/composer.json b/composer.json index 26e3eab..8c0a681 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "php-http/httplug": "^2.4", "php-http/discovery": "^1.15", "php-http/message": "^1.14", - "thecodingmachine/safe": "^1.3" + "thecodingmachine/safe": "^1.3", + "guzzlehttp/psr7": "^2.5" }, "require-dev": { "stanislav-janu/phpstan": "^1.0", diff --git a/composer.lock b/composer.lock index 5873d23..15d9f38 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7dec697db85d996065af2e3145d0f83b", + "content-hash": "82f37d4ed358f884c32d8f1dba6c362b", "packages": [ { "name": "clue/stream-filter", @@ -72,6 +72,122 @@ ], "time": "2022-02-21T13:15:14+00:00" }, + { + "name": "guzzlehttp/psr7", + "version": "2.5.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", + "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.5.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2023-04-17T16:11:26+00:00" + }, { "name": "php-http/discovery", "version": "1.15.3", @@ -435,6 +551,61 @@ }, "time": "2023-04-10T20:12:12+00:00" }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + }, + "time": "2023-04-10T20:10:41+00:00" + }, { "name": "psr/http-message", "version": "1.1", @@ -488,6 +659,50 @@ }, "time": "2023-04-04T09:50:52+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "thecodingmachine/safe", "version": "v1.3.3", @@ -841,122 +1056,6 @@ ], "time": "2022-08-28T14:55:35+00:00" }, - { - "name": "guzzlehttp/psr7", - "version": "2.5.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2023-04-17T16:11:26+00:00" - }, { "name": "jetbrains/phpstorm-attributes", "version": "1.0", @@ -1829,16 +1928,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.1.1", + "version": "10.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "0d9401b7e8245d71079e249e3cb868e9d2337887" + "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d9401b7e8245d71079e249e3cb868e9d2337887", - "reference": "0d9401b7e8245d71079e249e3cb868e9d2337887", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f0cd95be71add539f8fd2be25b2a4a29789000b", + "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b", "shasum": "" }, "require": { @@ -1910,7 +2009,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.2" }, "funding": [ { @@ -1926,124 +2025,25 @@ "type": "tidelift" } ], - "time": "2023-04-17T12:17:05+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "e616d01114759c4c489f93b099585439f795fe35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", - "reference": "e616d01114759c4c489f93b099585439f795fe35", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/1.0.2" - }, - "time": "2023-04-10T20:10:41+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" + "time": "2023-04-22T07:38:19+00:00" }, { "name": "rector/rector", - "version": "0.15.24", + "version": "0.15.25", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "716473919bcfdc27bdd2a32afb72adbf4c224e59" + "reference": "015935c7ed9e48a4f5895ba974f337e20a263841" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/716473919bcfdc27bdd2a32afb72adbf4c224e59", - "reference": "716473919bcfdc27bdd2a32afb72adbf4c224e59", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/015935c7ed9e48a4f5895ba974f337e20a263841", + "reference": "015935c7ed9e48a4f5895ba974f337e20a263841", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.1" + "phpstan/phpstan": "^1.10.14" }, "conflict": { "rector/rector-doctrine": "*", @@ -2078,7 +2078,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.15.24" + "source": "https://github.com/rectorphp/rector/tree/0.15.25" }, "funding": [ { @@ -2086,7 +2086,7 @@ "type": "github" } ], - "time": "2023-04-05T08:49:11+00:00" + "time": "2023-04-20T16:07:39+00:00" }, { "name": "sebastian/cli-parser", @@ -3220,7 +3220,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.0 <8.3" + "php": ">=8.1 <8.3" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/src/BatchRequest.php b/src/BatchRequest.php index 6d3c161..c986114 100755 --- a/src/BatchRequest.php +++ b/src/BatchRequest.php @@ -254,8 +254,8 @@ public function requestEntityToBatchArray( // the child requests will always be URL-encoded. $body = $request->getUrlEncodedBody() ->getBody(); - if ($body !== '' && $body !== '0') { - $batch['body'] = $body; + if ($body !== null) { + $batch['body'] = $body->getContents(); } $batch += $options; diff --git a/src/Client.php b/src/Client.php index 786082c..ab785b1 100755 --- a/src/Client.php +++ b/src/Client.php @@ -22,10 +22,12 @@ namespace JanuSoftware\Facebook; -use Http\Client\HttpClient; +use GuzzleHttp\Psr7\Utils; use Http\Discovery\HttpClientDiscovery; -use Http\Discovery\MessageFactoryDiscovery; +use Http\Discovery\Psr17FactoryDiscovery; use JanuSoftware\Facebook\Exception\SDKException; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\StreamInterface; use function Safe\sprintf; @@ -68,14 +70,14 @@ class Client public static int $requestCount = 0; - protected HttpClient $httpClient; + protected ClientInterface $httpClient; /** * Instantiates a new Client object. */ public function __construct( - HttpClient $httpClient = null, + ClientInterface $httpClient = null, protected bool $enableBetaMode = false, ) { $this->httpClient = $httpClient ?? HttpClientDiscovery::find(); @@ -85,7 +87,7 @@ public function __construct( /** * Sets the HTTP client handler. */ - public function setHttpClient(HttpClient $httpClient): void + public function setHttpClient(ClientInterface $httpClient): void { $this->httpClient = $httpClient; } @@ -94,7 +96,7 @@ public function setHttpClient(HttpClient $httpClient): void /** * Returns the HTTP client handler. */ - public function getHttpClient(): HttpClient + public function getHttpClient(): ClientInterface { return $this->httpClient; } @@ -168,11 +170,15 @@ public function sendRequest(Request|BatchRequest $request): Response [$url, $method, $headers, $body] = $this->prepareRequestMessage($request); - /** - * @phpstan-ignore-next-line - */ - $psr7Response = $this->httpClient->sendRequest(MessageFactoryDiscovery::find() - ->createRequest($method, $url, $headers, $body)); + $requestFactory = Psr17FactoryDiscovery::findRequestFactory()->createRequest($method, $url); + if ($body instanceof StreamInterface) { + $requestFactory = $requestFactory->withBody($body); + } + foreach ($headers as $name => $value) { + $requestFactory = $requestFactory->withHeader($name, $value); + } + + $psr7Response = $this->httpClient->sendRequest($requestFactory); static::$requestCount++; diff --git a/src/Http/RequestBodyInterface.php b/src/Http/RequestBodyInterface.php index 85936bf..6f8ced6 100755 --- a/src/Http/RequestBodyInterface.php +++ b/src/Http/RequestBodyInterface.php @@ -25,10 +25,13 @@ namespace JanuSoftware\Facebook\Http; +use Psr\Http\Message\StreamInterface; + + interface RequestBodyInterface { /** * Get the body of the request to send to Graph. */ - public function getBody(): string; + public function getBody(): ?StreamInterface; } diff --git a/src/Http/RequestBodyMultipart.php b/src/Http/RequestBodyMultipart.php index a6f009e..05df6c7 100755 --- a/src/Http/RequestBodyMultipart.php +++ b/src/Http/RequestBodyMultipart.php @@ -25,7 +25,9 @@ namespace JanuSoftware\Facebook\Http; +use GuzzleHttp\Psr7\Utils; use JanuSoftware\Facebook\FileUpload\File; +use Psr\Http\Message\StreamInterface; use function Safe\sprintf; /** @@ -52,7 +54,7 @@ public function __construct( } - public function getBody(): string + public function getBody(): ?StreamInterface { $body = ''; @@ -70,7 +72,7 @@ public function getBody(): string // Peace out $body .= "--{$this->boundary}--\r\n"; - return $body; + return Utils::streamFor($body); } diff --git a/src/Http/RequestBodyUrlEncoded.php b/src/Http/RequestBodyUrlEncoded.php index 6dbe961..2c95963 100755 --- a/src/Http/RequestBodyUrlEncoded.php +++ b/src/Http/RequestBodyUrlEncoded.php @@ -25,6 +25,10 @@ namespace JanuSoftware\Facebook\Http; +use GuzzleHttp\Psr7\Utils; +use Psr\Http\Message\StreamInterface; + + class RequestBodyUrlEncoded implements RequestBodyInterface { /** @@ -36,8 +40,11 @@ public function __construct( } - public function getBody(): string + public function getBody(): ?StreamInterface { - return http_build_query($this->params); + $string = http_build_query($this->params); + return $string === '' || $string === '0' + ? null + : Utils::streamFor($string); } } diff --git a/tests/BatchRequestTest.php b/tests/BatchRequestTest.php index 2726fdc..b73581d 100755 --- a/tests/BatchRequestTest.php +++ b/tests/BatchRequestTest.php @@ -327,6 +327,7 @@ public function testPreppingABatchRequestProperlySetsThePostParams(): void 'access_token' => 'foo_token', 'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', ]; + $this->assertEquals($expectedBatchParams, $params); } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e060218..ebc0b90 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -25,14 +25,12 @@ namespace JanuSoftware\Facebook\Tests; -use Http\Client\HttpClient; use JanuSoftware\Facebook\Application; use JanuSoftware\Facebook\BatchRequest; use JanuSoftware\Facebook\BatchResponse; use JanuSoftware\Facebook\Client; use JanuSoftware\Facebook\Exception\SDKException; use JanuSoftware\Facebook\FileUpload\File; -// These are needed when you uncomment the HTTP clients below. use JanuSoftware\Facebook\FileUpload\Video; use JanuSoftware\Facebook\GraphNode\GraphNode; use JanuSoftware\Facebook\Request; @@ -40,6 +38,8 @@ use JanuSoftware\Facebook\Tests\Fixtures\MyFooBatchHttpClient; use JanuSoftware\Facebook\Tests\Fixtures\MyFooHttpClient; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientInterface; + class ClientTest extends TestCase { @@ -71,7 +71,7 @@ public function testTheHttpClientWillFallbackToDefault(): void $client = new Client; $httpClient = $client->getHttpClient(); - $this->assertInstanceOf(HttpClient::class, $httpClient); + $this->assertInstanceOf(ClientInterface::class, $httpClient); } @@ -158,6 +158,8 @@ public function testABatchRequestWillProperlyBatchFiles(): void [$url, $method, $headers, $body] = $this->fbClient->prepareRequestMessage($fbBatchRequest); + $body = $body?->getContents() ?? ''; + $this->assertEquals(Client::BASE_GRAPH_VIDEO_URL, $url); $this->assertEquals('POST', $method); $this->assertStringContainsString('multipart/form-data; boundary=', $headers['Content-Type']); diff --git a/tests/Fixtures/FakeGraphApiForResumableUpload.php b/tests/Fixtures/FakeGraphApiForResumableUpload.php index 9543e8a..278fe5c 100644 --- a/tests/Fixtures/FakeGraphApiForResumableUpload.php +++ b/tests/Fixtures/FakeGraphApiForResumableUpload.php @@ -26,12 +26,12 @@ namespace JanuSoftware\Facebook\Tests\Fixtures; use GuzzleHttp\Psr7\Response; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class FakeGraphApiForResumableUpload implements HttpClient +class FakeGraphApiForResumableUpload implements ClientInterface { public int $transferCount = 0; private string $respondWith = 'SUCCESS'; diff --git a/tests/Fixtures/FooHttpClientInterface.php b/tests/Fixtures/FooHttpClientInterface.php index 3b38b32..18e4f56 100644 --- a/tests/Fixtures/FooHttpClientInterface.php +++ b/tests/Fixtures/FooHttpClientInterface.php @@ -26,12 +26,12 @@ namespace JanuSoftware\Facebook\Tests\Fixtures; use GuzzleHttp\Psr7\Response; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class FooHttpClientInterface implements HttpClient +class FooHttpClientInterface implements ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface { diff --git a/tests/Fixtures/MyFooBatchHttpClient.php b/tests/Fixtures/MyFooBatchHttpClient.php index 6a13f8f..d817b3a 100644 --- a/tests/Fixtures/MyFooBatchHttpClient.php +++ b/tests/Fixtures/MyFooBatchHttpClient.php @@ -26,12 +26,12 @@ namespace JanuSoftware\Facebook\Tests\Fixtures; use GuzzleHttp\Psr7\Response; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class MyFooBatchHttpClient implements HttpClient +class MyFooBatchHttpClient implements ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface { diff --git a/tests/Fixtures/MyFooHttpClient.php b/tests/Fixtures/MyFooHttpClient.php index 626fee1..aeb0027 100644 --- a/tests/Fixtures/MyFooHttpClient.php +++ b/tests/Fixtures/MyFooHttpClient.php @@ -26,12 +26,12 @@ namespace JanuSoftware\Facebook\Tests\Fixtures; use GuzzleHttp\Psr7\Response; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -class MyFooHttpClient implements HttpClient +class MyFooHttpClient implements ClientInterface { public function sendRequest(RequestInterface $request): ResponseInterface {