Skip to content

Commit 367546b

Browse files
Switched to PSR-17
1 parent c507737 commit 367546b

File tree

6 files changed

+50
-53
lines changed

6 files changed

+50
-53
lines changed

README.md

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,39 @@ Based on [php-github-api](https://github.com/m4tthumphrey/php-github-api) and co
1212
Installation
1313
------------
1414

15-
Via [Composer](https://getcomposer.org).
15+
Via [Composer](https://getcomposer.org). You will also need to install packages that "provide" [`psr/http-client-implementation`](https://packagist.org/providers/psr/http-client-implementation) and [`psr/http-factory-implementation`](https://packagist.org/providers/psr/http-factory-implementation).
1616

17-
### PHP 7.2+:
17+
### PHP 7.1+:
1818

1919
```bash
20-
composer require m4tthumphrey/php-gitlab-api guzzlehttp/guzzle:^7.0.1
20+
composer require m4tthumphrey/php-gitlab-api:^10.0 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0
2121
```
2222

23-
### PHP 7.1+:
23+
### PHP 7.2+:
2424

2525
```bash
26-
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter:^2.0.1
26+
composer require m4tthumphrey/php-gitlab-api:^10.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
2727
```
2828

29-
### Laravel 5.5+:
29+
### Laravel 6+:
3030

3131
```bash
32-
composer require graham-campbell/gitlab guzzlehttp/guzzle:^7.0.1
32+
composer require graham-campbell/gitlab:^4.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
3333
```
3434

35-
### Symfony 3.4+:
35+
### Symfony 4.4:
3636

3737
```bash
38-
composer require zeichen32/gitlabapibundle guzzlehttp/guzzle:^7.0.1
38+
composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^4.4 nyholm/psr7:^1.3
3939
```
4040

41-
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/gitlab](https://github.com/GrahamCampbell/Laravel-GitLab) is by [Graham Campbell](https://github.com/GrahamCampbell) and [zeichen32/gitlabapibundle](https://github.com/Zeichen32/GitLabApiBundle) is by [Jens Averkamp](https://github.com/Zeichen32).
42-
43-
Versioning
44-
----------
41+
### Symfony 5:
4542

46-
Depending on your Gitlab server version, you must choose the right version of this library.
47-
Please refer to the following table to pick the right one.
43+
```bash
44+
composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^5.0 nyholm/psr7:^1.3
45+
```
4846

49-
|Version|Gitlab API Version|Gitlab Version|
50-
|-------|------------------|--------------|
51-
|9.x | V4 | >= 9.0 |
52-
|8.x | V3 | < 9.5 |
47+
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/gitlab](https://github.com/GrahamCampbell/Laravel-GitLab) is by [Graham Campbell](https://github.com/GrahamCampbell) and [zeichen32/gitlabapibundle](https://github.com/Zeichen32/GitLabApiBundle) is by [Jens Averkamp](https://github.com/Zeichen32).
5348

5449
General API Usage
5550
-----------------
@@ -85,8 +80,6 @@ $issues = $pager->fetchAll($client->api('issues'),'all',[null, ['state' => 'clos
8580

8681
```
8782

88-
89-
9083
Model Usage
9184
-----------
9285

composer.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,24 @@
2323
"require": {
2424
"php": "^7.1",
2525
"ext-xml": "*",
26-
"php-http/client-common": "^2.1",
26+
"php-http/client-common": "^2.2",
2727
"php-http/cache-plugin": "^1.7",
28-
"php-http/discovery": "^1.7",
28+
"php-http/discovery": "^1.9",
2929
"php-http/httplug": "^2.1",
3030
"php-http/multipart-stream-builder": "^1.1",
31+
"psr/http-client-implementation": "^1.0",
32+
"psr/http-factory-implementation": "^1.0",
33+
"psr/http-message": "^1.0",
3134
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0"
3235
},
3336
"require-dev": {
34-
"guzzlehttp/psr7": "^1.2",
35-
"php-http/guzzle6-adapter": "^2.0",
36-
"php-http/mock-client": "^1.2",
37+
"guzzlehttp/psr7": "^1.5.2",
38+
"php-http/guzzle6-adapter": "^2.0.1",
39+
"http-interop/http-factory-guzzle": "^1.0",
3740
"phpunit/phpunit": "^7.5.15",
38-
"phpstan/phpstan": "^0.12.23"
41+
"phpstan/phpstan": "^0.12.32",
42+
"phpstan/extension-installer": "^1.0.4",
43+
"phpstan/phpstan-deprecation-rules": "^0.12.4"
3944
},
4045
"autoload": {
4146
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
@@ -45,7 +50,7 @@
4550
},
4651
"extra": {
4752
"branch-alias": {
48-
"dev-master": "9.17-dev"
53+
"dev-master": "10.0-dev"
4954
}
5055
}
5156
}

lib/Gitlab/Api/AbstractApi.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
use Gitlab\HttpClient\Message\QueryStringBuilder;
55
use Gitlab\HttpClient\Message\ResponseMediator;
66
use Gitlab\Tests\HttpClient\Message\QueryStringBuilderTest;
7-
use Http\Discovery\StreamFactoryDiscovery;
7+
use Http\Discovery\Psr17FactoryDiscovery;
88
use Http\Message\MultipartStream\MultipartStreamBuilder;
9-
use Http\Message\StreamFactory;
109
use Psr\Http\Message\ResponseInterface;
10+
use Psr\Http\Message\StreamFactoryInterface;
1111
use Psr\Http\Message\StreamInterface;
1212
use Symfony\Component\OptionsResolver\OptionsResolver;
1313

@@ -28,18 +28,18 @@ abstract class AbstractApi implements ApiInterface
2828
protected $client;
2929

3030
/**
31-
* @var StreamFactory
31+
* @var StreamFactoryInterface
3232
*/
3333
private $streamFactory;
3434

3535
/**
3636
* @param Client $client
37-
* @param StreamFactory|null $streamFactory
37+
* @param StreamFactoryInterface|null $streamFactory
3838
*/
39-
public function __construct(Client $client, StreamFactory $streamFactory = null)
39+
public function __construct(Client $client, StreamFactoryInterface $streamFactory = null)
4040
{
4141
$this->client = $client;
42-
$this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find();
42+
$this->streamFactory = $streamFactory ?: Psr17FactoryDiscovery::findStreamFactory();
4343
}
4444

4545
/**

lib/Gitlab/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;
1313
use Http\Client\Common\Plugin\HistoryPlugin;
1414
use Http\Client\Common\Plugin\RedirectPlugin;
15-
use Http\Discovery\UriFactoryDiscovery;
15+
use Http\Discovery\Psr17FactoryDiscovery;
1616
use Psr\Http\Client\ClientInterface;
1717

1818
/**
@@ -441,7 +441,7 @@ public function authenticate($token, $authMethod = self::AUTH_URL_TOKEN, $sudo =
441441
public function setUrl($url)
442442
{
443443
$this->httpClientBuilder->removePlugin(AddHostPlugin::class);
444-
$this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url)));
444+
$this->httpClientBuilder->addPlugin(new AddHostPlugin(Psr17FactoryDiscovery::findUrlFactory()->createUri($url)));
445445

446446
return $this;
447447
}

lib/Gitlab/HttpClient/Builder.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
use Http\Client\Common\Plugin;
77
use Http\Client\Common\PluginClient;
88
use Http\Client\Common\PluginClientFactory;
9-
use Http\Discovery\MessageFactoryDiscovery;
9+
use Http\Discovery\Psr17FactoryDiscovery;
1010
use Http\Discovery\Psr18ClientDiscovery;
11-
use Http\Discovery\StreamFactoryDiscovery;
12-
use Http\Message\RequestFactory;
13-
use Http\Message\StreamFactory;
1411
use Psr\Http\Client\ClientInterface;
12+
use Psr\Http\Message\RequestFactoryInterface;
13+
use Psr\Http\Message\StreamFactoryInterface;
1514

1615
/**
1716
* A builder that builds the API client.
@@ -36,12 +35,12 @@ class Builder
3635
private $pluginClient;
3736

3837
/**
39-
* @var RequestFactory
38+
* @var RequestFactoryInterface
4039
*/
4140
private $requestFactory;
4241

4342
/**
44-
* @var StreamFactory
43+
* @var StreamFactoryInterface
4544
*/
4645
private $streamFactory;
4746

@@ -58,18 +57,18 @@ class Builder
5857
private $plugins = [];
5958

6059
/**
61-
* @param ClientInterface $httpClient
62-
* @param RequestFactory $requestFactory
63-
* @param StreamFactory $streamFactory
60+
* @param ClientInterface|null $httpClient
61+
* @param RequestFactoryInterface|null $requestFactory
62+
* @param StreamFactoryInterface|null $streamFactory
6463
*/
6564
public function __construct(
6665
ClientInterface $httpClient = null,
67-
RequestFactory $requestFactory = null,
68-
StreamFactory $streamFactory = null
66+
RequestFactoryInterface $requestFactory = null,
67+
StreamFactoryInterface $streamFactory = null
6968
) {
7069
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
71-
$this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find();
72-
$this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find();
70+
$this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
71+
$this->streamFactory = $streamFactory ?: Psr17FactoryDiscovery::findStreamFactory();
7372
}
7473

7574
/**

test/Gitlab/Tests/HttpClient/BuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use Gitlab\HttpClient\Builder;
66
use Http\Client\Common\HttpMethodsClient;
77
use Http\Client\Common\Plugin;
8-
use Http\Message\RequestFactory;
9-
use Http\Message\StreamFactory;
108
use PHPUnit\Framework\TestCase;
119
use Psr\Http\Client\ClientInterface;
10+
use Psr\Http\Message\RequestFactoryInterface;
11+
use Psr\Http\Message\StreamFactoryInterface;
1212

1313
/**
1414
* @author Fabien Bourigault <[email protected]>
@@ -24,8 +24,8 @@ public function setUp()
2424
{
2525
$this->subject = new Builder(
2626
$this->getMockBuilder(ClientInterface::class)->getMock(),
27-
$this->getMockBuilder(RequestFactory::class)->getMock(),
28-
$this->getMockBuilder(StreamFactory::class)->getMock()
27+
$this->getMockBuilder(RequestFactoryInterface::class)->getMock(),
28+
$this->getMockBuilder(StreamFactoryInterface::class)->getMock()
2929
);
3030
}
3131

0 commit comments

Comments
 (0)