Skip to content

Commit c507737

Browse files
Switch to PSR18 client impl
1 parent 3050e6d commit c507737

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

+318
-277
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: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,33 @@ 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).
16+
17+
### PHP 7.2+:
18+
19+
```bash
20+
composer require m4tthumphrey/php-gitlab-api guzzlehttp/guzzle:^7.0.1
21+
```
22+
23+
### PHP 7.1+:
24+
25+
```bash
26+
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter:^2.0.1
27+
```
28+
29+
### Laravel 5.5+:
1630

1731
```bash
18-
composer require m4tthumphrey/php-gitlab-api php-http/guzzle6-adapter:^1.0
32+
composer require graham-campbell/gitlab guzzlehttp/guzzle:^7.0.1
1933
```
2034

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

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.
37+
```bash
38+
composer require zeichen32/gitlabapibundle guzzlehttp/guzzle:^7.0.1
39+
```
40+
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).
2442

2543
Versioning
2644
----------
@@ -98,18 +116,9 @@ $issue = $project->createIssue('This does not work.', array(
98116
$issue->close();
99117
```
100118

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!
119+
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!
110120

111121
Contributing
112122
------------
113123

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.
124+
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: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
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.1",
27+
"php-http/cache-plugin": "^1.7",
28+
"php-http/discovery": "^1.7",
29+
"php-http/httplug": "^2.1",
30+
"php-http/multipart-stream-builder": "^1.1",
31+
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0"
32+
},
33+
"require-dev": {
34+
"guzzlehttp/psr7": "^1.2",
35+
"php-http/guzzle6-adapter": "^2.0",
36+
"php-http/mock-client": "^1.2",
37+
"phpunit/phpunit": "^7.5.15",
38+
"phpstan/phpstan": "^0.12.23"
39+
},
40+
"autoload": {
41+
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
42+
},
43+
"autoload-dev": {
44+
"psr-4": { "Gitlab\\Tests\\": "test/Gitlab/Tests/" }
45+
},
46+
"extra": {
47+
"branch-alias": {
48+
"dev-master": "9.17-dev"
49+
}
50+
}
5051
}

lib/Gitlab/Api/AbstractApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)

lib/Gitlab/Api/Projects.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,10 @@ public function cancelPipeline($project_id, $pipeline_id)
287287
{
288288
return $this->post($this->getProjectPath($project_id, 'pipelines/'.$this->encodePath($pipeline_id)).'/cancel');
289289
}
290-
290+
291291
/**
292-
* @param $project_id
293-
* @param $pipeline_id
292+
* @param int $project_id
293+
* @param int $pipeline_id
294294
* @return mixed
295295
*/
296296
public function deletePipeline($project_id, $pipeline_id)
@@ -299,8 +299,8 @@ public function deletePipeline($project_id, $pipeline_id)
299299
}
300300

301301
/**
302-
* @param integer $project_id
303-
* @param integer|null $user_id
302+
* @param int $project_id
303+
* @param int|null $user_id
304304
* @param array $parameters
305305
* @return mixed
306306
*/
@@ -315,11 +315,10 @@ public function allMembers($project_id, $user_id = null, $parameters = [])
315315
/**
316316
* @param int $project_id
317317
* @param array $parameters (
318-
*
319318
* @var string $query The query you want to search members for.
320319
* )
321320
*
322-
* @throws MissingOptionsException If a required option is not provided
321+
* @throws \Symfony\Component\OptionsResolver\Exception\MissingOptionsException If a required option is not provided
323322
*
324323
* @return mixed
325324
*/
@@ -664,32 +663,31 @@ public function languages($project_id)
664663

665664
/**
666665
* @param int $project_id
667-
* @param array $parameters
666+
* @param array $params
668667
* @return mixed
669668
*/
670-
public function forks($project_id, array $parameters = [])
669+
public function forks($project_id, array $params = [])
671670
{
672671
$resolver = $this->createOptionsResolver();
673672

674-
return $this->get($this->getProjectPath($project_id, 'forks'), $resolver->resolve($parameters));
673+
return $this->get($this->getProjectPath($project_id, 'forks'), $resolver->resolve($params));
675674
}
676675

677676
/**
678677
* @param int $project_id
679678
* @param array $params (
680-
*
681679
* @var string $namespace The ID or path of the namespace that the project will be forked to
682680
* @var string $path The path of the forked project (optional)
683681
* @var string $name The name of the forked project (optional)
684682
* )
685683
* @return mixed
686684
*/
687-
public function fork($project_id, array $parameters = [])
685+
public function fork($project_id, array $params = [])
688686
{
689687
$resolver = new OptionsResolver();
690688
$resolver->setDefined(['namespace', 'path', 'name']);
691689

692-
$resolved = $resolver->resolve($parameters);
690+
$resolved = $resolver->resolve($params);
693691

694692
return $this->post($this->getProjectPath($project_id, 'fork'), $resolved);
695693
}
@@ -848,7 +846,7 @@ public function deployment($project_id, $deployment_id)
848846
{
849847
return $this->get($this->getProjectPath($project_id, 'deployments/'.$this->encodePath($deployment_id)));
850848
}
851-
849+
852850
/**
853851
* @param mixed $project_id
854852
* @param array $parameters
@@ -876,7 +874,7 @@ public function addShare($project_id, array $parameters = [])
876874

877875
return $this->post($this->getProjectPath($project_id, 'share'), $resolver->resolve($parameters));
878876
}
879-
877+
880878
/**
881879
* @param mixed $project_id
882880
* @param int $group_id
@@ -931,7 +929,7 @@ public function removeBadge($project_id, $badge_id)
931929
* @param string $badge_id
932930
* @param array $params
933931
* @return mixed
934-
*/
932+
*/
935933
public function updateBadge($project_id, $badge_id, array $params = array())
936934
{
937935
return $this->put($this->getProjectPath($project_id, 'badges/' . $this->encodePath($badge_id)), $params);

lib/Gitlab/Api/Repositories.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public function commits($project_id, array $parameters = [])
188188

189189
/**
190190
* @param int $project_id
191-
* @param $sha
191+
* @param string $sha
192192
* @return mixed
193193
*/
194194
public function commit($project_id, $sha)
@@ -198,7 +198,7 @@ public function commit($project_id, $sha)
198198

199199
/**
200200
* @param int $project_id
201-
* @param $sha
201+
* @param string $sha
202202
* @param array $parameters
203203
* @return mixed
204204
*/

0 commit comments

Comments
 (0)