Skip to content

Commit 33bd9ef

Browse files
committed
cs fixes
1 parent 5333ad8 commit 33bd9ef

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

example.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@
5656
$client->api('project')->show($projectId);
5757
$client->api('project')->getIdByName('Elvis');
5858
$client->api('project')->create(array(
59-
'name' => 'some name',
60-
'identifier' => 'the_identifier',
59+
'name' => 'some name',
60+
'identifier' => 'the_identifier',
61+
'tracker_ids' => array(),
6162
));
6263
$client->api('project')->update($projectId, array(
6364
'name' => 'different name',
@@ -128,6 +129,7 @@
128129
'value' => $_POST['EMAIL'],
129130
),
130131
),
132+
'watcher_user_ids' => array(),
131133
));
132134
$client->api('issue')->update($issueId, array(
133135
// 'subject' => 'test note (xml) 1',
@@ -262,7 +264,8 @@
262264
$client->api('membership')->all($projectId);
263265
$client->api('membership')->create($projectId, array(
264266
'user_id' => null,
265-
'role_ids' => null,
267+
'user_ids' => array(),
268+
'role_ids' => array(),
266269
));
267270
$client->api('membership')->remove($membershipId);
268271

lib/Redmine/Api/AbstractApi.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,16 @@ protected function retrieveAll($endpoint, array $params = array())
118118
}
119119
$params['limit'] = $_limit;
120120
$params['offset'] = $offset;
121+
121122
$newDataSet = (array) $this->get($endpoint . '?' . http_build_query($params));
122123
$ret = array_merge_recursive($ret, $newDataSet);
124+
123125
$offset += $_limit;
124-
// Break if the data set is the last one, as the offset is greater
125-
// than the total count
126-
if (empty($newDataSet)
127-
|| (array_key_exists('offset', $newDataSet)
128-
&& array_key_exists('total_count', $newDataSet)
129-
&& $newDataSet['offset'] >= $newDataSet['total_count'])
126+
if (empty($newDataSet) || (
127+
isset($newDataSet['offset']) &&
128+
isset($newDataSet['total_count']) &&
129+
$newDataSet['offset'] >= $newDataSet['total_count']
130+
)
130131
) {
131132
$limit = 0;
132133
}
@@ -143,15 +144,17 @@ protected function retrieveAll($endpoint, array $params = array())
143144
* @return $xml Element
144145
* @see http://www.redmine.org/projects/redmine/wiki/Rest_api#Working-with-custom-fields
145146
*/
146-
protected function attachCustomFieldXML($xml, $fields)
147+
protected function attachCustomFieldXML(SimpleXMLElement $xml, $fields)
147148
{
148-
$fieldsXML = $xml->addChild('custom_fields');
149-
$fieldsXML->addAttribute('type', 'array');
149+
$fields = $xml->addChild('custom_fields');
150+
$fields->addAttribute('type', 'array');
150151
foreach ($fields as $field) {
151-
$fieldXML = $fieldsXML->addChild('custom_field');
152-
$fieldXML->addAttribute('name', $field['name']);
153-
$fieldXML->addAttribute('id', $field['id']);
154-
$fieldXML->addChild('value', $field['value']);
152+
$field = $fields->addChild('custom_field');
153+
if (isset($field['name'])) {
154+
$field->addAttribute('name', $field['name']);
155+
}
156+
$field->addAttribute('id', $field['id']);
157+
$field->addChild('value', $field['value']);
155158
}
156159

157160
return $xml;

lib/Redmine/Api/Issue.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ private function buildXML(array $params = array())
6464

6565
foreach ($params as $k => $v) {
6666
if ('custom_fields' === $k && is_array($v)) {
67-
$custom_fields_item = $xml->addChild('custom_fields', '');
68-
$custom_fields_item->addAttribute('type', 'array');
69-
foreach ($v as $field) {
70-
$item = $custom_fields_item->addChild('custom_field', '');
71-
$item->addAttribute('id', (int) $field['id']);
72-
$item->addChild('value', $field['value']);
73-
}
67+
$this->attachCustomFieldXML($xml, $v);
7468
} elseif ('watcher_user_ids' === $k && is_array($v)) {
7569
$watcher_user_ids = $xml->addChild('watcher_user_ids', '');
7670
$watcher_user_ids->addAttribute('type', 'array');

lib/Redmine/Api/Membership.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public function create($project, array $params = array())
4343
'role_ids' => null,
4444
);
4545
$params = array_filter(array_merge($defaults, $params));
46-
if(
47-
(!isset($params['user_ids']) && !isset($params['user_id']))
46+
if((!isset($params['user_ids']) && !isset($params['user_id']))
4847
|| !isset($params['role_ids'])
4948
) {
5049
throw new \Exception('Missing mandatory parameters');

0 commit comments

Comments
 (0)