Skip to content

Commit cfcaaa0

Browse files
committed
Fix all PHPStan level 6 errors in src folder
1 parent 9b8b71f commit cfcaaa0

22 files changed

+384
-237
lines changed

src/Redmine/Api/AbstractApi.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function lastCallFailed()
108108
* @param string $path
109109
* @param bool $decodeIfJson
110110
*
111-
* @return string|array|SimpleXMLElement|false
111+
* @return string|array<mixed>|SimpleXMLElement|false
112112
*/
113113
protected function get($path, $decodeIfJson = true)
114114
{
@@ -245,7 +245,10 @@ protected function isNotNull($var)
245245
}
246246

247247
/**
248-
* @return array
248+
* @param array<mixed> $defaults
249+
* @param array<mixed> $params
250+
*
251+
* @return array<mixed>
249252
*/
250253
protected function sanitizeParams(array $defaults, array $params)
251254
{
@@ -262,10 +265,10 @@ protected function sanitizeParams(array $defaults, array $params)
262265
* @deprecated v2.2.0 Use `retrieveData()` instead
263266
* @see AbstractApi::retrieveData()
264267
*
265-
* @param string $endpoint API end point
266-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
268+
* @param string $endpoint API end point
269+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
267270
*
268-
* @return array|string|false elements found or error message or false
271+
* @return array<mixed>|string|false elements found or error message or false
269272
*/
270273
protected function retrieveAll($endpoint, array $params = [])
271274
{
@@ -288,12 +291,12 @@ protected function retrieveAll($endpoint, array $params = [])
288291
* Retrieves as many elements as you want of a given endpoint (even if the
289292
* total number of elements is greater than 100).
290293
*
291-
* @param string $endpoint API end point
292-
* @param array $params optional query parameters to be passed to the api (offset, limit, ...)
294+
* @param string $endpoint API end point
295+
* @param array<mixed> $params optional query parameters to be passed to the api (offset, limit, ...)
293296
*
294297
* @throws SerializerException if response body could not be converted into array
295298
*
296-
* @return array elements found
299+
* @return array<mixed> elements found
297300
*/
298301
protected function retrieveData(string $endpoint, array $params = []): array
299302
{
@@ -364,7 +367,7 @@ protected function retrieveData(string $endpoint, array $params = []): array
364367
* @see \Redmine\Serializer\XmlSerializer::createFromArray()
365368
*
366369
* @param SimpleXMLElement $xml XML Element the custom fields are attached to
367-
* @param array $fields array of fields to attach, each field needs name, id and value set
370+
* @param array<mixed> $fields array of fields to attach, each field needs name, id and value set
368371
*
369372
* @return SimpleXMLElement $xml
370373
*
@@ -411,6 +414,8 @@ protected function attachCustomFieldXML(SimpleXMLElement $xml, array $fields)
411414
* returns the last response body as array.
412415
*
413416
* @throws SerializerException if response body could not be converted into array
417+
*
418+
* @return array<mixed>
414419
*/
415420
private function getResponseAsArray(Response $response): array
416421
{
@@ -435,7 +440,7 @@ private function getResponseAsArray(Response $response): array
435440
private function handleClient(Client $client): HttpClient
436441
{
437442
return new class ($client) implements HttpClient {
438-
private $client;
443+
private Client $client;
439444

440445
public function __construct(Client $client)
441446
{

src/Redmine/Api/Attachment.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Redmine\Http\HttpFactory;
88
use Redmine\Serializer\JsonSerializer;
99
use Redmine\Serializer\PathSerializer;
10-
use SimpleXMLElement;
1110

1211
/**
1312
* Attachment details.
@@ -25,7 +24,7 @@ class Attachment extends AbstractApi
2524
*
2625
* @param int $id the attachment number
2726
*
28-
* @return array|false|string information about the attachment as array or false|string on error
27+
* @return array<mixed>|false|string information about the attachment as array or false|string on error
2928
*/
3029
public function show($id)
3130
{
@@ -52,10 +51,10 @@ public function show($id)
5251
*
5352
* @see https://www.redmine.org/projects/redmine/wiki/Rest_Attachments#PATCH
5453
*
55-
* @param int $id the attachment id
56-
* @param array $params available $params:
57-
* - filename: filename of the attachment
58-
* - description: new description of the attachment
54+
* @param int $id the attachment id
55+
* @param array<mixed> $params available $params:
56+
* - filename: filename of the attachment
57+
* - description: new description of the attachment
5958
*
6059
* @throws SerializerException if $params contains invalid values
6160
* @throws UnexpectedResponseException if the Redmine server delivers an unexpected response
@@ -108,8 +107,8 @@ public function download($id)
108107
* available $params :
109108
* - filename: filename of the attachment
110109
*
111-
* @param string $attachment the attachment content
112-
* @param array $params optional parameters to be passed to the api
110+
* @param string $attachment the attachment content
111+
* @param array<mixed> $params optional parameters to be passed to the api
113112
*
114113
* @return string information about the attachment
115114
*/

src/Redmine/Api/CustomField.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@
1515
*/
1616
class CustomField extends AbstractApi
1717
{
18+
/**
19+
* @var array<mixed>
20+
*/
1821
private $customFields = [];
1922

23+
/**
24+
* @var null|array<int,string>
25+
*/
2026
private $customFieldNames = null;
2127

2228
/**
2329
* List custom fields.
2430
*
2531
* @see http://www.redmine.org/projects/redmine/wiki/Rest_CustomFields#GET
2632
*
27-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
33+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
2834
*
2935
* @throws UnexpectedResponseException if response body could not be converted into array
3036
*
31-
* @return array list of custom fields found
37+
* @return array<mixed> list of custom fields found
3238
*/
3339
final public function list(array $params = []): array
3440
{
@@ -71,9 +77,9 @@ final public function listNames(): array
7177
*
7278
* @see http://www.redmine.org/projects/redmine/wiki/Rest_CustomFields#GET
7379
*
74-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
80+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
7581
*
76-
* @return array|string|false list of custom fields found or error message or false
82+
* @return array<mixed>|string|false list of custom fields found or error message or false
7783
*/
7884
public function all(array $params = [])
7985
{
@@ -102,10 +108,10 @@ public function all(array $params = [])
102108
* @deprecated v2.7.0 Use listNames() instead.
103109
* @see CustomField::listNames()
104110
*
105-
* @param bool $forceUpdate to force the update of the custom fields var
106-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
111+
* @param bool $forceUpdate to force the update of the custom fields var
112+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
107113
*
108-
* @return array list of custom fields (id => name)
114+
* @return array<string,int> list of custom fields (name => id)
109115
*/
110116
public function listing($forceUpdate = false, array $params = [])
111117
{
@@ -120,8 +126,8 @@ public function listing($forceUpdate = false, array $params = [])
120126
* @deprecated v2.7.0 Use listNames() instead.
121127
* @see CustomField::listNames()
122128
*
123-
* @param string|int $name customer field name
124-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
129+
* @param string|int $name customer field name
130+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
125131
*
126132
* @return int|false
127133
*/
@@ -138,7 +144,12 @@ public function getIdByName($name, array $params = [])
138144
return $arr[(string) $name];
139145
}
140146

141-
private function doListing(bool $forceUpdate, array $params)
147+
/**
148+
* @param array<mixed> $params
149+
*
150+
* @return array<mixed>
151+
*/
152+
private function doListing(bool $forceUpdate, array $params): array
142153
{
143154
if (empty($this->customFields) || $forceUpdate) {
144155
$this->customFields = $this->list($params);

src/Redmine/Api/Group.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@
2121
*/
2222
class Group extends AbstractApi
2323
{
24+
/**
25+
* @var array<mixed>
26+
*/
2427
private $groups = [];
2528

29+
/**
30+
* @var null|array<int,string>
31+
*/
2632
private $groupNames = null;
2733

2834
/**
2935
* List groups.
3036
*
3137
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Groups#GET
3238
*
33-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
39+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
3440
*
3541
* @throws UnexpectedResponseException if response body could not be converted into array
3642
*
37-
* @return array list of groups found
43+
* @return array<mixed> list of groups found
3844
*/
3945
final public function list(array $params = []): array
4046
{
@@ -73,9 +79,9 @@ final public function listNames(): array
7379
*
7480
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Groups#GET
7581
*
76-
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
82+
* @param array<mixed> $params optional parameters to be passed to the api (offset, limit, ...)
7783
*
78-
* @return array|string|false list of groups found or error message or false
84+
* @return array<mixed>|string|false list of groups found or error message or false
7985
*/
8086
public function all(array $params = [])
8187
{
@@ -106,7 +112,7 @@ public function all(array $params = [])
106112
*
107113
* @param bool $forceUpdate to force the update of the groups var
108114
*
109-
* @return array list of groups (id => name)
115+
* @return array<string,int> list of groups (name => id)
110116
*/
111117
public function listing($forceUpdate = false)
112118
{
@@ -128,7 +134,7 @@ public function listing($forceUpdate = false)
128134
*
129135
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Groups#POST
130136
*
131-
* @param array $params the new group data
137+
* @param array<mixed> $params the new group data
132138
*
133139
* @throws MissingParameterException Missing mandatory parameters
134140
*
@@ -170,7 +176,8 @@ public function create(array $params = [])
170176
*
171177
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Groups#PUT
172178
*
173-
* @param int $id the group id
179+
* @param int $id the group id
180+
* @param array<mixed> $params
174181
*
175182
* @return string empty string
176183
*/
@@ -198,10 +205,10 @@ public function update(int $id, array $params = [])
198205
* available $params :
199206
* - include: a coma separated list of associations to include in the response: users,memberships
200207
*
201-
* @param int $id the group id
202-
* @param array $params params to pass to url
208+
* @param int $id the group id
209+
* @param array<mixed> $params params to pass to url
203210
*
204-
* @return array|false|string information about the group as array or false|string on error
211+
* @return array<mixed>|false|string information about the group as array or false|string on error
205212
*/
206213
public function show($id, array $params = [])
207214
{

src/Redmine/Api/Issue.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ class Issue extends AbstractApi
8787
* - cf_x: get issues with the given value for custom field with an ID of x. (Custom field must have 'used as a filter' checked.)
8888
* - query_id : id of the previously saved query
8989
*
90-
* @param array $params the additional parameters (cf available $params above)
90+
* @param array<mixed> $params the additional parameters (cf available $params above)
9191
*
9292
* @throws UnexpectedResponseException if response body could not be converted into array
9393
*
94-
* @return array list of issues found
94+
* @return array<mixed> list of issues found
9595
*/
9696
final public function list(array $params = []): array
9797
{
@@ -120,9 +120,9 @@ final public function list(array $params = []): array
120120
* - cf_x: get issues with the given value for custom field with an ID of x. (Custom field must have 'used as a filter' checked.)
121121
* - query_id : id of the previously saved query
122122
*
123-
* @param array $params the additional parameters (cf available $params above)
123+
* @param array<mixed> $params the additional parameters (cf available $params above)
124124
*
125-
* @return array|string|false list of issues found or error message or false
125+
* @return array<mixed>|string|false list of issues found or error message or false
126126
*/
127127
public function all(array $params = [])
128128
{
@@ -150,10 +150,10 @@ public function all(array $params = [])
150150
* available $params :
151151
* include: fetch associated data (optional). Possible values: children, attachments, relations, changesets and journals
152152
*
153-
* @param int $id the issue id
154-
* @param array $params extra associated data
153+
* @param int $id the issue id
154+
* @param array<mixed> $params extra associated data
155155
*
156-
* @return array|false|string information about the issue as array or false|string on error
156+
* @return array<mixed>|false|string information about the issue as array or false|string on error
157157
*/
158158
public function show($id, array $params = [])
159159
{
@@ -185,7 +185,7 @@ public function show($id, array $params = [])
185185
*
186186
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Creating-an-issue
187187
*
188-
* @param array $params the new issue data
188+
* @param array<mixed> $params the new issue data
189189
*
190190
* @return string|SimpleXMLElement|false
191191
*/
@@ -234,7 +234,8 @@ public function create(array $params = [])
234234
*
235235
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Updating-an-issue
236236
*
237-
* @param int $id the issue number
237+
* @param int $id the issue number
238+
* @param array<mixed> $params
238239
*
239240
* @return string|SimpleXMLElement|false
240241
*/
@@ -341,9 +342,11 @@ public function addNoteToIssue($id, $note, $privateNote = false)
341342
/**
342343
* Transforms literal identifiers to integer ids.
343344
*
344-
* @return array
345+
* @param array<mixed> $params
346+
*
347+
* @return array<mixed>
345348
*/
346-
private function cleanParams(array $params = [])
349+
private function cleanParams(array $params = []): array
347350
{
348351
if (isset($params['project'])) {
349352
$projectApi = $this->getProjectApi();
@@ -420,8 +423,8 @@ private function cleanParams(array $params = [])
420423
*
421424
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Updating-an-issue
422425
*
423-
* @param int $id the issue number
424-
* @param array $attachment ['token' => '...', 'filename' => '...', 'content_type' => '...']
426+
* @param int $id the issue number
427+
* @param array<mixed> $attachment ['token' => '...', 'filename' => '...', 'content_type' => '...']
425428
*
426429
* @return bool|string
427430
*/
@@ -435,11 +438,11 @@ public function attach($id, array $attachment)
435438
*
436439
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues#Updating-an-issue
437440
*
438-
* @param int $id the issue number
439-
* @param array $attachments [
440-
* ['token' => '...', 'filename' => '...', 'content_type' => '...'],
441-
* ['token' => '...', 'filename' => '...', 'content_type' => '...']
442-
* ]
441+
* @param int $id the issue number
442+
* @param array<mixed> $attachments [
443+
* ['token' => '...', 'filename' => '...', 'content_type' => '...'],
444+
* ['token' => '...', 'filename' => '...', 'content_type' => '...']
445+
* ]
443446
*
444447
* @return bool|string
445448
*/

0 commit comments

Comments
 (0)