Skip to content

Commit

Permalink
Merge branch 'v2.x' into release-2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Jan 3, 2024
2 parents 6cef9e4 + c132efc commit ee331a1
Show file tree
Hide file tree
Showing 42 changed files with 762 additions and 45 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:

jobs:
tests:
name: Tests (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
name: Tests (PHP ${{ matrix.php }} on ${{ matrix.operating-system }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ["ubuntu-latest"]
php-versions: ["7.4", "8.0", "8.1", "8.2"]
php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]

steps:
- name: Checkout
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php }}
tools: phpunit
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: xdebug
Expand All @@ -37,14 +37,14 @@ jobs:
uses: "ramsey/composer-install@v2"

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

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

- name: Upload coverage reports to Codecov
if: ${{ success() && matrix.php-versions == '8.2' }}
if: ${{ success() && matrix.php == '8.3' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

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

### Fixed

Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Redmine\Exception;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;

/**
* Listing custom fields.
Expand All @@ -23,13 +24,17 @@ class CustomField extends AbstractApi
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @throws SerializerException if response body could not be converted into array
* @throws UnexpectedResponseException if response body could not be converted into array
*
* @return array list of custom fields found
*/
final public function list(array $params = []): array
{
$this->customFields = $this->retrieveData('/custom_fields.json', $params);
try {
$this->customFields = $this->retrieveData('/custom_fields.json', $params);
} catch (SerializerException $th) {
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
}

return $this->customFields;
}
Expand All @@ -56,6 +61,10 @@ public function all(array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Redmine\Exception;
use Redmine\Exception\MissingParameterException;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Serializer\PathSerializer;
use Redmine\Serializer\XmlSerializer;

Expand All @@ -26,13 +27,17 @@ class Group extends AbstractApi
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @throws SerializerException if response body could not be converted into array
* @throws UnexpectedResponseException if response body could not be converted into array
*
* @return array list of groups found
*/
final public function list(array $params = []): array
{
$this->groups = $this->retrieveData('/groups.json', $params);
try {
$this->groups = $this->retrieveData('/groups.json', $params);
} catch (SerializerException $th) {
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
}

return $this->groups;
}
Expand All @@ -59,6 +64,10 @@ public function all(array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Redmine\Exception;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Serializer\JsonSerializer;
use Redmine\Serializer\PathSerializer;
use Redmine\Serializer\XmlSerializer;
Expand Down Expand Up @@ -40,13 +41,17 @@ class Issue extends AbstractApi
*
* @param array $params the additional parameters (cf available $params above)
*
* @throws SerializerException if response body could not be converted into array
* @throws UnexpectedResponseException if response body could not be converted into array
*
* @return array list of issues found
*/
final public function list(array $params = []): array
{
return $this->retrieveData('/issues.json', $params);
try {
return $this->retrieveData('/issues.json', $params);
} catch (SerializerException $th) {
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
}
}

/**
Expand Down Expand Up @@ -81,6 +86,10 @@ public function all(array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/IssueCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Redmine\Exception\InvalidParameterException;
use Redmine\Exception\MissingParameterException;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Serializer\PathSerializer;
use Redmine\Serializer\XmlSerializer;

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

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

return $this->issueCategories;
}
Expand Down Expand Up @@ -70,6 +75,10 @@ public function all($project, array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/IssuePriority.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Redmine\Exception;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;

/**
* Listing issue priorities.
Expand All @@ -23,13 +24,17 @@ class IssuePriority extends AbstractApi
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @throws SerializerException if response body could not be converted into array
* @throws UnexpectedResponseException if response body could not be converted into array
*
* @return array list of issue priorities found
*/
final public function list(array $params = []): array
{
$this->issuePriorities = $this->retrieveData('/enumerations/issue_priorities.json', $params);
try {
$this->issuePriorities = $this->retrieveData('/enumerations/issue_priorities.json', $params);
} catch (SerializerException $th) {
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
}

return $this->issuePriorities;
}
Expand All @@ -56,6 +61,10 @@ public function all(array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/IssueRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Redmine\Exception;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Serializer\JsonSerializer;

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

return $this->relations;
}
Expand Down Expand Up @@ -59,6 +64,10 @@ public function all($issueId, array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/IssueStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Redmine\Exception;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;

/**
* Listing issue statuses.
Expand All @@ -23,13 +24,17 @@ class IssueStatus extends AbstractApi
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @throws SerializerException if response body could not be converted into array
* @throws UnexpectedResponseException if response body could not be converted into array
*
* @return array list of issue statuses found
*/
final public function list(array $params = []): array
{
$this->issueStatuses = $this->retrieveData('/issue_statuses.json', $params);
try {
$this->issueStatuses = $this->retrieveData('/issue_statuses.json', $params);
} catch (SerializerException $th) {
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
}

return $this->issueStatuses;
}
Expand All @@ -56,6 +61,10 @@ public function all(array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/Redmine/Api/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Redmine\Exception\InvalidParameterException;
use Redmine\Exception\MissingParameterException;
use Redmine\Exception\SerializerException;
use Redmine\Exception\UnexpectedResponseException;
use Redmine\Serializer\XmlSerializer;

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

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

return $this->memberships;
}
Expand Down Expand Up @@ -69,6 +74,10 @@ public function all($project, array $params = [])
return false;
}

if ($e instanceof UnexpectedResponseException && $e->getPrevious() !== null) {
$e = $e->getPrevious();
}

return $e->getMessage();
}
}
Expand Down
Loading

0 comments on commit ee331a1

Please sign in to comment.