Skip to content

Commit 8011ff6

Browse files
Merge remote-tracking branch 'upstream/11.14' into pkolmann-gitlab-integrations
2 parents 1f28f5f + 6b80588 commit 8011ff6

Some content is hidden

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

41 files changed

+1255
-78
lines changed

.github/workflows/static.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout code
48-
uses: actions/checkout@v3
48+
uses: actions/checkout@v4
4949

5050
- name: Setup PHP
5151
uses: shivammathur/setup-php@v2

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
php: ['7.4', '8.0', '8.1', '8.2']
14+
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
1515

1616
steps:
1717
- name: Checkout Code
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2

.styleci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ disabled:
1717
- native_constant_invocation_symfony
1818
- native_function_invocation_symfony
1919
- no_superfluous_phpdoc_tags_symfony
20+
- phpdoc_align
2021
- phpdoc_to_comment
2122
- phpdoc_var_without_name

CHANGELOG.md

+39
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,45 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [11.14.0] - 2024-03-11
9+
10+
* Add support for `php-http/cache-plugin:^2.0`
11+
* Add support for `'approved'` `status` in `Project::events`
12+
* Add support for `name` in `createRelease` and `updateRelease`
13+
* Add support for date filtering to `GroupsMilestones::all()`
14+
* Update `MergeRequests::all` to use millisecond precision for date filters
15+
16+
## [11.13.0] - 2023-12-03
17+
18+
* Add support for `symfony/options-resolver:^7.0`
19+
* Add support for `status` and `environment` in `Deployments::all`
20+
* Add support for `Groups::search`, `Projects::search`, and `Search::all`
21+
22+
## [11.12.0] - 2023-10-08
23+
24+
* Add PHP 8.3 support
25+
* Add `Projects::updateProtectedBranch` and `Projects::updateApprovalsConfiguration`
26+
* Add support for `environment_scope` in `Projects::removeVariable`
27+
* Add support for `filter` in `Projects::variable`
28+
* Add support for `author` in `Repositories::commits`
29+
* Add support for additional parameters in `Projects::labels` and `Groups::labels`
30+
31+
## [11.11.1] - 2023-10-08
32+
33+
* Fixed double encoding of job name in artifacts download
34+
35+
## [11.11.0] - 2023-07-17
36+
37+
* Add support for `author_id` in `Issues::all`
38+
* Add support for `tier` in `Environments::create`
39+
* Add support for `expires_at` in `Groups::addMember`
40+
* Add support for `include_retried` in `Jobs::pipelineBridges`
41+
* Add support for additional parameters in `Projects::deployment`
42+
* Add support for additional parameters in `Projects::forks`
43+
* Add support for `Events::all`
44+
* Add support for `Users::removeUserIdentity`
45+
* Add support for `MergeRequests::showParticipants`
46+
847
## [11.10.0] - 2023-04-30
948

1049
* Add support for `Packages::addGenericFile`

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2012-2018 Matt Humphrey <[email protected]>
4-
Copyright (c) 2018-2023 Graham Campbell <[email protected]>
4+
Copyright (c) 2018-2024 Graham Campbell <[email protected]>
55

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

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,27 @@ Check out the [change log](CHANGELOG.md), [releases](https://github.com/GitLabPH
2323

2424
## Installation
2525

26-
This version supports [PHP](https://php.net) 7.4-8.2. To get started, simply require the project using [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).
26+
This version supports [PHP](https://php.net) 7.4-8.3. To get started, simply require the project using [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).
2727

2828
### Standard Installation
2929

3030
```bash
31-
$ composer require "m4tthumphrey/php-gitlab-api:^11.10" \
32-
"guzzlehttp/guzzle:^7.5.1" "http-interop/http-factory-guzzle:^1.2"
31+
$ composer require "m4tthumphrey/php-gitlab-api:^11.14" \
32+
"guzzlehttp/guzzle:^7.8" "http-interop/http-factory-guzzle:^1.2"
3333
```
3434

3535
### Framework Integration
3636

3737
#### Laravel:
3838

3939
```bash
40-
$ composer require "graham-campbell/gitlab:^7.2"
40+
$ composer require "graham-campbell/gitlab:^7.5"
4141
```
4242

4343
#### Symfony:
4444

4545
```bash
46-
$ composer require "zeichen32/gitlabapibundle:^6.0" \
47-
"symfony/http-client:^6.2" "nyholm/psr7:^1.7"
46+
$ composer require "zeichen32/gitlabapibundle:^6.1"
4847
```
4948

5049
We are decoupled from any HTTP messaging client by using [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-17](https://www.php-fig.org/psr/psr-17/), [PSR-18](https://www.php-fig.org/psr/psr-18/), and [HTTPlug](https://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. The framework integration [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).

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929
"php": "^7.4.15 || ^8.0.2",
3030
"ext-json": "*",
3131
"ext-xml": "*",
32-
"php-http/cache-plugin": "^1.8",
33-
"php-http/client-common": "^2.6.1",
34-
"php-http/discovery": "^1.17",
32+
"php-http/cache-plugin": "^1.8.1 || ^2.0",
33+
"php-http/client-common": "^2.7.1",
34+
"php-http/discovery": "^1.19.2",
3535
"php-http/httplug": "^2.4",
3636
"php-http/multipart-stream-builder": "^1.3",
3737
"psr/cache": "^1.0 || ^2.0 || ^3.0",
3838
"psr/http-client-implementation": "^1.0",
3939
"psr/http-factory-implementation": "^1.0",
4040
"psr/http-message": "^1.1 || ^2.0",
41-
"symfony/options-resolver": "^4.4 || ^5.0 || ^6.0",
41+
"symfony/options-resolver": "^4.4 || ^5.0 || ^6.0 || ^7.0",
4242
"symfony/polyfill-php80": "^1.26"
4343
},
4444
"require-dev": {
4545
"bamarni/composer-bin-plugin": "^1.8.2",
46-
"guzzlehttp/guzzle": "^7.5.1",
47-
"http-interop/http-factory-guzzle": "^1.0"
46+
"guzzlehttp/guzzle": "^7.8",
47+
"http-interop/http-factory-guzzle": "^1.2"
4848
},
4949
"autoload": {
5050
"psr-4": {

phpstan-baseline.neon

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ parameters:
2020
count: 1
2121
path: src/Api/AbstractApi.php
2222

23+
-
24+
message: "#^PHPDoc tag @return contains generic type Http\\\\Promise\\\\Promise\\<Psr\\\\Http\\\\Message\\\\ResponseInterface\\> but interface Http\\\\Promise\\\\Promise is not generic\\.$#"
25+
count: 1
26+
path: src/HttpClient/Plugin/Authentication.php
27+
28+
-
29+
message: "#^PHPDoc tag @return contains generic type Http\\\\Promise\\\\Promise\\<Psr\\\\Http\\\\Message\\\\ResponseInterface\\> but interface Http\\\\Promise\\\\Promise is not generic\\.$#"
30+
count: 1
31+
path: src/HttpClient/Plugin/ExceptionThrower.php
32+
2333
-
2434
message: "#^Cannot cast mixed to string\\.$#"
2535
count: 1

phpstan.neon.dist

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ includes:
77
rules:
88
- Ergebnis\PHPStan\Rules\Closures\NoNullableReturnTypeDeclarationRule
99
- Ergebnis\PHPStan\Rules\Expressions\NoCompactRule
10-
- Ergebnis\PHPStan\Rules\Expressions\NoEmptyRule
1110
- Ergebnis\PHPStan\Rules\Expressions\NoEvalRule
1211
- Ergebnis\PHPStan\Rules\Files\DeclareStrictTypesRule
1312
- Ergebnis\PHPStan\Rules\Methods\PrivateInFinalClassRule

phpunit.xml.dist

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
33
<testsuites>
44
<testsuite name="Test Suite">
55
<directory suffix="Test.php">./tests</directory>
66
</testsuite>
77
</testsuites>
8-
<coverage>
8+
<source>
99
<include>
1010
<directory suffix=".php">./src</directory>
1111
</include>
12-
</coverage>
12+
</source>
1313
</phpunit>

psalm-baseline.xml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.7.6@ae4ec68e00e4880e3f00b1edd2da891236d749ab">
2+
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
33
<file src="src/Api/AbstractApi.php">
44
<InvalidArgument>
55
<code><![CDATA[function () use ($filename, $mode, &$ex): void {
@@ -17,6 +17,16 @@
1717
<code><![CDATA['is_int']]></code>
1818
</TypeDoesNotContainType>
1919
</file>
20+
<file src="src/HttpClient/Plugin/Authentication.php">
21+
<TooManyTemplateParams>
22+
<code><![CDATA[Promise<ResponseInterface>]]></code>
23+
</TooManyTemplateParams>
24+
</file>
25+
<file src="src/HttpClient/Plugin/ExceptionThrower.php">
26+
<TooManyTemplateParams>
27+
<code><![CDATA[Promise<ResponseInterface>]]></code>
28+
</TooManyTemplateParams>
29+
</file>
2030
<file src="src/ResultPager.php">
2131
<InaccessibleProperty>
2232
<code><![CDATA[$clone->perPage]]></code>

psalm.xml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
xmlns="https://getpsalm.org/schema/config"
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
88
errorBaseline="psalm-baseline.xml"
9+
findUnusedBaselineEntry="true"
10+
findUnusedCode="false"
911
>
1012
<issueHandlers>
1113
<PossiblyInvalidDocblockTag errorLevel="info" />

src/Api/AbstractApi.php

+37
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ abstract class AbstractApi
3838
*/
3939
private const URI_PREFIX = '/api/v4/';
4040

41+
/**
42+
* The access levels for groups and projects
43+
* as defined in the Gitlab::Access module.
44+
*
45+
* @see https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/access.rb
46+
*
47+
* @var array
48+
*/
49+
protected const ACCESS_LEVELS = [0, 10, 20, 30, 40, 50];
50+
4151
/**
4252
* The client instance.
4353
*
@@ -153,6 +163,33 @@ protected function put(string $uri, array $params = [], array $headers = [], arr
153163
return ResponseMediator::getContent($response);
154164
}
155165

166+
/**
167+
* @param string $uri
168+
* @param array<string,mixed> $params
169+
* @param array<string,string> $headers
170+
* @param array<string,string> $files
171+
*
172+
* @return mixed
173+
*/
174+
protected function patch(string $uri, array $params = [], array $headers = [], array $files = [])
175+
{
176+
if (0 < \count($files)) {
177+
$builder = $this->createMultipartStreamBuilder($params, $files);
178+
$body = self::prepareMultipartBody($builder);
179+
$headers = self::addMultipartContentType($headers, $builder);
180+
} else {
181+
$body = self::prepareJsonBody($params);
182+
183+
if (null !== $body) {
184+
$headers = self::addJsonContentType($headers);
185+
}
186+
}
187+
188+
$response = $this->client->getHttpClient()->patch(self::prepareUri($uri), $headers, $body ?? '');
189+
190+
return ResponseMediator::getContent($response);
191+
}
192+
156193
/**
157194
* @param string $uri
158195
* @param string $file

src/Api/Deployments.php

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class Deployments extends AbstractApi
2323
* @var string $order_by Return deployments ordered by id, iid, created_at, updated_at,
2424
* or ref fields (default is id)
2525
* @var string $sort Return deployments sorted in asc or desc order (default is desc)
26+
* @var string $status Return deployments filtered by status of deployment allowed
27+
* values of status are 'created', 'running', 'success', 'failed',
28+
* 'canceled', 'blocked'
29+
* @var string $environment Return deployments filtered to a particular environment
2630
* }
2731
*
2832
* @return mixed
@@ -36,6 +40,11 @@ public function all($project_id, array $parameters = [])
3640
$resolver->setDefined('sort')
3741
->setAllowedTypes('sort', 'string')
3842
->setAllowedValues('sort', ['desc', 'asc']);
43+
$resolver->setDefined('status')
44+
->setAllowedTypes('status', 'string')
45+
->setAllowedValues('status', ['created', 'running', 'success', 'failed', 'canceled', 'blocked']);
46+
$resolver->setDefined('environment')
47+
->setAllowedTypes('environment', 'string');
3948

4049
return $this->get($this->getProjectPath($project_id, 'deployments'), $resolver->resolve($parameters));
4150
}

src/Api/Environments.php

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function all($project_id, array $parameters = [])
4444
*
4545
* @var string $name The name of the environment
4646
* @var string $external_url Place to link to for this environment
47+
* @var string $tier The tier of the new environment. Allowed values are production, staging, testing, development, and other.
4748
* }
4849
*
4950
* @return mixed
@@ -56,6 +57,8 @@ public function create($project_id, array $parameters = [])
5657
->setAllowedTypes('name', 'string');
5758
$resolver->setDefined('external_url')
5859
->setAllowedTypes('external_url', 'string');
60+
$resolver->setDefined('tier')
61+
->setAllowedValues('tier', ['production', 'staging', 'testing', 'development', 'other']);
5962

6063
return $this->post($this->getProjectPath($project_id, 'environments'), $resolver->resolve($parameters));
6164
}

src/Api/Events.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Gitlab API library.
7+
*
8+
* (c) Niclas Hoyer <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Gitlab\Api;
15+
16+
use Symfony\Component\OptionsResolver\Options;
17+
18+
class Events extends AbstractApi
19+
{
20+
/**
21+
* @param array $parameters {
22+
*
23+
* @var string $action include only events of a particular action type
24+
* @var string $target_type include only events of a particular target type
25+
* @var \DateTimeInterface $before include only events created before a particular date
26+
* @var \DateTimeInterface $after include only events created after a particular date
27+
* @var string $scope include all events across a user’s projects
28+
* @var string $sort sort events in asc or desc order by created_at
29+
*
30+
* }
31+
*
32+
* @return mixed
33+
*/
34+
public function all(array $parameters = [])
35+
{
36+
$resolver = $this->createOptionsResolver();
37+
$datetimeNormalizer = function (Options $resolver, \DateTimeInterface $value): string {
38+
return $value->format('Y-m-d');
39+
};
40+
41+
$resolver->setDefined('action');
42+
$resolver->setDefined('target_type');
43+
$resolver->setDefined('before')
44+
->setAllowedTypes('before', \DateTimeInterface::class)
45+
->setNormalizer('before', $datetimeNormalizer)
46+
;
47+
$resolver->setDefined('after')
48+
->setAllowedTypes('after', \DateTimeInterface::class)
49+
->setNormalizer('after', $datetimeNormalizer)
50+
;
51+
$resolver->setDefined('scope');
52+
$resolver->setDefined('sort');
53+
54+
return $this->get('events', $resolver->resolve($parameters));
55+
}
56+
}

0 commit comments

Comments
 (0)