diff --git a/README.md b/README.md index e27a48e..6fea5af 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,16 @@ Feel free to check out the [change log](CHANGELOG.md), [releases](https://github This version requires [PHP](https://php.net) 7.2-7.4. -To get the latest version, simply require the project using [Composer](https://getcomposer.org). You will need to install any package that "provides" `php-http/client-implementation`. Pure PHP users will want something like: +To get the latest version, simply require the project using [Composer](https://getcomposer.org). You will need to install any package that "provides" `psr/http-client-implementation`. Pure PHP users will want something like: ```bash -$ composer require bitbucket/client php-http/guzzle6-adapter:^2.0 +$ composer require bitbucket/client guzzlehttp/guzzle:^7.0.1 ``` Laravel users will want something like: ```bash -$ composer require graham-campbell/bitbucket php-http/guzzle6-adapter:^2.0 +$ composer require graham-campbell/bitbucket guzzlehttp/guzzle:^7.0.1 ``` We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io). You can visit [HTTPlug for library users](https://docs.php-http.org/en/latest/httplug/users.html) to get more information about installing HTTPlug related packages. [`graham-campbell/bitbucket`](https://github.com/GrahamCampbell/Laravel-Bitbucket) is also maintained by [Graham Campbell](https://github.com/GrahamCampbell). diff --git a/composer.json b/composer.json index 1774a4e..c3e3814 100644 --- a/composer.json +++ b/composer.json @@ -11,19 +11,19 @@ ], "require": { "php": "^7.2.5", - "psr/http-message": "^1.0", + "php-http/client-common": "^2.1", + "php-http/cache-plugin": "^1.7", + "php-http/discovery": "^1.7", + "php-http/httplug": "^2.1", + "php-http/multipart-stream-builder": "^1.1", "psr/cache": "^1.0", - "php-http/httplug": "^1.1|^2.0", - "php-http/discovery": "^1.6", - "php-http/cache-plugin": "^1.6", - "php-http/client-implementation": "^1.0", - "php-http/client-common": "^1.9|^2.0", - "php-http/multipart-stream-builder": "^1.0" + "psr/http-client-implementation": "^1.0", + "psr/http-message": "^1.0" }, "require-dev": { "graham-campbell/analyzer": "^2.4", "phpunit/phpunit": "^8.5|^9.0", - "php-http/guzzle6-adapter": "^1.1|^2.0" + "php-http/guzzle6-adapter": "^2.0" }, "autoload": { "psr-4": { diff --git a/src/Api/AbstractApi.php b/src/Api/AbstractApi.php index 10cd938..eba8ff3 100644 --- a/src/Api/AbstractApi.php +++ b/src/Api/AbstractApi.php @@ -15,7 +15,7 @@ use Bitbucket\Exception\InvalidArgumentException; use Bitbucket\HttpClient\Message\ResponseMediator; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract bitbucket api class. @@ -35,7 +35,7 @@ abstract class AbstractApi implements ApiInterface /** * The http methods client. * - * @var \Http\Client\Common\HttpMethodsClient + * @var \Http\Client\Common\HttpMethodsClientInterface */ private $client; @@ -49,11 +49,11 @@ abstract class AbstractApi implements ApiInterface /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client + * @param \Http\Client\Common\HttpMethodsClientInterface $client * * @return void */ - public function __construct(HttpMethodsClient $client) + public function __construct(HttpMethodsClientInterface $client) { $this->client = $client; } @@ -83,7 +83,7 @@ public function setPerPage(int $perPage = null) /** * Get the http methods client. * - * @return \Http\Client\Common\HttpMethodsClient + * @return \Http\Client\Common\HttpMethodsClientInterface */ protected function getHttpClient() { diff --git a/src/Api/Addon/Linkers/AbstractLinkersApi.php b/src/Api/Addon/Linkers/AbstractLinkersApi.php index 20aaf96..5bc367d 100644 --- a/src/Api/Addon/Linkers/AbstractLinkersApi.php +++ b/src/Api/Addon/Linkers/AbstractLinkersApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Addon\Linkers; use Bitbucket\Api\Addon\AbstractAddonApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract linkers api class. @@ -33,10 +33,10 @@ abstract class AbstractLinkersApi extends AbstractAddonApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $linker + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $linker */ - public function __construct(HttpMethodsClient $client, string $linker) + public function __construct(HttpMethodsClientInterface $client, string $linker) { parent::__construct($client); $this->linker = $linker; diff --git a/src/Api/Addon/Users/AbstractUsersApi.php b/src/Api/Addon/Users/AbstractUsersApi.php index 3108f66..f5be9f2 100644 --- a/src/Api/Addon/Users/AbstractUsersApi.php +++ b/src/Api/Addon/Users/AbstractUsersApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Addon\Users; use Bitbucket\Api\Addon\AbstractAddonApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract users api class. @@ -33,10 +33,10 @@ abstract class AbstractUsersApi extends AbstractAddonApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Repositories/AbstractRepositoriesApi.php b/src/Api/Repositories/AbstractRepositoriesApi.php index e18d418..bd4353a 100644 --- a/src/Api/Repositories/AbstractRepositoriesApi.php +++ b/src/Api/Repositories/AbstractRepositoriesApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories; use Bitbucket\Api\AbstractApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract repository api class. @@ -33,10 +33,10 @@ abstract class AbstractRepositoriesApi extends AbstractApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Repositories/Users/AbstractUsersApi.php b/src/Api/Repositories/Users/AbstractUsersApi.php index bde3c18..52d51ad 100644 --- a/src/Api/Repositories/Users/AbstractUsersApi.php +++ b/src/Api/Repositories/Users/AbstractUsersApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users; use Bitbucket\Api\Repositories\AbstractRepositoriesApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract users api class. @@ -33,11 +33,11 @@ abstract class AbstractUsersApi extends AbstractRepositoriesApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo */ - public function __construct(HttpMethodsClient $client, string $username, string $repo) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo) { parent::__construct($client, $username); $this->repo = $repo; diff --git a/src/Api/Repositories/Users/Commit/AbstractCommitApi.php b/src/Api/Repositories/Users/Commit/AbstractCommitApi.php index 53476ef..15bcd80 100644 --- a/src/Api/Repositories/Users/Commit/AbstractCommitApi.php +++ b/src/Api/Repositories/Users/Commit/AbstractCommitApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users\Commit; use Bitbucket\Api\Repositories\Users\AbstractUsersApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract commit api class. @@ -33,12 +33,12 @@ abstract class AbstractCommitApi extends AbstractUsersApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo - * @param string $commit + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo + * @param string $commit */ - public function __construct(HttpMethodsClient $client, string $username, string $repo, string $commit) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo, string $commit) { parent::__construct($client, $username, $repo); $this->commit = $commit; diff --git a/src/Api/Repositories/Users/Issues/AbstractIssuesApi.php b/src/Api/Repositories/Users/Issues/AbstractIssuesApi.php index 5a50b1e..ce5af38 100644 --- a/src/Api/Repositories/Users/Issues/AbstractIssuesApi.php +++ b/src/Api/Repositories/Users/Issues/AbstractIssuesApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users\Issues; use Bitbucket\Api\Repositories\Users\AbstractUsersApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract issues api class. @@ -33,12 +33,12 @@ abstract class AbstractIssuesApi extends AbstractUsersApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo - * @param string $issue + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo + * @param string $issue */ - public function __construct(HttpMethodsClient $client, string $username, string $repo, string $issue) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo, string $issue) { parent::__construct($client, $username, $repo); $this->issue = $issue; diff --git a/src/Api/Repositories/Users/Pipelines/AbstractPipelinesApi.php b/src/Api/Repositories/Users/Pipelines/AbstractPipelinesApi.php index 4cadacd..2ca3c51 100644 --- a/src/Api/Repositories/Users/Pipelines/AbstractPipelinesApi.php +++ b/src/Api/Repositories/Users/Pipelines/AbstractPipelinesApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users\Pipelines; use Bitbucket\Api\Repositories\Users\AbstractUsersApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract pipelines api class. @@ -33,12 +33,12 @@ abstract class AbstractPipelinesApi extends AbstractUsersApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo - * @param string $pipeline + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo + * @param string $pipeline */ - public function __construct(HttpMethodsClient $client, string $username, string $repo, string $pipeline) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo, string $pipeline) { parent::__construct($client, $username, $repo); $this->pipeline = $pipeline; diff --git a/src/Api/Repositories/Users/PipelinesConfig/Schedules/AbstractSchedulesApi.php b/src/Api/Repositories/Users/PipelinesConfig/Schedules/AbstractSchedulesApi.php index b5be34f..b3ae27e 100644 --- a/src/Api/Repositories/Users/PipelinesConfig/Schedules/AbstractSchedulesApi.php +++ b/src/Api/Repositories/Users/PipelinesConfig/Schedules/AbstractSchedulesApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users\PipelinesConfig\Schedules; use Bitbucket\Api\Repositories\Users\PipelinesConfig\AbstractPipelinesConfigApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract schedules api class. @@ -33,12 +33,12 @@ abstract class AbstractSchedulesApi extends AbstractPipelinesConfigApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo - * @param string $schedule + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo + * @param string $schedule */ - public function __construct(HttpMethodsClient $client, string $username, string $repo, string $schedule) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo, string $schedule) { parent::__construct($client, $username, $repo); $this->schedule = $schedule; diff --git a/src/Api/Repositories/Users/PullRequests/AbstractPullRequestsApi.php b/src/Api/Repositories/Users/PullRequests/AbstractPullRequestsApi.php index a20ecdb..122cfe9 100644 --- a/src/Api/Repositories/Users/PullRequests/AbstractPullRequestsApi.php +++ b/src/Api/Repositories/Users/PullRequests/AbstractPullRequestsApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Repositories\Users\PullRequests; use Bitbucket\Api\Repositories\Users\AbstractUsersApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract pull requests api class. @@ -33,12 +33,12 @@ abstract class AbstractPullRequestsApi extends AbstractUsersApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $repo - * @param string $pr + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $repo + * @param string $pr */ - public function __construct(HttpMethodsClient $client, string $username, string $repo, string $pr) + public function __construct(HttpMethodsClientInterface $client, string $username, string $repo, string $pr) { parent::__construct($client, $username, $repo); $this->pr = $pr; diff --git a/src/Api/Snippets/AbstractSnippetsApi.php b/src/Api/Snippets/AbstractSnippetsApi.php index 0fb3d12..7a5bd46 100644 --- a/src/Api/Snippets/AbstractSnippetsApi.php +++ b/src/Api/Snippets/AbstractSnippetsApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Snippets; use Bitbucket\Api\AbstractApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract snippets api class. @@ -33,10 +33,10 @@ abstract class AbstractSnippetsApi extends AbstractApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Snippets/Users/AbstractUsersApi.php b/src/Api/Snippets/Users/AbstractUsersApi.php index b66b813..4409b61 100644 --- a/src/Api/Snippets/Users/AbstractUsersApi.php +++ b/src/Api/Snippets/Users/AbstractUsersApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Snippets\Users; use Bitbucket\Api\Snippets\AbstractSnippetsApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract users api class. @@ -33,11 +33,11 @@ abstract class AbstractUsersApi extends AbstractSnippetsApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username - * @param string $snippet + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username + * @param string $snippet */ - public function __construct(HttpMethodsClient $client, string $username, string $snippet) + public function __construct(HttpMethodsClientInterface $client, string $username, string $snippet) { parent::__construct($client, $username); $this->snippet = $snippet; diff --git a/src/Api/Teams.php b/src/Api/Teams.php index 8fe962f..b28b01f 100644 --- a/src/Api/Teams.php +++ b/src/Api/Teams.php @@ -21,7 +21,7 @@ use Bitbucket\Api\Teams\PipelinesConfig; use Bitbucket\Api\Teams\Projects; use Bitbucket\Api\Teams\Repositories as TeamsRepositories; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The teams api class. @@ -40,10 +40,10 @@ class Teams extends AbstractApi /** * Create a new teams api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Teams/AbstractTeamsApi.php b/src/Api/Teams/AbstractTeamsApi.php index a403a8c..201fbcb 100644 --- a/src/Api/Teams/AbstractTeamsApi.php +++ b/src/Api/Teams/AbstractTeamsApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Teams; use Bitbucket\Api\AbstractApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract team api class. @@ -33,10 +33,10 @@ abstract class AbstractTeamsApi extends AbstractApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Users.php b/src/Api/Users.php index 6727fd2..5c7afe7 100644 --- a/src/Api/Users.php +++ b/src/Api/Users.php @@ -20,7 +20,7 @@ use Bitbucket\Api\Users\Properties; use Bitbucket\Api\Users\Repositories as UsersRepositories; use Bitbucket\Api\Users\SshKeys; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The users api class. @@ -39,10 +39,10 @@ class Users extends AbstractApi /** * Create a new users api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Api/Users/AbstractUsersApi.php b/src/Api/Users/AbstractUsersApi.php index 78bf84a..15e77a1 100644 --- a/src/Api/Users/AbstractUsersApi.php +++ b/src/Api/Users/AbstractUsersApi.php @@ -14,7 +14,7 @@ namespace Bitbucket\Api\Users; use Bitbucket\Api\AbstractApi; -use Http\Client\Common\HttpMethodsClient; +use Http\Client\Common\HttpMethodsClientInterface; /** * The abstract user api class. @@ -33,10 +33,10 @@ abstract class AbstractUsersApi extends AbstractApi /** * Create a new api instance. * - * @param \Http\Client\Common\HttpMethodsClient $client - * @param string $username + * @param \Http\Client\Common\HttpMethodsClientInterface $client + * @param string $username */ - public function __construct(HttpMethodsClient $client, string $username) + public function __construct(HttpMethodsClientInterface $client, string $username) { parent::__construct($client); $this->username = $username; diff --git a/src/Client.php b/src/Client.php index 8072454..9df05b9 100644 --- a/src/Client.php +++ b/src/Client.php @@ -200,7 +200,7 @@ public function getLastResponse() /** * Get the http client. * - * @return \Http\Client\Common\HttpMethodsClient + * @return \Http\Client\Common\HttpMethodsClientInterface */ public function getHttpClient() { diff --git a/src/HttpClient/Builder.php b/src/HttpClient/Builder.php index edb287b..2242603 100644 --- a/src/HttpClient/Builder.php +++ b/src/HttpClient/Builder.php @@ -19,13 +19,13 @@ use Http\Client\Common\Plugin\Cache\Generator\HeaderCacheKeyGenerator; use Http\Client\Common\Plugin\CachePlugin; use Http\Client\Common\PluginClientFactory; -use Http\Client\HttpClient; -use Http\Discovery\HttpClientDiscovery; use Http\Discovery\MessageFactoryDiscovery; +use Http\Discovery\Psr18ClientDiscovery; use Http\Discovery\StreamFactoryDiscovery; use Http\Message\RequestFactory; use Http\Message\StreamFactory; use Psr\Cache\CacheItemPoolInterface; +use Psr\Http\Client\ClientInterface; /** * The Bitbucket HTTP client builder class. @@ -45,21 +45,21 @@ final class Builder /** * The object that sends HTTP messages. * - * @var \Http\Client\HttpClient + * @var \Psr\Http\Client\ClientInterface */ private $httpClient; /** * A HTTP client with all our plugins. * - * @var \Http\Client\Common\HttpMethodsClient + * @var \Http\Client\Common\HttpMethodsClientInterface */ private $pluginClient; /** * The HTTP request factory. * - * @var \Http\Message\MessageFactory + * @var \Http\Message\RequestFactory */ private $requestFactory; @@ -96,22 +96,22 @@ final class Builder /** * Create a new http client builder instance. * - * @param \Http\Client\HttpClient|null $httpClient - * @param \Http\Message\RequestFactory|null $requestFactory - * @param \Http\Message\StreamFactory|null $streamFactory + * @param \Psr\Http\Client\ClientInterface|null $httpClient + * @param \Http\Message\RequestFactory|null $requestFactory + * @param \Http\Message\StreamFactory|null $streamFactory */ public function __construct( - HttpClient $httpClient = null, + ClientInterface $httpClient = null, RequestFactory $requestFactory = null, StreamFactory $streamFactory = null ) { - $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); + $this->httpClient = $httpClient ?: Psr18ClientDiscovery::find(); $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); } /** - * @return \Http\Client\Common\HttpMethodsClient + * @return \Http\Client\Common\HttpMethodsClientInterface */ public function getHttpClient() { diff --git a/src/HttpClient/Plugin/Authentication.php b/src/HttpClient/Plugin/Authentication.php index f0684fd..96178c4 100644 --- a/src/HttpClient/Plugin/Authentication.php +++ b/src/HttpClient/Plugin/Authentication.php @@ -16,6 +16,7 @@ use Bitbucket\Client; use Bitbucket\Exception\RuntimeException; use Http\Client\Common\Plugin; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; /** @@ -26,8 +27,6 @@ */ class Authentication implements Plugin { - use Plugin\VersionBridgePlugin; - /** * The authorization header. * @@ -58,7 +57,7 @@ public function __construct(string $method, string $token, string $password = nu * * @return \Http\Promise\Promise */ - public function doHandleRequest(RequestInterface $request, callable $next, callable $first) + public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { $request = $request->withHeader('Authorization', $this->header); diff --git a/src/HttpClient/Plugin/ExceptionThrower.php b/src/HttpClient/Plugin/ExceptionThrower.php index 267d8aa..e545a65 100644 --- a/src/HttpClient/Plugin/ExceptionThrower.php +++ b/src/HttpClient/Plugin/ExceptionThrower.php @@ -21,6 +21,7 @@ use Bitbucket\Exception\ValidationFailedException; use Bitbucket\HttpClient\Message\ResponseMediator; use Http\Client\Common\Plugin; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -33,8 +34,6 @@ */ class ExceptionThrower implements Plugin { - use Plugin\VersionBridgePlugin; - /** * Handle the request and return the response coming from the next callable. * @@ -44,7 +43,7 @@ class ExceptionThrower implements Plugin * * @return \Http\Promise\Promise */ - public function doHandleRequest(RequestInterface $request, callable $next, callable $first) + public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { return $next($request)->then(function (ResponseInterface $response) { $status = $response->getStatusCode(); diff --git a/src/HttpClient/Plugin/History.php b/src/HttpClient/Plugin/History.php index 1e1ce18..3a0cad2 100644 --- a/src/HttpClient/Plugin/History.php +++ b/src/HttpClient/Plugin/History.php @@ -14,6 +14,7 @@ namespace Bitbucket\HttpClient\Plugin; use Http\Client\Common\Plugin\Journal; +use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -25,8 +26,6 @@ */ class History implements Journal { - use HistoryTrait; - /** * The last response. * @@ -56,4 +55,8 @@ public function addSuccess(RequestInterface $request, ResponseInterface $respons { $this->lastResponse = $response; } + + public function addFailure(RequestInterface $request, ClientExceptionInterface $exception) + { + } } diff --git a/src/HttpClient/Plugin/HistoryTrait.php b/src/HttpClient/Plugin/HistoryTrait.php deleted file mode 100644 index e3f249e..0000000 --- a/src/HttpClient/Plugin/HistoryTrait.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Bitbucket\HttpClient\Plugin; - -use Http\Client\Common\HttpMethodsClientInterface; -use Http\Client\Exception; -use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; - -if (interface_exists(HttpMethodsClientInterface::class)) { - trait HistoryTrait - { - public function addFailure(RequestInterface $request, ClientExceptionInterface $exception) - { - } - } -} else { - trait HistoryTrait - { - public function addFailure(RequestInterface $request, Exception $exception) - { - } - } -} diff --git a/tests/AnalysisTest.php b/tests/AnalysisTest.php index 440ca4c..03b34f3 100644 --- a/tests/AnalysisTest.php +++ b/tests/AnalysisTest.php @@ -14,9 +14,7 @@ namespace Bitbucket\Tests; use GrahamCampbell\Analyzer\AnalysisTrait; -use Http\Client\Common\HttpMethodsClientInterface; use PHPUnit\Framework\TestCase; -use Psr\Http\Client\ClientExceptionInterface; /** * This is the analysis test class. @@ -39,14 +37,4 @@ protected function getPaths() realpath(__DIR__), ]; } - - /** - * Get the classes to ignore not existing. - * - * @return string[] - */ - protected function getIgnored() - { - return [ClientExceptionInterface::class, HttpMethodsClientInterface::class]; - } }