Skip to content

Commit 5cd32f5

Browse files
committed
Merge branch 'v2.x' into release-2.4.0
2 parents dae7089 + dd07dd5 commit 5cd32f5

Some content is hidden

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

50 files changed

+353
-365
lines changed

.php-cs-fixer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99

1010
$config = new PhpCsFixer\Config();
1111
return $config->setRules([
12-
'@Symfony' => true,
13-
12+
'@PER-CS2.0' => true,
13+
'@PER-CS2.0:risky' => true,
1414
'array_syntax' => ['syntax' => 'short'],
1515
'linebreak_after_opening_tag' => true,
1616
'ordered_imports' => true,
1717
'phpdoc_order' => true,
1818
])
1919
->setFinder($finder)
20+
->setRiskyAllowed(true)
2021
;

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"psr/http-factory": "^1.0"
3030
},
3131
"require-dev": {
32-
"friendsofphp/php-cs-fixer": "^3",
32+
"friendsofphp/php-cs-fixer": "^3.45",
3333
"phpunit/phpunit": "^9 || ^10.5",
3434
"guzzlehttp/psr7": "^2",
3535
"php-mock/php-mock-phpunit": "^2.6",
@@ -46,6 +46,7 @@
4646
}
4747
},
4848
"scripts": {
49+
"codestyle": "php-cs-fixer fix",
4950
"coverage": "phpunit --coverage-html=\".phpunit.cache/code-coverage\"",
5051
"phpstan": "phpstan analyze --memory-limit 512M --configuration .phpstan.neon",
5152
"test": "phpunit"

src/Redmine/Api.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@
55
/**
66
* api interface.
77
*/
8-
interface Api
9-
{
10-
}
8+
interface Api {}

src/Redmine/Api/AbstractApi.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(Client $client)
3838
*/
3939
public function lastCallFailed()
4040
{
41-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.1.0, use \Redmine\Client\Client::getLastResponseStatusCode() instead.', E_USER_DEPRECATED);
41+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.1.0, use \Redmine\Client\Client::getLastResponseStatusCode() instead.', E_USER_DEPRECATED);
4242

4343
$code = $this->client->getLastResponseStatusCode();
4444

@@ -69,7 +69,7 @@ protected function get($path, $decodeIfJson = true)
6969
try {
7070
return JsonSerializer::createFromString($body)->getNormalized();
7171
} catch (SerializerException $e) {
72-
return 'Error decoding body as JSON: '.$e->getPrevious()->getMessage();
72+
return 'Error decoding body as JSON: ' . $e->getPrevious()->getMessage();
7373
}
7474
}
7575

@@ -174,7 +174,7 @@ protected function sanitizeParams(array $defaults, array $params)
174174
*/
175175
protected function retrieveAll($endpoint, array $params = [])
176176
{
177-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.2.0, use `retrieveData()` instead.', E_USER_DEPRECATED);
177+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.2.0, use `retrieveData()` instead.', E_USER_DEPRECATED);
178178

179179
try {
180180
$data = $this->retrieveData(strval($endpoint), $params);
@@ -242,7 +242,8 @@ protected function retrieveData(string $endpoint, array $params = []): array
242242

243243
$offset += $_limit;
244244

245-
if (empty($newDataSet) || !isset($newDataSet['limit']) || (
245+
if (
246+
empty($newDataSet) || !isset($newDataSet['limit']) || (
246247
isset($newDataSet['offset']) &&
247248
isset($newDataSet['total_count']) &&
248249
$newDataSet['offset'] >= $newDataSet['total_count']
@@ -269,7 +270,7 @@ protected function retrieveData(string $endpoint, array $params = []): array
269270
*/
270271
protected function attachCustomFieldXML(SimpleXMLElement $xml, array $fields)
271272
{
272-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.3.0, use `\Redmine\Serializer\XmlSerializer::createFromArray()` instead.', E_USER_DEPRECATED);
273+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.3.0, use `\Redmine\Serializer\XmlSerializer::createFromArray()` instead.', E_USER_DEPRECATED);
273274

274275
$_fields = $xml->addChild('custom_fields');
275276
$_fields->addAttribute('type', 'array');
@@ -324,7 +325,7 @@ private function getLastResponseBodyAsArray(): array
324325
}
325326

326327
if (!is_array($returnData)) {
327-
throw new SerializerException('Could not convert response body into array: '.$body);
328+
throw new SerializerException('Could not convert response body into array: ' . $body);
328329
}
329330

330331
return $returnData;

src/Redmine/Api/Attachment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Attachment extends AbstractApi
2424
*/
2525
public function show($id)
2626
{
27-
return $this->get('/attachments/'.urlencode($id).'.json');
27+
return $this->get('/attachments/' . urlencode($id) . '.json');
2828
}
2929

3030
/**
@@ -36,7 +36,7 @@ public function show($id)
3636
*/
3737
public function download($id)
3838
{
39-
return $this->get('/attachments/download/'.urlencode($id), false);
39+
return $this->get('/attachments/download/' . urlencode($id), false);
4040
}
4141

4242
/**
@@ -70,6 +70,6 @@ public function upload($attachment, $params = [])
7070
*/
7171
public function remove($id)
7272
{
73-
return $this->delete('/attachments/'.$id.'.xml');
73+
return $this->delete('/attachments/' . $id . '.xml');
7474
}
7575
}

src/Redmine/Api/CustomField.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ class CustomField extends AbstractApi
3131
final public function list(array $params = []): array
3232
{
3333
try {
34-
$this->customFields = $this->retrieveData('/custom_fields.json', $params);
34+
return $this->retrieveData('/custom_fields.json', $params);
3535
} catch (SerializerException $th) {
3636
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
3737
}
38-
39-
return $this->customFields;
4038
}
4139

4240
/**
@@ -52,10 +50,10 @@ final public function list(array $params = []): array
5250
*/
5351
public function all(array $params = [])
5452
{
55-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);
53+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.4.0, use `' . __CLASS__ . '::list()` instead.', E_USER_DEPRECATED);
5654

5755
try {
58-
return $this->list($params);
56+
$this->customFields = $this->list($params);
5957
} catch (Exception $e) {
6058
if ($this->client->getLastResponseBody() === '') {
6159
return false;
@@ -67,6 +65,8 @@ public function all(array $params = [])
6765

6866
return $e->getMessage();
6967
}
68+
69+
return $this->customFields;
7070
}
7171

7272
/**
@@ -80,7 +80,7 @@ public function all(array $params = [])
8080
public function listing($forceUpdate = false, array $params = [])
8181
{
8282
if (empty($this->customFields) || $forceUpdate) {
83-
$this->list($params);
83+
$this->customFields = $this->list($params);
8484
}
8585
$ret = [];
8686
foreach ($this->customFields['custom_fields'] as $e) {

src/Redmine/Api/Group.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ class Group extends AbstractApi
3434
final public function list(array $params = []): array
3535
{
3636
try {
37-
$this->groups = $this->retrieveData('/groups.json', $params);
37+
return $this->retrieveData('/groups.json', $params);
3838
} catch (SerializerException $th) {
3939
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
4040
}
41-
42-
return $this->groups;
4341
}
4442

4543
/**
@@ -55,10 +53,10 @@ final public function list(array $params = []): array
5553
*/
5654
public function all(array $params = [])
5755
{
58-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);
56+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.4.0, use `' . __CLASS__ . '::list()` instead.', E_USER_DEPRECATED);
5957

6058
try {
61-
return $this->list($params);
59+
$this->groups = $this->list($params);
6260
} catch (Exception $e) {
6361
if ($this->client->getLastResponseBody() === '') {
6462
return false;
@@ -70,6 +68,8 @@ public function all(array $params = [])
7068

7169
return $e->getMessage();
7270
}
71+
72+
return $this->groups;
7373
}
7474

7575
/**
@@ -82,7 +82,7 @@ public function all(array $params = [])
8282
public function listing($forceUpdate = false)
8383
{
8484
if (empty($this->groups) || $forceUpdate) {
85-
$this->list();
85+
$this->groups = $this->list();
8686
}
8787
$ret = [];
8888
foreach ($this->groups['groups'] as $e) {
@@ -152,7 +152,7 @@ public function update($id, array $params = [])
152152
public function show($id, array $params = [])
153153
{
154154
return $this->get(
155-
PathSerializer::create('/groups/'.urlencode($id).'.json', $params)->getPath()
155+
PathSerializer::create('/groups/' . urlencode($id) . '.json', $params)->getPath()
156156
);
157157
}
158158

@@ -167,7 +167,7 @@ public function show($id, array $params = [])
167167
*/
168168
public function remove($id)
169169
{
170-
return $this->delete('/groups/'.$id.'.xml');
170+
return $this->delete('/groups/' . $id . '.xml');
171171
}
172172

173173
/**
@@ -183,7 +183,7 @@ public function remove($id)
183183
public function addUser($id, $userId)
184184
{
185185
return $this->post(
186-
'/groups/'.$id.'/users.xml',
186+
'/groups/' . $id . '/users.xml',
187187
XmlSerializer::createFromArray(['user_id' => $userId])->getEncoded()
188188
);
189189
}
@@ -200,6 +200,6 @@ public function addUser($id, $userId)
200200
*/
201201
public function removeUser($id, $userId)
202202
{
203-
return $this->delete('/groups/'.$id.'/users/'.$userId.'.xml');
203+
return $this->delete('/groups/' . $id . '/users/' . $userId . '.xml');
204204
}
205205
}

src/Redmine/Api/Issue.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ final public function list(array $params = []): array
7777
*/
7878
public function all(array $params = [])
7979
{
80-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);
80+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.4.0, use `' . __CLASS__ . '::list()` instead.', E_USER_DEPRECATED);
8181

8282
try {
8383
return $this->list($params);
@@ -113,7 +113,7 @@ public function show($id, array $params = [])
113113
}
114114

115115
return $this->get(
116-
PathSerializer::create('/issues/'.urlencode($id).'.json', $params)->getPath()
116+
PathSerializer::create('/issues/' . urlencode($id) . '.json', $params)->getPath()
117117
);
118118
}
119119

@@ -185,7 +185,7 @@ public function update($id, array $params)
185185
}
186186

187187
return $this->put(
188-
'/issues/'.$id.'.xml',
188+
'/issues/' . $id . '.xml',
189189
XmlSerializer::createFromArray(['issue' => $sanitizedParams])->getEncoded()
190190
);
191191
}
@@ -199,7 +199,7 @@ public function update($id, array $params)
199199
public function addWatcher($id, $watcherUserId)
200200
{
201201
return $this->post(
202-
'/issues/'.$id.'/watchers.xml',
202+
'/issues/' . $id . '/watchers.xml',
203203
XmlSerializer::createFromArray(['user_id' => $watcherUserId])->getEncoded()
204204
);
205205
}
@@ -212,7 +212,7 @@ public function addWatcher($id, $watcherUserId)
212212
*/
213213
public function removeWatcher($id, $watcherUserId)
214214
{
215-
return $this->delete('/issues/'.$id.'/watchers/'.$watcherUserId.'.xml');
215+
return $this->delete('/issues/' . $id . '/watchers/' . $watcherUserId . '.xml');
216216
}
217217

218218
/**
@@ -329,7 +329,7 @@ public function attachMany($id, array $attachments)
329329
];
330330

331331
return $this->put(
332-
'/issues/'.$id.'.json',
332+
'/issues/' . $id . '.json',
333333
JsonSerializer::createFromArray(['issue' => $params])->getEncoded()
334334
);
335335
}
@@ -343,6 +343,6 @@ public function attachMany($id, array $attachments)
343343
*/
344344
public function remove($id)
345345
{
346-
return $this->delete('/issues/'.$id.'.xml');
346+
return $this->delete('/issues/' . $id . '.xml');
347347
}
348348
}

src/Redmine/Api/IssueCategory.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4444
}
4545

4646
try {
47-
$this->issueCategories = $this->retrieveData('/projects/'.strval($projectIdentifier).'/issue_categories.json', $params);
47+
return $this->retrieveData('/projects/' . strval($projectIdentifier) . '/issue_categories.json', $params);
4848
} catch (SerializerException $th) {
4949
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
5050
}
51-
52-
return $this->issueCategories;
5351
}
5452

5553
/**
@@ -66,7 +64,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
6664
*/
6765
public function all($project, array $params = [])
6866
{
69-
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::listByProject()` instead.', E_USER_DEPRECATED);
67+
@trigger_error('`' . __METHOD__ . '()` is deprecated since v2.4.0, use `' . __CLASS__ . '::listByProject()` instead.', E_USER_DEPRECATED);
7068

7169
try {
7270
return $this->listByProject(strval($project), $params);
@@ -94,7 +92,7 @@ public function all($project, array $params = [])
9492
public function listing($project, $forceUpdate = false)
9593
{
9694
if (true === $forceUpdate || empty($this->issueCategories)) {
97-
$this->listByProject($project);
95+
$this->issueCategories = $this->listByProject($project);
9896
}
9997
$ret = [];
10098
foreach ($this->issueCategories['issue_categories'] as $e) {
@@ -133,7 +131,7 @@ public function getIdByName($project, $name)
133131
*/
134132
public function show($id)
135133
{
136-
return $this->get('/issue_categories/'.urlencode($id).'.json');
134+
return $this->get('/issue_categories/' . urlencode($id) . '.json');
137135
}
138136

139137
/**
@@ -163,7 +161,7 @@ public function create($project, array $params = [])
163161
}
164162

165163
return $this->post(
166-
'/projects/'.$project.'/issue_categories.xml',
164+
'/projects/' . $project . '/issue_categories.xml',
167165
XmlSerializer::createFromArray(['issue_category' => $params])->getEncoded()
168166
);
169167
}
@@ -186,7 +184,7 @@ public function update($id, array $params)
186184
$params = $this->sanitizeParams($defaults, $params);
187185

188186
return $this->put(
189-
'/issue_categories/'.$id.'.xml',
187+
'/issue_categories/' . $id . '.xml',
190188
XmlSerializer::createFromArray(['issue_category' => $params])->getEncoded()
191189
);
192190
}
@@ -206,7 +204,7 @@ public function update($id, array $params)
206204
public function remove($id, array $params = [])
207205
{
208206
return $this->delete(
209-
PathSerializer::create('/issue_categories/'.$id.'.xml', $params)->getPath()
207+
PathSerializer::create('/issue_categories/' . $id . '.xml', $params)->getPath()
210208
);
211209
}
212210
}

0 commit comments

Comments
 (0)