Skip to content

Commit 4b12c2a

Browse files
Finished off deprecations
1 parent d87415b commit 4b12c2a

File tree

5 files changed

+70
-40
lines changed

5 files changed

+70
-40
lines changed

lib/Gitlab/Api/Issues.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public function addDiscussion($project_id, $issue_iid, $body)
289289
{
290290
// backwards compatibility
291291
if (is_array($body)) {
292+
@trigger_error(sprintf('Passing an array to the $body parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
292293
$params = $body;
293294
} else {
294295
$params = ['body' => $body];
@@ -309,6 +310,7 @@ public function addDiscussionNote($project_id, $issue_iid, $discussion_id, $body
309310
{
310311
// backwards compatibility
311312
if (is_array($body)) {
313+
@trigger_error(sprintf('Passing an array to the $body parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
312314
$params = $body;
313315
} else {
314316
$params = ['body' => $body];

lib/Gitlab/Api/MergeRequests.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,28 @@ public function show($project_id, $mr_iid, $parameters = [])
129129
}
130130

131131
/**
132-
* @param int|string $project_id
133-
* @param string $source
134-
* @param string $target
135-
* @param string $title
136-
* @param int $assignee @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['assignee_id'] instead.
137-
* @param int|string $target_project_id @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['target_project_id'] instead.
138-
* @param string $description @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['description'] instead
139-
* @param array<string,mixed> $parameters {
140-
*
141-
* @var int $assignee_id the assignee id
142-
* @var int|string $target_project_id the target project id
143-
* @var string $description the description
144-
* }
132+
* @param int|string $project_id
133+
* @param string $source
134+
* @param string $target
135+
* @param string $title
136+
* @param int|array<string,mixed> $parameters
137+
* @param int|string $target_project_id @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['target_project_id'] instead.
138+
* @param string $description @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['description'] instead
139+
* @param array<string,mixed>|null $legacyParams @deprecated since version 9.18 and will be removed in 10.0. Use $parameters instead
145140
*
146141
* @return mixed
147142
*/
148-
public function create($project_id, $source, $target, $title, $assignee = null, $target_project_id = null, $description = null, array $parameters = [])
143+
public function create($project_id, $source, $target, $title, $parameters = null, $target_project_id = null, $description = null, array $legacyParams = null)
149144
{
150-
if (null !== $assignee) {
151-
@trigger_error(sprintf('The %s() method\'s $assignee parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters[\'assignee_id\'] instead.', __METHOD__), E_USER_DEPRECATED);
145+
if (is_array($parameters)) {
146+
return $this->post(
147+
$this->getProjectPath($project_id, 'merge_requests'),
148+
$parameters
149+
);
150+
}
151+
152+
if (null !== $parameters) {
153+
@trigger_error(sprintf('Passing the assignee to the %s() method\'s $parameters parameter is deprecated since version 9.18 and will be banned in 10.0. Use $parameters[\'assignee_id\'] instead.', __METHOD__), E_USER_DEPRECATED);
152154
}
153155

154156
if (null !== $target_project_id) {
@@ -159,18 +161,22 @@ public function create($project_id, $source, $target, $title, $assignee = null,
159161
@trigger_error(sprintf('The %s() method\'s $description parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters[\'description\'] instead.', __METHOD__), E_USER_DEPRECATED);
160162
}
161163

164+
if (null !== $legacyParams) {
165+
@trigger_error(sprintf('The %s() method\'s $legacyParams parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters instead.', __METHOD__), E_USER_DEPRECATED);
166+
}
167+
162168
$baseParams = [
163169
'source_branch' => $source,
164170
'target_branch' => $target,
165171
'title' => $title,
166-
'assignee_id' => $assignee,
172+
'assignee_id' => $parameters,
167173
'description' => $description,
168174
'target_project_id' => $target_project_id,
169175
];
170176

171177
return $this->post(
172178
$this->getProjectPath($project_id, 'merge_requests'),
173-
array_merge($baseParams, $parameters)
179+
array_merge($baseParams, $legacyParams === null ? [] : $legacyParams)
174180
);
175181
}
176182

@@ -196,6 +202,7 @@ public function update($project_id, $mr_iid, array $params)
196202
public function merge($project_id, $mr_iid, $message = null)
197203
{
198204
if (is_array($message)) {
205+
@trigger_error(sprintf('Passing an array to the $message parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
199206
$params = $message;
200207
} else {
201208
$params = ['merge_commit_message' => $message];
@@ -372,6 +379,7 @@ public function addDiscussionNote($project_id, $mr_iid, $discussion_id, $body)
372379
{
373380
// backwards compatibility
374381
if (is_array($body)) {
382+
@trigger_error(sprintf('Passing an array to the $message parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
375383
$params = $body;
376384
} else {
377385
$params = ['body' => $body];

lib/Gitlab/Api/Projects.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public function allMembers($project_id, $parameters = [])
384384
public function members($project_id, $parameters = [])
385385
{
386386
if (!is_array($parameters)) {
387-
@trigger_error('Deprecated: String parameter of the members() function is deprecated and will not be allowed in 10.0.', E_USER_NOTICE);
387+
@trigger_error('String parameter of the members() function is deprecated and will not be allowed in 10.0.', E_USER_DEPRECATED);
388388
$username_query = $parameters;
389389
$parameters = [];
390390
if (null !== $username_query && '' !== $username_query) {

lib/Gitlab/Model/Group.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ public function transfer($project_id)
124124
}
125125

126126
/**
127+
* @param string|null $query
128+
*
127129
* @return User[]
128130
*/
129-
public function members()
131+
public function members($query = null)
130132
{
131-
$data = $this->client->groups()->members($this->id);
133+
$data = $this->client->groups()->members($this->id, $query === null ? [] : ['query' => $query]);
132134

133135
$members = [];
134136
foreach ($data as $member) {

lib/Gitlab/Model/Project.php

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ public function remove()
226226
}
227227

228228
/**
229-
* @param string|null $username_query
229+
* @param string|null $query
230230
*
231231
* @return User[]
232232
*/
233-
public function members($username_query = null)
233+
public function members($query = null)
234234
{
235-
$data = $this->client->projects()->members($this->id, ['query' => $username_query]);
235+
$data = $this->client->projects()->members($this->id, $query === null ? [] : ['query' => $query]);
236236

237237
$members = [];
238238
foreach ($data as $member) {
@@ -821,25 +821,43 @@ public function mergeRequest($id)
821821
}
822822

823823
/**
824-
* @param string $source
825-
* @param string $target
826-
* @param string $title
827-
* @param int|null $assignee
828-
* @param string|null $description
824+
* @param string $source
825+
* @param string $target
826+
* @param string $title
827+
* @param int|array|null $parameters
828+
* @param string|null $description @deprecated since version 9.18 and will be removed in 10.0. Use $parameters['description'] instead.
829829
*
830830
* @return MergeRequest
831831
*/
832-
public function createMergeRequest($source, $target, $title, $assignee = null, $description = null)
833-
{
834-
$data = $this->client->mergeRequests()->create(
835-
$this->id,
836-
$source,
837-
$target,
838-
$title,
839-
$assignee,
840-
$this->id,
841-
$description
842-
);
832+
public function createMergeRequest($source, $target, $title, $parameters = null, $description = null)
833+
{
834+
if (is_array($parameters)) {
835+
$parameters['target_project_id'] = $this->id;
836+
837+
$data = $this->client->mergeRequests()->create(
838+
$this->id,
839+
$source,
840+
$target,
841+
$title,
842+
$parameters
843+
);
844+
} else {
845+
if (null !== $parameters) {
846+
@trigger_error(sprintf('Passing the assignee to the %s() method\'s $parameters parameter is deprecated since version 9.18 and will be banned in 10.0. Use $parameters[\'assignee_id\'] instead.', __METHOD__), E_USER_DEPRECATED);
847+
}
848+
849+
if (null !== $description) {
850+
@trigger_error(sprintf('The %s() method\'s $description parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters[\'description\'] instead.', __METHOD__), E_USER_DEPRECATED);
851+
}
852+
853+
$data = $this->client->mergeRequests()->create(
854+
$this->id,
855+
$source,
856+
$target,
857+
$title,
858+
['target_project_id' => $this->id, 'assignee_id' => $parameters, 'description' => $description]
859+
);
860+
}
843861

844862
return MergeRequest::fromArray($this->getClient(), $this, $data);
845863
}

0 commit comments

Comments
 (0)