Skip to content

Commit ee331a1

Browse files
committed
Merge branch 'v2.x' into release-2.4.0
2 parents 6cef9e4 + c132efc commit ee331a1

Some content is hidden

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

42 files changed

+762
-45
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ on:
66

77
jobs:
88
tests:
9-
name: Tests (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
9+
name: Tests (PHP ${{ matrix.php }} on ${{ matrix.operating-system }})
1010
runs-on: ubuntu-latest
1111

1212
strategy:
1313
fail-fast: false
1414
matrix:
1515
operating-system: ["ubuntu-latest"]
16-
php-versions: ["7.4", "8.0", "8.1", "8.2"]
16+
php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
1717

1818
steps:
1919
- name: Checkout
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup PHP, with composer and extensions
2727
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
2828
with:
29-
php-version: ${{ matrix.php-versions }}
29+
php-version: ${{ matrix.php }}
3030
tools: phpunit
3131
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
3232
coverage: xdebug
@@ -37,14 +37,14 @@ jobs:
3737
uses: "ramsey/composer-install@v2"
3838

3939
- name: Run static code analysis
40-
if: ${{ matrix.php-versions == '8.2' }}
40+
if: ${{ matrix.php == '8.3' }}
4141
run: composer run phpstan -- --error-format=github
4242

4343
- name: Run tests
4444
run: vendor/bin/phpunit --coverage-clover .phpunit.cache/clover.xml
4545

4646
- name: Upload coverage reports to Codecov
47-
if: ${{ success() && matrix.php-versions == '8.2' }}
47+
if: ${{ success() && matrix.php == '8.3' }}
4848
uses: codecov/codecov-action@v3
4949
with:
5050
token: ${{ secrets.CODECOV_TOKEN }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Added
1313

14+
- Added support for PHP 8.3
1415
- New method `Redmine\Api\CustomField::list()` to list custom fields.
1516
- New method `Redmine\Api\Group::list()` to list groups.
1617
- New method `Redmine\Api\Issue::list()` to list issues.
@@ -31,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3132
- New method `Redmine\Api\User::list()` to list users.
3233
- New method `Redmine\Api\Version::listByProject()` to list versions from a project.
3334
- New method `Redmine\Api\Wiki::listByProject()` to list wiki pages from a project.
35+
- New exception `Redmine\Exception\UnexpectedResponseException` if the Redmine server responded with an unexpected body.
3436

3537
### Fixed
3638

src/Redmine/Api/CustomField.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Exception;
66
use Redmine\Exception\SerializerException;
7+
use Redmine\Exception\UnexpectedResponseException;
78

89
/**
910
* Listing custom fields.
@@ -23,13 +24,17 @@ class CustomField extends AbstractApi
2324
*
2425
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2526
*
26-
* @throws SerializerException if response body could not be converted into array
27+
* @throws UnexpectedResponseException if response body could not be converted into array
2728
*
2829
* @return array list of custom fields found
2930
*/
3031
final public function list(array $params = []): array
3132
{
32-
$this->customFields = $this->retrieveData('/custom_fields.json', $params);
33+
try {
34+
$this->customFields = $this->retrieveData('/custom_fields.json', $params);
35+
} catch (SerializerException $th) {
36+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
37+
}
3338

3439
return $this->customFields;
3540
}
@@ -56,6 +61,10 @@ public function all(array $params = [])
5661
return false;
5762
}
5863

64+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
65+
$e = $e->getPrevious();
66+
}
67+
5968
return $e->getMessage();
6069
}
6170
}

src/Redmine/Api/Group.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Redmine\Exception;
66
use Redmine\Exception\MissingParameterException;
77
use Redmine\Exception\SerializerException;
8+
use Redmine\Exception\UnexpectedResponseException;
89
use Redmine\Serializer\PathSerializer;
910
use Redmine\Serializer\XmlSerializer;
1011

@@ -26,13 +27,17 @@ class Group extends AbstractApi
2627
*
2728
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2829
*
29-
* @throws SerializerException if response body could not be converted into array
30+
* @throws UnexpectedResponseException if response body could not be converted into array
3031
*
3132
* @return array list of groups found
3233
*/
3334
final public function list(array $params = []): array
3435
{
35-
$this->groups = $this->retrieveData('/groups.json', $params);
36+
try {
37+
$this->groups = $this->retrieveData('/groups.json', $params);
38+
} catch (SerializerException $th) {
39+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
40+
}
3641

3742
return $this->groups;
3843
}
@@ -59,6 +64,10 @@ public function all(array $params = [])
5964
return false;
6065
}
6166

67+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
68+
$e = $e->getPrevious();
69+
}
70+
6271
return $e->getMessage();
6372
}
6473
}

src/Redmine/Api/Issue.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Exception;
66
use Redmine\Exception\SerializerException;
7+
use Redmine\Exception\UnexpectedResponseException;
78
use Redmine\Serializer\JsonSerializer;
89
use Redmine\Serializer\PathSerializer;
910
use Redmine\Serializer\XmlSerializer;
@@ -40,13 +41,17 @@ class Issue extends AbstractApi
4041
*
4142
* @param array $params the additional parameters (cf available $params above)
4243
*
43-
* @throws SerializerException if response body could not be converted into array
44+
* @throws UnexpectedResponseException if response body could not be converted into array
4445
*
4546
* @return array list of issues found
4647
*/
4748
final public function list(array $params = []): array
4849
{
49-
return $this->retrieveData('/issues.json', $params);
50+
try {
51+
return $this->retrieveData('/issues.json', $params);
52+
} catch (SerializerException $th) {
53+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
54+
}
5055
}
5156

5257
/**
@@ -81,6 +86,10 @@ public function all(array $params = [])
8186
return false;
8287
}
8388

89+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
90+
$e = $e->getPrevious();
91+
}
92+
8493
return $e->getMessage();
8594
}
8695
}

src/Redmine/Api/IssueCategory.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Redmine\Exception\InvalidParameterException;
77
use Redmine\Exception\MissingParameterException;
88
use Redmine\Exception\SerializerException;
9+
use Redmine\Exception\UnexpectedResponseException;
910
use Redmine\Serializer\PathSerializer;
1011
use Redmine\Serializer\XmlSerializer;
1112

@@ -29,7 +30,7 @@ class IssueCategory extends AbstractApi
2930
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
3031
*
3132
* @throws InvalidParameterException if $projectIdentifier is not of type int or string
32-
* @throws SerializerException if response body could not be converted into array
33+
* @throws UnexpectedResponseException if response body could not be converted into array
3334
*
3435
* @return array list of issue categories found
3536
*/
@@ -42,7 +43,11 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4243
));
4344
}
4445

45-
$this->issueCategories = $this->retrieveData('/projects/'.strval($projectIdentifier).'/issue_categories.json', $params);
46+
try {
47+
$this->issueCategories = $this->retrieveData('/projects/'.strval($projectIdentifier).'/issue_categories.json', $params);
48+
} catch (SerializerException $th) {
49+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
50+
}
4651

4752
return $this->issueCategories;
4853
}
@@ -70,6 +75,10 @@ public function all($project, array $params = [])
7075
return false;
7176
}
7277

78+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
79+
$e = $e->getPrevious();
80+
}
81+
7382
return $e->getMessage();
7483
}
7584
}

src/Redmine/Api/IssuePriority.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Exception;
66
use Redmine\Exception\SerializerException;
7+
use Redmine\Exception\UnexpectedResponseException;
78

89
/**
910
* Listing issue priorities.
@@ -23,13 +24,17 @@ class IssuePriority extends AbstractApi
2324
*
2425
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2526
*
26-
* @throws SerializerException if response body could not be converted into array
27+
* @throws UnexpectedResponseException if response body could not be converted into array
2728
*
2829
* @return array list of issue priorities found
2930
*/
3031
final public function list(array $params = []): array
3132
{
32-
$this->issuePriorities = $this->retrieveData('/enumerations/issue_priorities.json', $params);
33+
try {
34+
$this->issuePriorities = $this->retrieveData('/enumerations/issue_priorities.json', $params);
35+
} catch (SerializerException $th) {
36+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
37+
}
3338

3439
return $this->issuePriorities;
3540
}
@@ -56,6 +61,10 @@ public function all(array $params = [])
5661
return false;
5762
}
5863

64+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
65+
$e = $e->getPrevious();
66+
}
67+
5968
return $e->getMessage();
6069
}
6170
}

src/Redmine/Api/IssueRelation.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Exception;
66
use Redmine\Exception\SerializerException;
7+
use Redmine\Exception\UnexpectedResponseException;
78
use Redmine\Serializer\JsonSerializer;
89

910
/**
@@ -25,13 +26,17 @@ class IssueRelation extends AbstractApi
2526
* @param int $issueId the issue id
2627
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2728
*
28-
* @throws SerializerException if response body could not be converted into array
29+
* @throws UnexpectedResponseException if response body could not be converted into array
2930
*
3031
* @return array list of relations found
3132
*/
3233
final public function listByIssueId(int $issueId, array $params = []): array
3334
{
34-
$this->relations = $this->retrieveData('/issues/'.strval($issueId).'/relations.json', $params);
35+
try {
36+
$this->relations = $this->retrieveData('/issues/'.strval($issueId).'/relations.json', $params);
37+
} catch (SerializerException $th) {
38+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
39+
}
3540

3641
return $this->relations;
3742
}
@@ -59,6 +64,10 @@ public function all($issueId, array $params = [])
5964
return false;
6065
}
6166

67+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
68+
$e = $e->getPrevious();
69+
}
70+
6271
return $e->getMessage();
6372
}
6473
}

src/Redmine/Api/IssueStatus.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Exception;
66
use Redmine\Exception\SerializerException;
7+
use Redmine\Exception\UnexpectedResponseException;
78

89
/**
910
* Listing issue statuses.
@@ -23,13 +24,17 @@ class IssueStatus extends AbstractApi
2324
*
2425
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2526
*
26-
* @throws SerializerException if response body could not be converted into array
27+
* @throws UnexpectedResponseException if response body could not be converted into array
2728
*
2829
* @return array list of issue statuses found
2930
*/
3031
final public function list(array $params = []): array
3132
{
32-
$this->issueStatuses = $this->retrieveData('/issue_statuses.json', $params);
33+
try {
34+
$this->issueStatuses = $this->retrieveData('/issue_statuses.json', $params);
35+
} catch (SerializerException $th) {
36+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
37+
}
3338

3439
return $this->issueStatuses;
3540
}
@@ -56,6 +61,10 @@ public function all(array $params = [])
5661
return false;
5762
}
5863

64+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
65+
$e = $e->getPrevious();
66+
}
67+
5968
return $e->getMessage();
6069
}
6170
}

src/Redmine/Api/Membership.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Redmine\Exception\InvalidParameterException;
77
use Redmine\Exception\MissingParameterException;
88
use Redmine\Exception\SerializerException;
9+
use Redmine\Exception\UnexpectedResponseException;
910
use Redmine\Serializer\XmlSerializer;
1011

1112
/**
@@ -28,7 +29,7 @@ class Membership extends AbstractApi
2829
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
2930
*
3031
* @throws InvalidParameterException if $projectIdentifier is not of type int or string
31-
* @throws SerializerException if response body could not be converted into array
32+
* @throws UnexpectedResponseException if response body could not be converted into array
3233
*
3334
* @return array list of memberships found
3435
*/
@@ -41,7 +42,11 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4142
));
4243
}
4344

44-
$this->memberships = $this->retrieveData('/projects/'.strval($projectIdentifier).'/memberships.json', $params);
45+
try {
46+
$this->memberships = $this->retrieveData('/projects/'.strval($projectIdentifier).'/memberships.json', $params);
47+
} catch (SerializerException $th) {
48+
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
49+
}
4550

4651
return $this->memberships;
4752
}
@@ -69,6 +74,10 @@ public function all($project, array $params = [])
6974
return false;
7075
}
7176

77+
if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
78+
$e = $e->getPrevious();
79+
}
80+
7281
return $e->getMessage();
7382
}
7483
}

0 commit comments

Comments
 (0)