Skip to content

Commit 4fbdb97

Browse files
Merge pull request #511 from GrahamCampbell/psr18
Switch to PSR-17 and PSR-18
2 parents 3050e6d + 433f0d8 commit 4fbdb97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+421
-326
lines changed

.styleci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
preset: psr2
1+
preset: psr12
2+
3+
enabled:
4+
- phpdoc_indent
5+
- phpdoc_scalar
6+
7+
disabled:
8+
- blank_line_after_opening_tag
9+
- concat_with_spaces

.travis.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
language: php
22

3+
dist: bionic
4+
35
php:
4-
- 5.6
5-
- 7.0
66
- 7.1
77
- 7.2
88
- 7.3
99
- 7.4
1010

1111
matrix:
12-
# test latest PHP stable version with lowest dependencies and phpstan static analysis
1312
include:
14-
- php: 7.3
15-
env: STATIC_ANALYSIS=yes
13+
- php: 7.4
14+
name: phpstan
15+
script:
16+
- vendor/bin/phpstan analyse --no-progress
1617

17-
before_script:
18-
- travis_retry composer self-update
18+
install:
1919
- travis_retry composer update --no-interaction ${COMPOSER_FLAGS}
20-
- if [ "$STATIC_ANALYSIS" != "" ]; then curl -L https://github.com/phpstan/phpstan/releases/download/0.8/phpstan.phar -o phpstan.phar; fi;
2120

2221
script:
2322
- vendor/bin/phpunit --verbose --coverage-text
24-
- if [ "$STATIC_ANALYSIS" != "" ]; then php phpstan.phar analyse --level=4 lib; fi;

README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +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).
16+
17+
### PHP 7.1+:
1618

1719
```bash
18-
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter:^1.0
20+
composer require m4tthumphrey/php-gitlab-api:^10.0 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0
1921
```
2022

21-
Why `php-http/guzzle6-adapter`? We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io).
23+
### PHP 7.2+:
2224

23-
You can visit [HTTPlug for library users](http://docs.php-http.org/en/latest/httplug/users.html) to get more information about installing HTTPlug related packages.
25+
```bash
26+
composer require m4tthumphrey/php-gitlab-api:^10.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
27+
```
2428

25-
Versioning
26-
----------
29+
### Laravel 6+:
2730

28-
Depending on your Gitlab server version, you must choose the right version of this library.
29-
Please refer to the following table to pick the right one.
31+
```bash
32+
composer require graham-campbell/gitlab:^4.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
33+
```
34+
35+
### Symfony 4.4:
36+
37+
```bash
38+
composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^4.4 nyholm/psr7:^1.3
39+
```
3040

31-
|Version|Gitlab API Version|Gitlab Version|
32-
|-------|------------------|--------------|
33-
|9.x | V4 | >= 9.0 |
34-
|8.x | V3 | < 9.5 |
41+
### Symfony 5:
42+
43+
```bash
44+
composer require zeichen32/gitlabapibundle:^5.0 symfony/http-client:^5.0 nyholm/psr7:^1.3
45+
```
46+
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).
3548

3649
General API Usage
3750
-----------------
@@ -67,8 +80,6 @@ $issues = $pager->fetchAll($client->api('issues'),'all',[null, ['state' => 'clos
6780

6881
```
6982

70-
71-
7283
Model Usage
7384
-----------
7485

@@ -98,18 +109,9 @@ $issue = $project->createIssue('This does not work.', array(
98109
$issue->close();
99110
```
100111

101-
You get the idea! Take a look around ([API methods](https://github.com/m4tthumphrey/php-gitlab-api/tree/master/lib/Gitlab/Api),
102-
[models](https://github.com/m4tthumphrey/php-gitlab-api/tree/master/lib/Gitlab/Model)) and please feel free to report any bugs.
103-
104-
Framework Integrations
105-
----------------------
106-
- **Symfony** - https://github.com/Zeichen32/GitLabApiBundle
107-
- **Laravel** - https://github.com/GrahamCampbell/Laravel-GitLab
108-
109-
If you have integrated GitLab into a popular PHP framework, let us know!
112+
You get the idea! Take a look around ([API methods](https://github.com/m4tthumphrey/php-gitlab-api/tree/master/lib/Gitlab/Api), [models](https://github.com/m4tthumphrey/php-gitlab-api/tree/master/lib/Gitlab/Model)) and please feel free to report any bugs. If you have integrated GitLab into a popular PHP framework, let us know!
110113

111114
Contributing
112115
------------
113116

114-
There are many parts of Gitlab that I have not added to this as it was originally created for personal use, hence the
115-
lack of tests. Feel free to fork and add new functionality and tests, I'll gladly accept decent pull requests.
117+
There are many parts of Gitlab that I have not added to this as it was originally created for personal use, hence the lack of tests. Feel free to fork and add new functionality and tests, I'll gladly accept decent pull requests.

composer.json

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,57 @@
11
{
2-
"name": "m4tthumphrey/php-gitlab-api",
3-
"type": "library",
4-
"description": "GitLab API client",
5-
"homepage": "https://github.com/m4tthumphrey/php-gitlab-api",
6-
"keywords": ["gitlab", "api"],
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Matt Humphrey",
11-
"homepage": "http://m4tt.io"
12-
},
13-
{
14-
"name": "KnpLabs Team",
15-
"homepage": "http://knplabs.com"
16-
},
17-
{
18-
"name": "Thibault Duplessis",
19-
"email": "thibault.duplessis@gmail.com",
20-
"homepage": "http://ornicar.github.com"
21-
}
22-
],
23-
"require": {
24-
"php": "^5.6 || ^7.0",
25-
"ext-xml": "*",
26-
"php-http/client-common": "^1.6 || ^2.0",
27-
"php-http/client-implementation": "^1.0",
28-
"php-http/discovery": "^1.2",
29-
"php-http/httplug": "^1.1 || ^2.0",
30-
"php-http/multipart-stream-builder": "^1.0",
31-
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0 || ^5.0"
32-
},
33-
"require-dev": {
34-
"guzzlehttp/psr7": "^1.2",
35-
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
36-
"php-http/mock-client": "^1.2",
37-
"phpunit/phpunit": "^5.7.27 || ^7.5.15"
38-
},
39-
"autoload": {
40-
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
41-
},
42-
"autoload-dev": {
43-
"psr-4": { "Gitlab\\Tests\\": "test/Gitlab/Tests/" }
44-
},
45-
"extra": {
46-
"branch-alias": {
47-
"dev-master": "9.17-dev"
48-
}
49-
}
2+
"name": "m4tthumphrey/php-gitlab-api",
3+
"type": "library",
4+
"description": "GitLab API client",
5+
"homepage": "https://github.com/m4tthumphrey/php-gitlab-api",
6+
"keywords": ["gitlab", "api"],
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Matt Humphrey",
11+
"homepage": "http://m4tt.io"
12+
},
13+
{
14+
"name": "KnpLabs Team",
15+
"homepage": "http://knplabs.com"
16+
},
17+
{
18+
"name": "Thibault Duplessis",
19+
"email": "thibault.duplessis@gmail.com",
20+
"homepage": "http://ornicar.github.com"
21+
}
22+
],
23+
"require": {
24+
"php": "^7.1",
25+
"ext-xml": "*",
26+
"php-http/client-common": "^2.2",
27+
"php-http/cache-plugin": "^1.7",
28+
"php-http/discovery": "^1.9",
29+
"php-http/httplug": "^2.1",
30+
"php-http/multipart-stream-builder": "^1.1",
31+
"psr/cache": "^1.0",
32+
"psr/http-client-implementation": "^1.0",
33+
"psr/http-factory-implementation": "^1.0",
34+
"psr/http-message": "^1.0",
35+
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0"
36+
},
37+
"require-dev": {
38+
"guzzlehttp/psr7": "^1.5.2",
39+
"php-http/guzzle6-adapter": "^2.0.1",
40+
"http-interop/http-factory-guzzle": "^1.0",
41+
"phpstan/phpstan": "^0.12.32",
42+
"phpstan/extension-installer": "^1.0.4",
43+
"phpstan/phpstan-deprecation-rules": "^0.12.4",
44+
"phpunit/phpunit": "^7.5.15"
45+
},
46+
"autoload": {
47+
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
48+
},
49+
"autoload-dev": {
50+
"psr-4": { "Gitlab\\Tests\\": "test/Gitlab/Tests/" }
51+
},
52+
"extra": {
53+
"branch-alias": {
54+
"dev-master": "10.0-dev"
55+
}
56+
}
5057
}

lib/Gitlab/Api/AbstractApi.php

Lines changed: 7 additions & 7 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
/**
@@ -248,7 +248,7 @@ private function preparePath($path, array $parameters = [])
248248
}
249249

250250
/**
251-
* @param $file
251+
* @param string $file
252252
*
253253
* @return string
254254
*/

lib/Gitlab/Api/Groups.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public function transfer($group_id, $project_id)
9090
}
9191

9292
/**
93-
* @param integer $id
94-
* @param integer|null $user_id
93+
* @param int $id
94+
* @param int|null $user_id
9595
* @param array $parameters
9696
* @return mixed
9797
*/
@@ -158,7 +158,7 @@ public function removeMember($group_id, $user_id)
158158
}
159159

160160
/**
161-
* @param $id
161+
* @param int $id
162162
* @param array $parameters (
163163
*
164164
* @var bool $archived Limit by archived status.

lib/Gitlab/Api/Issues.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ public function awardEmoji($project_id, $issue_iid)
301301
}
302302

303303
/**
304-
* @param int $project_id
305-
* @param int $issue_iid
306-
* @return mixed
307-
*/
304+
* @param int $project_id
305+
* @param int $issue_iid
306+
* @return mixed
307+
*/
308308
public function closedByMergeRequests($project_id, $issue_iid)
309309
{
310310
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/closed_by');
@@ -319,7 +319,7 @@ public function showParticipants($project_id, $issue_iid)
319319
{
320320
return $this->get($this->getProjectPath($project_id, 'issues/' .$this->encodePath($issue_iid)).'/participants');
321321
}
322-
322+
323323
/**
324324
* {@inheritDoc}
325325
*/

lib/Gitlab/Api/MergeRequests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function update($project_id, $mr_id, array $params)
158158
/**
159159
* @param int $project_id
160160
* @param int $mr_id
161-
* @param string $message
161+
* @param string|array $message
162162
* @return mixed
163163
*/
164164
public function merge($project_id, $mr_id, $message = null)

lib/Gitlab/Api/ProjectNamespaces.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function all(array $parameters = [])
1919
}
2020

2121
/**
22-
* @param integer|string $namespace_id
22+
* @param int|string $namespace_id
2323
* @return mixed
2424
*/
2525
public function show($namespace_id)

0 commit comments

Comments
 (0)