Skip to content

Commit

Permalink
Drop support of HTTPlug 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mxr576 committed Oct 12, 2020
1 parent cf38154 commit 0d8e730
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [2.0.6]
* Dropped support of HTTPlug 1.x libraries (HTTPlug, Client Common and Guzzle 6 adapter).

## [2.0.5](https://github.com/apigee/apigee-client-php/milestone/3?closed=1) - May 26 2020
* GA support for Apigee hybrid Management API.
* Remove Alpha note about Monetization in README.
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"fightbulc/moment": "^1.26",
"firebase/php-jwt": "^5.0",
"league/period": "^3.4",
"php-http/client-common": "^1.9",
"php-http/client-common": "^2.0",
"php-http/client-implementation": "^1.0",
"php-http/discovery": "^1.0",
"php-http/httplug": "^1.1",
"php-http/discovery": "^1.6.0",
"php-http/httplug": "^2.0",
"php-http/message": "^1.0",
"php-http/message-factory": "^1.0",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0",
Expand All @@ -40,7 +40,7 @@
"league/flysystem": "^1.0",
"limedeck/phpunit-detailed-printer": "^3.2",
"monolog/monolog": "^1.23",
"php-http/guzzle6-adapter": "^1.1.1",
"php-http/guzzle6-adapter": "^2.0",
"php-http/mock-client": "^1.1.0",
"phpmetrics/phpmetrics": "^2.3",
"phpunit/phpunit": "^6.4.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/authentication.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

/**
/*
* Provides a client factory that can build a API client. It reads necessary credentials from environment variables.
*
* Requires the following environment variables to be set on your system:
Expand Down
2 changes: 1 addition & 1 deletion examples/list_multiple_entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

/**
/*
* This example demonstrates how you can list entities (developers, api products, developer apps, etc.) from a type.
*/
use Apigee\Edge\Api\Management\Controller\ApiProductController;
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

use Apigee\Edge\Exception\ApiResponseException;
use Apigee\Edge\Exception\OauthAuthenticationException;
use Apigee\Edge\HttpClient\Plugin\AddPathPlugin;
use Apigee\Edge\HttpClient\Plugin\Authentication\AbstractOauth;
use Apigee\Edge\HttpClient\Plugin\ResponseHandlerPlugin;
use Apigee\Edge\HttpClient\Plugin\RetryOauthAuthenticationPlugin;
use Apigee\Edge\HttpClient\Utility\Builder;
use Apigee\Edge\HttpClient\Utility\Journal;
use Apigee\Edge\HttpClient\Utility\JournalInterface;
use Http\Client\Common\Plugin\AddHostPlugin;
use Http\Client\Common\Plugin\AddPathPlugin;
use Http\Client\Common\Plugin\AuthenticationPlugin;
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;
use Http\Client\Common\Plugin\HistoryPlugin;
Expand Down
2 changes: 2 additions & 0 deletions src/HttpClient/Plugin/AddPathPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @see https://github.com/php-http/client-common/blob/2.0.0/src/Plugin/AddPathPlugin.php
* @see https://github.com/php-http/client-common/issues/171
* @see https://github.com/php-http/client-common/issues/141
* @deprecated in 2.0.6, will be removed before 3.0.0. No longer needed.
*/
final class AddPathPlugin implements Plugin
{
Expand All @@ -52,6 +53,7 @@ final class AddPathPlugin implements Plugin
*/
public function __construct(UriInterface $uri)
{
@trigger_error(sprintf('The %s class is deprecated since version 2.0.6 and will be removed in 3.0.0. Use %s instead.', get_class($this), Plugin\AddPathPlugin::class), E_USER_DEPRECATED);
if ('' === $uri->getPath()) {
throw new InvalidArgumentException('URI path cannot be empty');
}
Expand Down
8 changes: 5 additions & 3 deletions src/HttpClient/Plugin/ResponseHandlerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
use Http\Client\Common\Plugin;
use Http\Client\Exception;
use Http\Client\Exception\HttpException;
use Http\Client\Exception\NetworkException;
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,17 +59,17 @@ 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 {
if ($e instanceof ApiException) {
throw $e;
}
if ($e instanceof HttpException || in_array(HttpException::class, class_parents($e))) {
if (is_a($e, HttpException::class)) {
$this->decodeResponse($e->getResponse(), $request);
} elseif ($e instanceof RequestException || in_array(RequestException::class, class_parents($e))) {
} elseif (is_a($e, RequestException::class) || is_a($e, NetworkException::class)) {
throw new ApiRequestException($request, $e->getMessage(), $e->getCode(), $e);
}

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\AbstractOauth;
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(AbstractOauth $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
6 changes: 3 additions & 3 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 @@ -66,9 +66,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
* @param \Psr\Http\Client\ClientExceptionInterface $exception Exception returned by the call
*/
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 0d8e730

Please sign in to comment.