Skip to content

Commit 9292486

Browse files
Added types where possible
1 parent 74086ac commit 9292486

39 files changed

+286
-285
lines changed

rector.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ services:
5656
Rector\SOLID\Rector\If_\ChangeNestedIfsToEarlyReturnRector: ~
5757
Rector\SOLID\Rector\If_\RemoveAlwaysElseRector: ~
5858
Rector\SOLID\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector: ~
59+
Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector: ~

src/Api/AbstractApi.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function perPage(?int $perPage)
9393
*
9494
* @return \Psr\Http\Message\ResponseInterface
9595
*/
96-
protected function getAsResponse($uri, array $params = [], array $headers = [])
96+
protected function getAsResponse(string $uri, array $params = [], array $headers = [])
9797
{
9898
if (null !== $this->perPage && !isset($params['per_page'])) {
9999
$params['per_page'] = $this->perPage;
@@ -109,7 +109,7 @@ protected function getAsResponse($uri, array $params = [], array $headers = [])
109109
*
110110
* @return mixed
111111
*/
112-
protected function get($uri, array $params = [], array $headers = [])
112+
protected function get(string $uri, array $params = [], array $headers = [])
113113
{
114114
$response = $this->getAsResponse($uri, $params, $headers);
115115

@@ -124,7 +124,7 @@ protected function get($uri, array $params = [], array $headers = [])
124124
*
125125
* @return mixed
126126
*/
127-
protected function post($uri, array $params = [], array $headers = [], array $files = [])
127+
protected function post(string $uri, array $params = [], array $headers = [], array $files = [])
128128
{
129129
if (0 < \count($files)) {
130130
$builder = $this->createMultipartStreamBuilder($params, $files);
@@ -151,7 +151,7 @@ protected function post($uri, array $params = [], array $headers = [], array $fi
151151
*
152152
* @return mixed
153153
*/
154-
protected function put($uri, array $params = [], array $headers = [], array $files = [])
154+
protected function put(string $uri, array $params = [], array $headers = [], array $files = [])
155155
{
156156
if (0 < \count($files)) {
157157
$builder = $this->createMultipartStreamBuilder($params, $files);
@@ -177,7 +177,7 @@ protected function put($uri, array $params = [], array $headers = [], array $fil
177177
*
178178
* @return mixed
179179
*/
180-
protected function delete($uri, array $params = [], array $headers = [])
180+
protected function delete(string $uri, array $params = [], array $headers = [])
181181
{
182182
$body = self::prepareJsonBody($params);
183183

@@ -206,7 +206,7 @@ protected static function encodePath($uri)
206206
*
207207
* @return string
208208
*/
209-
protected function getProjectPath($id, $uri)
209+
protected function getProjectPath($id, string $uri)
210210
{
211211
return 'projects/'.self::encodePath($id).'/'.$uri;
212212
}
@@ -217,7 +217,7 @@ protected function getProjectPath($id, $uri)
217217
*
218218
* @return string
219219
*/
220-
protected function getGroupPath($id, $uri)
220+
protected function getGroupPath(int $id, string $uri)
221221
{
222222
return 'groups/'.self::encodePath($id).'/'.$uri;
223223
}
@@ -365,7 +365,7 @@ private static function addJsonContentType(array $headers)
365365
*
366366
* @see https://github.com/guzzle/psr7/blob/1.6.1/src/functions.php#L287-L320
367367
*/
368-
private static function tryFopen($filename, $mode)
368+
private static function tryFopen(string $filename, string $mode)
369369
{
370370
$ex = null;
371371
\set_error_handler(function () use ($filename, $mode, &$ex) {

src/Api/Deployments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function all($project_id, array $parameters = [])
2525
*
2626
* @return mixed
2727
*/
28-
public function show($project_id, $deployment_id)
28+
public function show($project_id, string $deployment_id)
2929
{
3030
return $this->get($this->getProjectPath($project_id, 'deployments/'.$deployment_id));
3131
}

src/Api/Environments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function create($project_id, array $parameters = [])
5353
*
5454
* @return mixed
5555
*/
56-
public function remove($project_id, $environment_id)
56+
public function remove($project_id, string $environment_id)
5757
{
5858
return $this->delete($this->getProjectPath($project_id, 'environments/'.$environment_id));
5959
}
@@ -64,7 +64,7 @@ public function remove($project_id, $environment_id)
6464
*
6565
* @return mixed
6666
*/
67-
public function stop($project_id, $environment_id)
67+
public function stop($project_id, string $environment_id)
6868
{
6969
return $this->post($this->getProjectPath($project_id, 'environments/'.self::encodePath($environment_id).'/stop'));
7070
}
@@ -75,7 +75,7 @@ public function stop($project_id, $environment_id)
7575
*
7676
* @return mixed
7777
*/
78-
public function show($project_id, $environment_id)
78+
public function show($project_id, string $environment_id)
7979
{
8080
return $this->get($this->getProjectPath($project_id, 'environments/'.self::encodePath($environment_id)));
8181
}

src/Api/Groups.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function all(array $parameters = [])
3535
*
3636
* @return mixed
3737
*/
38-
public function show($id)
38+
public function show(int $id)
3939
{
4040
return $this->get('groups/'.self::encodePath($id));
4141
}
@@ -52,7 +52,7 @@ public function show($id)
5252
*
5353
* @return mixed
5454
*/
55-
public function create($name, $path, $description = null, $visibility = 'private', $lfs_enabled = null, $request_access_enabled = null, $parent_id = null, $shared_runners_minutes_limit = null)
55+
public function create(string $name, string $path, string $description = null, string $visibility = 'private', bool $lfs_enabled = null, bool $request_access_enabled = null, int $parent_id = null, int $shared_runners_minutes_limit = null)
5656
{
5757
$params = [
5858
'name' => $name,
@@ -76,7 +76,7 @@ public function create($name, $path, $description = null, $visibility = 'private
7676
*
7777
* @return mixed
7878
*/
79-
public function update($id, array $params)
79+
public function update(int $id, array $params)
8080
{
8181
return $this->put('groups/'.self::encodePath($id), $params);
8282
}
@@ -86,7 +86,7 @@ public function update($id, array $params)
8686
*
8787
* @return mixed
8888
*/
89-
public function remove($group_id)
89+
public function remove(int $group_id)
9090
{
9191
return $this->delete('groups/'.self::encodePath($group_id));
9292
}
@@ -97,7 +97,7 @@ public function remove($group_id)
9797
*
9898
* @return mixed
9999
*/
100-
public function transfer($group_id, $project_id)
100+
public function transfer(int $group_id, $project_id)
101101
{
102102
return $this->post('groups/'.self::encodePath($group_id).'/projects/'.self::encodePath($project_id));
103103
}
@@ -108,7 +108,7 @@ public function transfer($group_id, $project_id)
108108
*
109109
* @return mixed
110110
*/
111-
public function allMembers($group_id, array $parameters = [])
111+
public function allMembers(int $group_id, array $parameters = [])
112112
{
113113
$resolver = $this->createOptionsResolver();
114114
$resolver->setDefined('query');
@@ -125,7 +125,7 @@ public function allMembers($group_id, array $parameters = [])
125125
*
126126
* @return mixed
127127
*/
128-
public function members($group_id, array $parameters = [])
128+
public function members(int $group_id, array $parameters = [])
129129
{
130130
$resolver = $this->createOptionsResolver();
131131
$resolver->setDefined('query');
@@ -139,7 +139,7 @@ public function members($group_id, array $parameters = [])
139139
*
140140
* @return mixed
141141
*/
142-
public function member($group_id, $user_id)
142+
public function member(int $group_id, int $user_id)
143143
{
144144
return $this->get('groups/'.self::encodePath($group_id).'/members/'.self::encodePath($user_id));
145145
}
@@ -151,7 +151,7 @@ public function member($group_id, $user_id)
151151
*
152152
* @return mixed
153153
*/
154-
public function addMember($group_id, $user_id, $access_level)
154+
public function addMember(int $group_id, int $user_id, int $access_level)
155155
{
156156
return $this->post('groups/'.self::encodePath($group_id).'/members', [
157157
'user_id' => $user_id,
@@ -166,7 +166,7 @@ public function addMember($group_id, $user_id, $access_level)
166166
*
167167
* @return mixed
168168
*/
169-
public function saveMember($group_id, $user_id, $access_level)
169+
public function saveMember(int $group_id, int $user_id, int $access_level)
170170
{
171171
return $this->put('groups/'.self::encodePath($group_id).'/members/'.self::encodePath($user_id), [
172172
'access_level' => $access_level,
@@ -179,7 +179,7 @@ public function saveMember($group_id, $user_id, $access_level)
179179
*
180180
* @return mixed
181181
*/
182-
public function removeMember($group_id, $user_id)
182+
public function removeMember(int $group_id, int $user_id)
183183
{
184184
return $this->delete('groups/'.self::encodePath($group_id).'/members/'.self::encodePath($user_id));
185185
}
@@ -206,7 +206,7 @@ public function removeMember($group_id, $user_id)
206206
*
207207
* @return mixed
208208
*/
209-
public function projects($id, array $parameters = [])
209+
public function projects(int $id, array $parameters = [])
210210
{
211211
$resolver = $this->createOptionsResolver();
212212
$booleanNormalizer = function (Options $resolver, $value) {
@@ -278,7 +278,7 @@ public function projects($id, array $parameters = [])
278278
*
279279
* @return mixed
280280
*/
281-
public function subgroups($group_id, array $parameters = [])
281+
public function subgroups(int $group_id, array $parameters = [])
282282
{
283283
$resolver = $this->getGroupSearchResolver();
284284

@@ -291,7 +291,7 @@ public function subgroups($group_id, array $parameters = [])
291291
*
292292
* @return mixed
293293
*/
294-
public function labels($group_id, array $parameters = [])
294+
public function labels(int $group_id, array $parameters = [])
295295
{
296296
$resolver = $this->createOptionsResolver();
297297

@@ -304,7 +304,7 @@ public function labels($group_id, array $parameters = [])
304304
*
305305
* @return mixed
306306
*/
307-
public function addLabel($group_id, array $params)
307+
public function addLabel(int $group_id, array $params)
308308
{
309309
return $this->post('groups/'.self::encodePath($group_id).'/labels', $params);
310310
}
@@ -315,7 +315,7 @@ public function addLabel($group_id, array $params)
315315
*
316316
* @return mixed
317317
*/
318-
public function updateLabel($group_id, array $params)
318+
public function updateLabel(int $group_id, array $params)
319319
{
320320
return $this->put('groups/'.self::encodePath($group_id).'/labels', $params);
321321
}
@@ -326,7 +326,7 @@ public function updateLabel($group_id, array $params)
326326
*
327327
* @return mixed
328328
*/
329-
public function removeLabel($group_id, $name)
329+
public function removeLabel(int $group_id, string $name)
330330
{
331331
return $this->delete('groups/'.self::encodePath($group_id).'/labels', [
332332
'name' => $name,
@@ -339,7 +339,7 @@ public function removeLabel($group_id, $name)
339339
*
340340
* @return mixed
341341
*/
342-
public function variables($group_id, array $parameters = [])
342+
public function variables(int $group_id, array $parameters = [])
343343
{
344344
$resolver = $this->createOptionsResolver();
345345

@@ -352,7 +352,7 @@ public function variables($group_id, array $parameters = [])
352352
*
353353
* @return mixed
354354
*/
355-
public function variable($group_id, $key)
355+
public function variable(int $group_id, string $key)
356356
{
357357
return $this->get($this->getGroupPath($group_id, 'variables/'.self::encodePath($key)));
358358
}
@@ -365,7 +365,7 @@ public function variable($group_id, $key)
365365
*
366366
* @return mixed
367367
*/
368-
public function addVariable($group_id, $key, $value, $protected = null)
368+
public function addVariable(int $group_id, string $key, string $value, ?bool $protected = null)
369369
{
370370
$payload = [
371371
'key' => $key,
@@ -387,7 +387,7 @@ public function addVariable($group_id, $key, $value, $protected = null)
387387
*
388388
* @return mixed
389389
*/
390-
public function updateVariable($group_id, $key, $value, $protected = null)
390+
public function updateVariable(int $group_id, string $key, string $value, ?bool $protected = null)
391391
{
392392
$payload = [
393393
'value' => $value,
@@ -406,7 +406,7 @@ public function updateVariable($group_id, $key, $value, $protected = null)
406406
*
407407
* @return mixed
408408
*/
409-
public function removeVariable($group_id, $key)
409+
public function removeVariable(int $group_id, string $key)
410410
{
411411
return $this->delete($this->getGroupPath($group_id, 'variables/'.self::encodePath($key)));
412412
}

0 commit comments

Comments
 (0)