Skip to content

Commit 585f0fb

Browse files
PHPDoc and static analysis fixes
1 parent 4cab560 commit 585f0fb

22 files changed

+306
-41
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
/.gitignore export-ignore
77
/.styleci.yml export-ignore
88
/.travis.yml export-ignore
9+
/phpstan-baseline.neon export-ignore
10+
/phpstan.neon.dist export-ignore
911
/phpunit.xml.dist export-ignore
1012
/README.md export-ignore
1113
/UPGRADE.md export-ignore

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
vendor/
2-
composer.lock
3-
41
.idea
2+
/composer.lock
3+
/phpstan.neon
4+
/phpstan.phar
5+
/phpunit.xml
6+
/vendor

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ php:
1010

1111
matrix:
1212
include:
13-
- php: 7.3
13+
- php: 7.4
1414
env: STATIC_ANALYSIS=yes
15+
script: then php phpstan.phar analyse
1516

1617
before_script:
17-
- travis_retry composer self-update
18-
- travis_retry composer update --no-interaction ${COMPOSER_FLAGS}
19-
- if [ "$STATIC_ANALYSIS" != "" ]; then curl -L https://github.com/phpstan/phpstan/releases/download/0.10.8/phpstan.phar -o phpstan.phar; fi;
18+
- travis_retry composer update --no-interaction
19+
- if [ "$STATIC_ANALYSIS" != "" ]; then curl -L https://github.com/phpstan/phpstan/releases/download/0.12.32/phpstan.phar -o phpstan.phar; fi;
2020

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

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@
4242
},
4343
"autoload-dev": {
4444
"psr-4": { "Gitlab\\Tests\\": "test/Gitlab/Tests/" }
45-
}
45+
},
46+
"config": {
47+
"preferred-install": "dist"
48+
}
4649
}

lib/Gitlab/Api/AbstractApi.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected function delete($path, array $parameters = array(), $requestHeaders =
173173
}
174174

175175
/**
176-
* @param int $id
176+
* @param string|int $id
177177
* @param string $path
178178
* @return string
179179
*/
@@ -193,12 +193,12 @@ protected function getGroupPath($id, $path)
193193
}
194194

195195
/**
196-
* @param string $path
196+
* @param string|int $path
197197
* @return string
198198
*/
199199
protected function encodePath($path)
200200
{
201-
$path = rawurlencode($path);
201+
$path = rawurlencode((string) $path);
202202

203203
return str_replace('.', '%2E', $path);
204204
}
@@ -239,6 +239,11 @@ private function prepareBody(array $parameters = [])
239239
return $stream;
240240
}
241241

242+
/**
243+
* @param string $path
244+
* @param array $parameters
245+
* @return string
246+
*/
242247
private function preparePath($path, array $parameters = [])
243248
{
244249
if (count($parameters) > 0) {

lib/Gitlab/Api/Groups.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php namespace Gitlab\Api;
22

33
use Symfony\Component\OptionsResolver\Options;
4+
use Symfony\Component\OptionsResolver\OptionsResolver;
45

56
class Groups extends AbstractApi
67
{
@@ -373,6 +374,9 @@ public function removeVariable($group_id, $key)
373374
return $this->delete($this->getGroupPath($group_id, 'variables/'.$this->encodePath($key)));
374375
}
375376

377+
/**
378+
* @return OptionsResolver
379+
*/
376380
private function getGroupSearchResolver()
377381
{
378382
$resolver = $this->createOptionsResolver();

lib/Gitlab/Api/Issues.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function all($project_id = null, array $parameters = [])
2626
return $this->get($path, $this->createOptionsResolver()->resolve($parameters));
2727
}
2828

29+
/**
30+
* @param int $group_id
31+
* @param array $parameters
32+
* @return mixed
33+
*/
2934
public function group($group_id, array $parameters = [])
3035
{
3136
return $this->get(

lib/Gitlab/Api/IssuesStatistics.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,38 @@
55

66
class IssuesStatistics extends AbstractApi
77
{
8+
/**
9+
* @param array $parameters
10+
* @return mixed
11+
*/
812
public function all($parameters)
913
{
1014
return $this->get('issues_statistics', $this->createOptionsResolver()->resolve($parameters));
1115
}
1216

17+
/**
18+
* @param int $project_id
19+
* @param array $parameters
20+
* @return mixed
21+
*/
1322
public function project($project_id, $parameters)
1423
{
1524
return $this->get($this->getProjectPath($project_id, 'issues_statistics'), $this->createOptionsResolver()->resolve($parameters));
1625
}
1726

27+
/**
28+
* @param int $group_id
29+
* @param array $parameters
30+
* @return mixed
31+
*/
1832
public function group($group_id, $parameters)
1933
{
2034
return $this->get($this->getGroupPath($group_id, 'issues_statistics'), $this->createOptionsResolver()->resolve($parameters));
2135
}
2236

37+
/**
38+
* @return OptionsResolver
39+
*/
2340
protected function createOptionsResolver()
2441
{
2542
$resolver = new OptionsResolver();

lib/Gitlab/Api/Projects.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function addMember($project_id, $user_id, $access_level)
361361
*/
362362
public function saveMember($project_id, $user_id, $access_level)
363363
{
364-
return $this->put($this->getProjectPath($project_id, 'members/'.urldecode($user_id)), array(
364+
return $this->put($this->getProjectPath($project_id, 'members/'.$this->encodePath($user_id)), array(
365365
'access_level' => $access_level
366366
));
367367
}
@@ -373,7 +373,7 @@ public function saveMember($project_id, $user_id, $access_level)
373373
*/
374374
public function removeMember($project_id, $user_id)
375375
{
376-
return $this->delete($this->getProjectPath($project_id, 'members/'.urldecode($user_id)));
376+
return $this->delete($this->getProjectPath($project_id, 'members/'.$this->encodePath($user_id)));
377377
}
378378

379379
/**
@@ -884,7 +884,7 @@ public function badges($project_id)
884884

885885
/**
886886
* @param int $project_id
887-
* @param string $badge_id
887+
* @param int $badge_id
888888
* @return mixed
889889
*/
890890
public function badge($project_id, $badge_id)
@@ -904,7 +904,7 @@ public function addBadge($project_id, array $parameters = array())
904904

905905
/**
906906
* @param int $project_id
907-
* @param string $badge_id
907+
* @param int $badge_id
908908
* @return mixed
909909
*/
910910
public function removeBadge($project_id, $badge_id)
@@ -914,7 +914,7 @@ public function removeBadge($project_id, $badge_id)
914914

915915
/**
916916
* @param int $project_id
917-
* @param string $badge_id
917+
* @param int $badge_id
918918
* @param array $parameters
919919
* @return mixed
920920
*/

lib/Gitlab/Api/Repositories.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public function branches($project_id, array $parameters = [])
2727

2828
/**
2929
* @param int $project_id
30-
* @param int $branch_id
30+
* @param string $branch
3131
* @return mixed
3232
*/
33-
public function branch($project_id, $branch_id)
33+
public function branch($project_id, $branch)
3434
{
35-
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_id)));
35+
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch)));
3636
}
3737

3838
/**
@@ -61,27 +61,27 @@ public function deleteBranch($project_id, $branch)
6161

6262
/**
6363
* @param int $project_id
64-
* @param string $branch_name
64+
* @param string $branch
6565
* @param bool $devPush
6666
* @param bool $devMerge
6767
* @return mixed
6868
*/
69-
public function protectBranch($project_id, $branch_name, $devPush = false, $devMerge = false)
69+
public function protectBranch($project_id, $branch, $devPush = false, $devMerge = false)
7070
{
71-
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name).'/protect'), array(
71+
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch).'/protect'), array(
7272
'developers_can_push' => $devPush,
7373
'developers_can_merge' => $devMerge
7474
));
7575
}
7676

7777
/**
7878
* @param int $project_id
79-
* @param string $branch_name
79+
* @param string $branch
8080
* @return mixed
8181
*/
82-
public function unprotectBranch($project_id, $branch_name)
82+
public function unprotectBranch($project_id, $branch)
8383
{
84-
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name).'/unprotect'));
84+
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch).'/unprotect'));
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)