Skip to content

Commit dd07dd5

Browse files
authored
Merge pull request #355 from Art4/fix-code-style
Change code style to PER CS 2.0
2 parents 6f0a512 + 6ea5398 commit dd07dd5

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

+278
-286
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final public function list(array $params = []): array
5050
*/
5151
public function all(array $params = [])
5252
{
53-
@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);
5454

5555
try {
5656
$this->customFields = $this->list($params);

src/Redmine/Api/Group.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final public function list(array $params = []): array
5353
*/
5454
public function all(array $params = [])
5555
{
56-
@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);
5757

5858
try {
5959
$this->groups = $this->list($params);
@@ -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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4444
}
4545

4646
try {
47-
return $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
}
@@ -64,7 +64,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
6464
*/
6565
public function all($project, array $params = [])
6666
{
67-
@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);
6868

6969
try {
7070
return $this->listByProject(strval($project), $params);
@@ -131,7 +131,7 @@ public function getIdByName($project, $name)
131131
*/
132132
public function show($id)
133133
{
134-
return $this->get('/issue_categories/'.urlencode($id).'.json');
134+
return $this->get('/issue_categories/' . urlencode($id) . '.json');
135135
}
136136

137137
/**
@@ -161,7 +161,7 @@ public function create($project, array $params = [])
161161
}
162162

163163
return $this->post(
164-
'/projects/'.$project.'/issue_categories.xml',
164+
'/projects/' . $project . '/issue_categories.xml',
165165
XmlSerializer::createFromArray(['issue_category' => $params])->getEncoded()
166166
);
167167
}
@@ -184,7 +184,7 @@ public function update($id, array $params)
184184
$params = $this->sanitizeParams($defaults, $params);
185185

186186
return $this->put(
187-
'/issue_categories/'.$id.'.xml',
187+
'/issue_categories/' . $id . '.xml',
188188
XmlSerializer::createFromArray(['issue_category' => $params])->getEncoded()
189189
);
190190
}
@@ -204,7 +204,7 @@ public function update($id, array $params)
204204
public function remove($id, array $params = [])
205205
{
206206
return $this->delete(
207-
PathSerializer::create('/issue_categories/'.$id.'.xml', $params)->getPath()
207+
PathSerializer::create('/issue_categories/' . $id . '.xml', $params)->getPath()
208208
);
209209
}
210210
}

src/Redmine/Api/IssuePriority.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final public function list(array $params = []): array
5050
*/
5151
public function all(array $params = [])
5252
{
53-
@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);
5454

5555
try {
5656
$this->issuePriorities = $this->list($params);

0 commit comments

Comments
 (0)