Skip to content

Commit f4488f8

Browse files
Removed deprecated code (#53)
1 parent 26b74a4 commit f4488f8

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ This version requires [PHP](https://php.net) 7.2-7.4.
2828
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:
2929

3030
```bash
31-
$ composer require bitbucket/client guzzlehttp/guzzle:^7.0.1
31+
$ composer require bitbucket/client:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
3232
```
3333

3434
Laravel users will want something like:
3535

3636
```bash
37-
$ composer require graham-campbell/bitbucket guzzlehttp/guzzle:^7.0.1
37+
$ composer require graham-campbell/bitbucket:^7.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
3838
```
3939

4040
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).

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
],
1212
"require": {
1313
"php": "^7.2.5",
14-
"php-http/client-common": "^2.1",
14+
"php-http/client-common": "^2.2",
1515
"php-http/cache-plugin": "^1.7",
16-
"php-http/discovery": "^1.7",
16+
"php-http/discovery": "^1.9",
1717
"php-http/httplug": "^2.1",
1818
"php-http/multipart-stream-builder": "^1.1",
1919
"psr/cache": "^1.0",
@@ -24,9 +24,10 @@
2424
"require-dev": {
2525
"bamarni/composer-bin-plugin": "^1.4.1",
2626
"graham-campbell/analyzer": "^3.0",
27-
"phpunit/phpunit": "^8.5|^9.0",
28-
"php-http/guzzle6-adapter": "^2.0",
29-
"php-http/mock-client": "^1.3"
27+
"guzzlehttp/guzzle": "^7.0.1",
28+
"http-interop/http-factory-guzzle": "^1.0",
29+
"php-http/mock-client": "^1.4",
30+
"phpunit/phpunit": "^8.5|^9.0"
3031
},
3132
"autoload": {
3233
"psr-4": {

src/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;
3030
use Http\Client\Common\Plugin\HistoryPlugin;
3131
use Http\Client\Common\Plugin\RedirectPlugin;
32-
use Http\Discovery\UriFactoryDiscovery;
32+
use Http\Discovery\Psr17FactoryDiscovery;
3333

3434
/**
3535
* The Bitbucket API 2.0 client.
@@ -191,7 +191,7 @@ public function authenticate(string $method, string $token, string $password = n
191191
public function setUrl(string $url)
192192
{
193193
$this->httpClientBuilder->removePlugin(AddHostPlugin::class);
194-
$this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url)));
194+
$this->httpClientBuilder->addPlugin(new AddHostPlugin(Psr17FactoryDiscovery::findUrlFactory()->createUri($url)));
195195
}
196196

197197
/**

src/HttpClient/Builder.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
use Http\Client\Common\Plugin\Cache\Generator\HeaderCacheKeyGenerator;
2020
use Http\Client\Common\Plugin\CachePlugin;
2121
use Http\Client\Common\PluginClientFactory;
22-
use Http\Discovery\MessageFactoryDiscovery;
22+
use Http\Discovery\Psr17FactoryDiscovery;
2323
use Http\Discovery\Psr18ClientDiscovery;
24-
use Http\Discovery\StreamFactoryDiscovery;
25-
use Http\Message\RequestFactory;
26-
use Http\Message\StreamFactory;
2724
use Psr\Cache\CacheItemPoolInterface;
2825
use Psr\Http\Client\ClientInterface;
26+
use Psr\Http\Message\RequestFactoryInterface;
27+
use Psr\Http\Message\StreamFactoryInterface;
2928

3029
/**
3130
* The Bitbucket HTTP client builder class.
@@ -59,14 +58,14 @@ final class Builder
5958
/**
6059
* The HTTP request factory.
6160
*
62-
* @var \Http\Message\RequestFactory
61+
* @var \Psr\Http\Message\RequestFactoryInterface
6362
*/
6463
private $requestFactory;
6564

6665
/**
6766
* The HTTP stream factory.
6867
*
69-
* @var \Http\Message\StreamFactory
68+
* @var \Psr\Http\Message\StreamFactoryInterface
7069
*/
7170
private $streamFactory;
7271

@@ -96,18 +95,18 @@ final class Builder
9695
/**
9796
* Create a new http client builder instance.
9897
*
99-
* @param \Psr\Http\Client\ClientInterface|null $httpClient
100-
* @param \Http\Message\RequestFactory|null $requestFactory
101-
* @param \Http\Message\StreamFactory|null $streamFactory
98+
* @param \Psr\Http\Client\ClientInterface|null $httpClient
99+
* @param \Psr\Http\Message\RequestFactoryInterface|null $requestFactory
100+
* @param \Psr\Http\Message\StreamFactoryInterface|null $streamFactory
102101
*/
103102
public function __construct(
104103
ClientInterface $httpClient = null,
105-
RequestFactory $requestFactory = null,
106-
StreamFactory $streamFactory = null
104+
RequestFactoryInterface $requestFactory = null,
105+
StreamFactoryInterface $streamFactory = null
107106
) {
108107
$this->httpClient = $httpClient ?? Psr18ClientDiscovery::find();
109-
$this->requestFactory = $requestFactory ?? MessageFactoryDiscovery::find();
110-
$this->streamFactory = $streamFactory ?? StreamFactoryDiscovery::find();
108+
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
109+
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
111110
}
112111

113112
/**

tests/MockedClient.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
use Bitbucket\Client;
1717
use Bitbucket\HttpClient\Builder;
18-
use Http\Message\ResponseFactory;
1918
use Http\Mock\Client as MockClient;
19+
use Psr\Http\Message\ResponseFactoryInterface;
2020
use Psr\Http\Message\ResponseInterface;
2121

2222
/**
@@ -42,25 +42,20 @@ public static function create(ResponseInterface $response)
4242
/**
4343
* @param \Psr\Http\Message\ResponseInterface $response
4444
*
45-
* @return \Http\Message\ResponseFactory
45+
* @return \Psr\Http\Message\ResponseFactoryInterface
4646
*/
4747
private static function createResponseFactory(ResponseInterface $response)
4848
{
49-
return new class($response) implements ResponseFactory {
49+
return new class($response) implements ResponseFactoryInterface {
5050
private $response;
5151

5252
public function __construct(ResponseInterface $response)
5353
{
5454
$this->response = $response;
5555
}
5656

57-
public function createResponse(
58-
$statusCode = 200,
59-
$reasonPhrase = null,
60-
array $headers = [],
61-
$body = null,
62-
$protocolVersion = '1.1'
63-
) {
57+
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
58+
{
6459
return $this->response;
6560
}
6661
};

vendor-bin/phpstan/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"require": {
3-
"phpstan/phpstan": "^0.12.31",
3+
"phpstan/phpstan": "^0.12.32",
44
"phpstan/extension-installer": "^1.0.4",
5+
"phpstan/phpstan-deprecation-rules": "^0.12.4",
56
"phpstan/phpstan-strict-rules": "^0.12.2",
67
"thecodingmachine/phpstan-strict-rules": "^0.12.0"
78
},

0 commit comments

Comments
 (0)