Skip to content

Commit

Permalink
Compatibility fix for HTTPlug 2.0 packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mxr576 committed Jan 22, 2019
1 parent 665d171 commit 502181c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/HttpClient/Plugin/ResponseHandlerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Http\Client\Exception\RequestException;
use Http\Message\Formatter;
use Http\Message\Formatter\FullHttpMessageFormatter;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand Down Expand Up @@ -57,8 +58,7 @@ public function __construct(Formatter $formatter = null)
* @psalm-suppress UndefinedMethod - $e->getResponse() is not undefined.
* @psalm-suppress InvalidArgument - $e is not an invalid argument.
*/
public function handleRequest(RequestInterface $request, callable $next, callable $first)
{
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise {
return $next($request)->then(function (ResponseInterface $response) use ($request) {
return $this->decodeResponse($response, $request);
}, function (Exception $e) use ($request): void {
Expand Down
3 changes: 2 additions & 1 deletion src/HttpClient/Plugin/RetryOauthAuthenticationPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Apigee\Edge\HttpClient\Plugin\Authentication\Oauth;
use Http\Client\Common\Plugin;
use Http\Client\Exception;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function __construct(Oauth $auth)
*
* @psalm-suppress InvalidThrow - Exception with interface can be thrown.
*/
public function handleRequest(RequestInterface $request, callable $next, callable $first)
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
{
return $next($request)->then(function (ResponseInterface $response) {
return $response;
Expand Down
14 changes: 4 additions & 10 deletions src/HttpClient/Utility/Journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Apigee\Edge\HttpClient\Utility;

use Http\Client\Exception;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand Down Expand Up @@ -50,10 +50,7 @@ final class Journal implements JournalInterface
private $success = true;

/**
* Record a successful call.
*
* @param \Psr\Http\Message\RequestInterface $request Request use to make the call
* @param \Psr\Http\Message\ResponseInterface $response Response returned by the call
* @inheritdoc
*/
public function addSuccess(RequestInterface $request, ResponseInterface $response): void
{
Expand All @@ -63,12 +60,9 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
}

/**
* Record a failed call.
*
* @param \Psr\Http\Message\RequestInterface $request Request use to make the call
* @param \Http\Client\Exception $exception Exception returned by the call
* @inheritdoc
*/
public function addFailure(RequestInterface $request, Exception $exception): void
public function addFailure(RequestInterface $request, ClientExceptionInterface $exception): void
{
$this->lastRequest = $request;
$this->lastException = $exception;
Expand Down
3 changes: 2 additions & 1 deletion tests/Test/HttpClient/FileSystemHttpMockClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Http\Client\HttpClient;
use League\Flysystem\AdapterInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
* Loads the content of an HTTP response from the file system if available.
Expand All @@ -49,7 +50,7 @@ public function __construct(AdapterInterface $adapter = null)
*
* @see HttpClient::sendRequest
*/
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
return $this->fileSystemResponseFactory->createResponseForRequest($request, 200, null, ['Content-Type' => 'application/json']);
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/HttpClient/MockHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __call($name, $arguments)
*
* @see HttpClient::sendRequest
*/
public function sendRequest(RequestInterface $request)
public function sendRequest(RequestInterface $request): ResponseInterface
{
try {
return $this->decorated->sendRequest($request);
Expand Down
4 changes: 2 additions & 2 deletions tests/Test/HttpClient/Utility/TestJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace Apigee\Edge\Tests\Test\HttpClient\Utility;

use Apigee\Edge\HttpClient\Utility\JournalInterface;
use Http\Client\Exception;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -46,7 +46,7 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons
/**
* @inheritdoc
*/
public function addFailure(RequestInterface $request, Exception $exception): void
public function addFailure(RequestInterface $request, ClientExceptionInterface $exception): void
{
$this->requests[] = $request;
$this->exceptions[] = $exception;
Expand Down

0 comments on commit 502181c

Please sign in to comment.