diff --git a/README.md b/README.md index f09edb5..30cbced 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,13 @@ 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" `psr/http-client-implementation`. Pure PHP users will want something like: ```bash -$ composer require bitbucket/client guzzlehttp/guzzle:^7.0.1 +$ composer require bitbucket/client:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 ``` Laravel users will want something like: ```bash -$ composer require graham-campbell/bitbucket guzzlehttp/guzzle:^7.0.1 +$ composer require graham-campbell/bitbucket:^7.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 ``` 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 70eb543..9e2e435 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ ], "require": { "php": "^7.2.5", - "php-http/client-common": "^2.1", + "php-http/client-common": "^2.2", "php-http/cache-plugin": "^1.7", - "php-http/discovery": "^1.7", + "php-http/discovery": "^1.9", "php-http/httplug": "^2.1", "php-http/multipart-stream-builder": "^1.1", "psr/cache": "^1.0", @@ -24,9 +24,10 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.4.1", "graham-campbell/analyzer": "^3.0", - "phpunit/phpunit": "^8.5|^9.0", - "php-http/guzzle6-adapter": "^2.0", - "php-http/mock-client": "^1.3" + "guzzlehttp/guzzle": "^7.0.1", + "http-interop/http-factory-guzzle": "^1.0", + "php-http/mock-client": "^1.4", + "phpunit/phpunit": "^8.5|^9.0" }, "autoload": { "psr-4": { diff --git a/src/Client.php b/src/Client.php index 60886e0..1e48d75 100644 --- a/src/Client.php +++ b/src/Client.php @@ -29,7 +29,7 @@ use Http\Client\Common\Plugin\HeaderDefaultsPlugin; use Http\Client\Common\Plugin\HistoryPlugin; use Http\Client\Common\Plugin\RedirectPlugin; -use Http\Discovery\UriFactoryDiscovery; +use Http\Discovery\Psr17FactoryDiscovery; /** * The Bitbucket API 2.0 client. @@ -191,7 +191,7 @@ public function authenticate(string $method, string $token, string $password = n public function setUrl(string $url) { $this->httpClientBuilder->removePlugin(AddHostPlugin::class); - $this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url))); + $this->httpClientBuilder->addPlugin(new AddHostPlugin(Psr17FactoryDiscovery::findUrlFactory()->createUri($url))); } /** diff --git a/src/HttpClient/Builder.php b/src/HttpClient/Builder.php index 5955573..e9b654f 100644 --- a/src/HttpClient/Builder.php +++ b/src/HttpClient/Builder.php @@ -19,13 +19,12 @@ use Http\Client\Common\Plugin\Cache\Generator\HeaderCacheKeyGenerator; use Http\Client\Common\Plugin\CachePlugin; use Http\Client\Common\PluginClientFactory; -use Http\Discovery\MessageFactoryDiscovery; +use Http\Discovery\Psr17FactoryDiscovery; 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; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; /** * The Bitbucket HTTP client builder class. @@ -59,14 +58,14 @@ final class Builder /** * The HTTP request factory. * - * @var \Http\Message\RequestFactory + * @var \Psr\Http\Message\RequestFactoryInterface */ private $requestFactory; /** * The HTTP stream factory. * - * @var \Http\Message\StreamFactory + * @var \Psr\Http\Message\StreamFactoryInterface */ private $streamFactory; @@ -96,18 +95,18 @@ final class Builder /** * Create a new http client builder instance. * - * @param \Psr\Http\Client\ClientInterface|null $httpClient - * @param \Http\Message\RequestFactory|null $requestFactory - * @param \Http\Message\StreamFactory|null $streamFactory + * @param \Psr\Http\Client\ClientInterface|null $httpClient + * @param \Psr\Http\Message\RequestFactoryInterface|null $requestFactory + * @param \Psr\Http\Message\StreamFactoryInterface|null $streamFactory */ public function __construct( ClientInterface $httpClient = null, - RequestFactory $requestFactory = null, - StreamFactory $streamFactory = null + RequestFactoryInterface $requestFactory = null, + StreamFactoryInterface $streamFactory = null ) { $this->httpClient = $httpClient ?? Psr18ClientDiscovery::find(); - $this->requestFactory = $requestFactory ?? MessageFactoryDiscovery::find(); - $this->streamFactory = $streamFactory ?? StreamFactoryDiscovery::find(); + $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); + $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); } /** diff --git a/tests/MockedClient.php b/tests/MockedClient.php index 0c292e5..9db1cd7 100644 --- a/tests/MockedClient.php +++ b/tests/MockedClient.php @@ -15,8 +15,8 @@ use Bitbucket\Client; use Bitbucket\HttpClient\Builder; -use Http\Message\ResponseFactory; use Http\Mock\Client as MockClient; +use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; /** @@ -42,11 +42,11 @@ public static function create(ResponseInterface $response) /** * @param \Psr\Http\Message\ResponseInterface $response * - * @return \Http\Message\ResponseFactory + * @return \Psr\Http\Message\ResponseFactoryInterface */ private static function createResponseFactory(ResponseInterface $response) { - return new class($response) implements ResponseFactory { + return new class($response) implements ResponseFactoryInterface { private $response; public function __construct(ResponseInterface $response) @@ -54,13 +54,8 @@ public function __construct(ResponseInterface $response) $this->response = $response; } - public function createResponse( - $statusCode = 200, - $reasonPhrase = null, - array $headers = [], - $body = null, - $protocolVersion = '1.1' - ) { + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { return $this->response; } }; diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index 216707a..1753dad 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,7 +1,8 @@ { "require": { - "phpstan/phpstan": "^0.12.31", + "phpstan/phpstan": "^0.12.32", "phpstan/extension-installer": "^1.0.4", + "phpstan/phpstan-deprecation-rules": "^0.12.4", "phpstan/phpstan-strict-rules": "^0.12.2", "thecodingmachine/phpstan-strict-rules": "^0.12.0" },