Skip to content

Commit 2d4f374

Browse files
authored
Merge pull request GitLabPHP#1 from m4tthumphrey/master
update upstream
2 parents 2916023 + 5a3ef56 commit 2d4f374

32 files changed

+962
-75
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ php:
66
- 5.6
77
- 7.0
88
- 7.1
9+
- 7.2
910

1011
matrix:
12+
# test latest PHP stable version with lowest dependencies and phpstan static analysis
1113
include:
12-
- php: 7.2
13-
env: STATIC_ANALYSIS=yes
14+
- php: 7.1
15+
env: COMPOSER_FLAGS="--prefer-lowest" STATIC_ANALYSIS=yes
1416

1517
before_script:
1618
- travis_retry composer self-update
17-
- travis_retry composer install --no-interaction --prefer-source
19+
- travis_retry composer update --no-interaction ${COMPOSER_FLAGS}
1820
- if [ "$STATIC_ANALYSIS" != "" ]; then curl -L https://github.com/phpstan/phpstan/releases/download/0.8/phpstan.phar -o phpstan.phar; fi;
1921

2022
script:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Matt Humphrey
3+
Copyright (c) 2018 Matt Humphrey
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ to fetch all your closed issue with pagination ( on the gitlab api )
5757
$client = \Gitlab\Client::create('http://git.yourdomain.com')
5858
->authenticate('your_gitlab_token_here', \Gitlab\Client::AUTH_URL_TOKEN)
5959
;
60-
$pager = new ResultPager($client);
60+
$pager = new \Gitlab\ResultPager($client);
6161
$issues = $pager->fetchall($client->api('issues'),'all',[null, ['state' => 'closed']]);
6262

6363
```
@@ -99,7 +99,7 @@ You get the idea! Take a look around ([API methods](https://github.com/m4tthumph
9999
Framework Integrations
100100
----------------------
101101
- **Symfony** - https://github.com/Zeichen32/GitLabApiBundle
102-
- **Laravel** - https://github.com/vinkla/laravel-gitlab
102+
- **Laravel** - https://github.com/GrahamCampbell/Laravel-GitLab
103103

104104
If you have integrated GitLab into a popular PHP framework, let us know!
105105

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
"require": {
2424
"php": "^5.6 || ^7.0",
2525
"ext-xml": "*",
26-
"php-http/client-common": "^1.5",
26+
"php-http/client-common": "^1.6",
2727
"php-http/client-implementation": "^1.0",
2828
"php-http/discovery": "^1.2",
2929
"php-http/httplug": "^1.1",
3030
"php-http/multipart-stream-builder": "^1.0",
31-
"symfony/options-resolver": "^2.6 || ^3.0"
31+
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0"
3232
},
3333
"require-dev": {
3434
"guzzlehttp/psr7": "^1.2",
3535
"php-http/guzzle6-adapter": "^1.0",
3636
"php-http/mock-client": "^1.0",
37-
"phpunit/phpunit": "~4.5"
37+
"phpunit/phpunit": "^5.0"
3838
},
3939
"autoload": {
4040
"psr-4": { "Gitlab\\": "lib/Gitlab/" }
@@ -44,7 +44,7 @@
4444
},
4545
"extra": {
4646
"branch-alias": {
47-
"dev-master": "9.0.x-dev"
47+
"dev-master": "9.8.x-dev"
4848
}
4949
}
5050
}

lib/Gitlab/Api/Deployments.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php namespace Gitlab\Api;
2+
3+
class Deployments extends AbstractApi
4+
{
5+
/**
6+
* @param int $project_id
7+
* @param array $parameters
8+
* @return mixed
9+
*/
10+
public function all($project_id, array $parameters = [])
11+
{
12+
$resolver = $this->createOptionsResolver();
13+
return $this->get($this->getProjectPath($project_id, 'deployments'), $resolver->resolve($parameters));
14+
}
15+
16+
/**
17+
* @param int $project_id
18+
* @param string $deployment_id
19+
* @return mixed
20+
*/
21+
public function show($project_id, $deployment_id)
22+
{
23+
return $this->get($this->getProjectPath($project_id, 'deployments/' . $deployment_id));
24+
}
25+
}

lib/Gitlab/Api/Environments.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php namespace Gitlab\Api;
2+
3+
use Symfony\Component\OptionsResolver\OptionsResolver;
4+
5+
class Environments extends AbstractApi
6+
{
7+
/**
8+
* @param int $project_id
9+
* @param array $parameters
10+
* @return mixed
11+
*/
12+
public function all($project_id, array $parameters = [])
13+
{
14+
$resolver = $this->createOptionsResolver();
15+
return $this->get($this->getProjectPath($project_id, 'environments'), $resolver->resolve($parameters));
16+
}
17+
18+
/**
19+
* @param int $project_id
20+
* @param array $parameters (
21+
*
22+
* @var string $name The name of the environment
23+
* @var string $external_url Place to link to for this environment
24+
* )
25+
* @return mixed
26+
*/
27+
public function create($project_id, array $parameters = array())
28+
{
29+
$resolver = new OptionsResolver();
30+
$resolver->setDefined('name')
31+
->setRequired('name')
32+
->setAllowedTypes('name', 'string');
33+
$resolver->setDefined('external_url')
34+
->setAllowedTypes('external_url', 'string');
35+
36+
return $this->post($this->getProjectPath($project_id, 'environment'), $resolver->resolve($parameters));
37+
}
38+
39+
/**
40+
* @param int $project_id
41+
* @param string $environment_id
42+
* @return mixed
43+
*/
44+
public function remove($project_id, $environment_id)
45+
{
46+
return $this->delete($this->getProjectPath($project_id, 'environments/' . $environment_id));
47+
}
48+
}

lib/Gitlab/Api/Groups.php

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

3+
use Symfony\Component\OptionsResolver\Options;
4+
35
class Groups extends AbstractApi
46
{
57
/**
@@ -18,7 +20,7 @@ class Groups extends AbstractApi
1820
public function all(array $parameters = [])
1921
{
2022
$resolver = $this->createOptionsResolver();
21-
$booleanNormalizer = function ($value) {
23+
$booleanNormalizer = function (Options $resolver, $value) {
2224
return $value ? 'true' : 'false';
2325
};
2426

@@ -180,7 +182,7 @@ public function removeMember($group_id, $user_id)
180182
public function projects($id, array $parameters = [])
181183
{
182184
$resolver = $this->createOptionsResolver();
183-
$booleanNormalizer = function ($value) {
185+
$booleanNormalizer = function (Options $resolver, $value) {
184186
return $value ? 'true' : 'false';
185187
};
186188

lib/Gitlab/Api/Jobs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function artifacts($project_id, $job_id)
8181
public function artifactsByRefName($project_id, $ref_name, $job_name)
8282
{
8383
return $this->getAsResponse("projects/".$this->encodePath($project_id)."/jobs/artifacts/".$this->encodePath($ref_name)."/download", array(
84-
'job' => $job_name
84+
'job' => $this->encodePath($job_name)
8585
))->getBody();
8686
}
8787

lib/Gitlab/Api/MergeRequests.php

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

3+
use Symfony\Component\OptionsResolver\Options;
34
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
45
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
56

@@ -36,7 +37,7 @@ class MergeRequests extends AbstractApi
3637
public function all($project_id, array $parameters = [])
3738
{
3839
$resolver = $this->createOptionsResolver();
39-
$datetimeNormalizer = function (\DateTimeInterface $value) {
40+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value) {
4041
return $value->format('c');
4142
};
4243
$resolver->setDefined('iids')
@@ -67,7 +68,8 @@ public function all($project_id, array $parameters = [])
6768
->setAllowedTypes('created_before', \DateTimeInterface::class)
6869
->setNormalizer('created_before', $datetimeNormalizer)
6970
;
70-
71+
$resolver->setDefined('search');
72+
7173
return $this->get($this->getProjectPath($project_id, 'merge_requests'), $resolver->resolve($parameters));
7274
}
7375

lib/Gitlab/Api/Projects.php

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

3+
use Symfony\Component\OptionsResolver\Options;
34
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
45
use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException;
56
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -33,7 +34,7 @@ class Projects extends AbstractApi
3334
public function all(array $parameters = [])
3435
{
3536
$resolver = $this->createOptionsResolver();
36-
$booleanNormalizer = function ($value) {
37+
$booleanNormalizer = function (Options $resolver, $value) {
3738
return $value ? 'true' : 'false';
3839
};
3940
$resolver->setDefined('archived')
@@ -84,11 +85,28 @@ public function all(array $parameters = [])
8485

8586
/**
8687
* @param int $project_id
88+
* @param array $parameters {
89+
*
90+
* @var bool $statistics Include project statistics.
91+
* @var bool $with_custom_attributes Include project custom attributes.
92+
* }
8793
* @return mixed
8894
*/
89-
public function show($project_id)
95+
public function show($project_id, array $parameters = [])
9096
{
91-
return $this->get('projects/'.$this->encodePath($project_id));
97+
$resolver = $this->createOptionsResolver();
98+
$booleanNormalizer = function (Options $resolver, $value) {
99+
return $value ? true : false;
100+
};
101+
$resolver->setDefined('statistics')
102+
->setAllowedTypes('statistics', 'bool')
103+
->setNormalizer('statistics', $booleanNormalizer)
104+
;
105+
$resolver->setDefined('with_custom_attributes')
106+
->setAllowedTypes('with_custom_attributes', 'bool')
107+
->setNormalizer('with_custom_attributes', $booleanNormalizer)
108+
;
109+
return $this->get('projects/'.$this->encodePath($project_id), $resolver->resolve($parameters));
92110
}
93111

94112
/**
@@ -171,7 +189,7 @@ public function unarchive($project_id)
171189
public function pipelines($project_id, array $parameters = [])
172190
{
173191
$resolver = $this->createOptionsResolver();
174-
$booleanNormalizer = function ($value) {
192+
$booleanNormalizer = function (Options $resolver, $value) {
175193
return $value ? 'true' : 'false';
176194
};
177195

@@ -241,14 +259,33 @@ public function cancelPipeline($project_id, $pipeline_id)
241259

242260
/**
243261
* @param int $project_id
244-
* @param string $username_query
262+
* @param array $parameters (
263+
*
264+
* @var string $query The query you want to search members for.
265+
* )
266+
*
267+
* @throws MissingOptionsException If a required option is not provided
268+
*
245269
* @return mixed
246270
*/
247-
public function members($project_id, $username_query = null)
271+
public function members($project_id, $parameters = [])
248272
{
249-
return $this->get($this->getProjectPath($project_id, 'members'), array(
250-
'query' => $username_query
251-
));
273+
if (!is_array($parameters)) {
274+
@trigger_error("Deprecated: String parameter of the members() function is deprecated.", E_USER_NOTICE);
275+
$username_query = $parameters;
276+
$parameters = array();
277+
if (!empty($username_query)) {
278+
$parameters['query'] = $username_query;
279+
}
280+
}
281+
282+
$resolver = $this->createOptionsResolver();
283+
284+
$resolver->setDefined('query')
285+
->setAllowedTypes('query', 'string')
286+
;
287+
288+
return $this->get($this->getProjectPath($project_id, 'members'), $resolver->resolve($parameters));
252289
}
253290

254291
/**
@@ -430,7 +467,7 @@ public function enableDeployKey($project_id, $key_id)
430467
public function events($project_id, array $parameters = [])
431468
{
432469
$resolver = $this->createOptionsResolver();
433-
$datetimeNormalizer = function (\DateTimeInterface $value) {
470+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value) {
434471
return $value->format('Y-m-d');
435472
};
436473

@@ -495,6 +532,17 @@ public function removeLabel($project_id, $name)
495532
));
496533
}
497534

535+
/**
536+
* Get languages used in a project with percentage value.
537+
*
538+
* @param int $project_id
539+
* @return mixed
540+
*/
541+
public function languages($project_id)
542+
{
543+
return $this->get($this->getProjectPath($project_id, 'languages'));
544+
}
545+
498546
/**
499547
* @param int $project_id
500548
* @param array $params (
@@ -555,11 +603,15 @@ public function removeService($project_id, $service_name)
555603

556604
/**
557605
* @param int $project_id
606+
* @param array $parameters
607+
*
558608
* @return mixed
559609
*/
560-
public function variables($project_id)
610+
public function variables($project_id, array $parameters = [])
561611
{
562-
return $this->get($this->getProjectPath($project_id, 'variables'));
612+
$resolver = $this->createOptionsResolver();
613+
614+
return $this->get($this->getProjectPath($project_id, 'variables'), $resolver->resolve($parameters));
563615
}
564616

565617
/**

0 commit comments

Comments
 (0)