Skip to content

Commit 661f391

Browse files
Escape global functions with a slash
1 parent fb8bb2f commit 661f391

32 files changed

+144
-144
lines changed

lib/Gitlab/Api/AbstractApi.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(Client $client, StreamFactory $streamFactory = null)
4848
if (null === $streamFactory) {
4949
$this->streamFactory = $client->getStreamFactory();
5050
} else {
51-
@trigger_error(sprintf('The %s() method\'s $streamFactory parameter is deprecated since version 9.18 and will be removed in 10.0.', __METHOD__), E_USER_DEPRECATED);
51+
@\trigger_error(\sprintf('The %s() method\'s $streamFactory parameter is deprecated since version 9.18 and will be removed in 10.0.', __METHOD__), E_USER_DEPRECATED);
5252
$this->streamFactory = $streamFactory;
5353
}
5454
}
@@ -60,7 +60,7 @@ public function __construct(Client $client, StreamFactory $streamFactory = null)
6060
*/
6161
public function configure()
6262
{
63-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0.', __METHOD__), E_USER_DEPRECATED);
63+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0.', __METHOD__), E_USER_DEPRECATED);
6464

6565
return $this;
6666
}
@@ -106,10 +106,10 @@ protected function post($path, array $parameters = [], array $requestHeaders = [
106106
$path = $this->preparePath($path);
107107

108108
$body = null;
109-
if (0 === count($files) && 0 < count($parameters)) {
109+
if (0 === \count($files) && 0 < \count($parameters)) {
110110
$body = $this->prepareBody($parameters);
111111
$requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
112-
} elseif (0 < count($files)) {
112+
} elseif (0 < \count($files)) {
113113
$builder = new MultipartStreamBuilder($this->streamFactory);
114114

115115
foreach ($parameters as $name => $value) {
@@ -121,7 +121,7 @@ protected function post($path, array $parameters = [], array $requestHeaders = [
121121
'headers' => [
122122
'Content-Type' => $this->guessContentType($file),
123123
],
124-
'filename' => basename($file),
124+
'filename' => \basename($file),
125125
]);
126126
}
127127

@@ -147,10 +147,10 @@ protected function put($path, array $parameters = [], array $requestHeaders = []
147147
$path = $this->preparePath($path);
148148

149149
$body = null;
150-
if (0 === count($files) && 0 < count($parameters)) {
150+
if (0 === \count($files) && 0 < \count($parameters)) {
151151
$body = $this->prepareBody($parameters);
152152
$requestHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
153-
} elseif (0 < count($files)) {
153+
} elseif (0 < \count($files)) {
154154
$builder = new MultipartStreamBuilder($this->streamFactory);
155155

156156
foreach ($parameters as $name => $value) {
@@ -162,7 +162,7 @@ protected function put($path, array $parameters = [], array $requestHeaders = []
162162
'headers' => [
163163
'Content-Type' => $this->guessContentType($file),
164164
],
165-
'filename' => basename($file),
165+
'filename' => \basename($file),
166166
]);
167167
}
168168

@@ -220,9 +220,9 @@ protected function getGroupPath($id, $path)
220220
*/
221221
protected function encodePath($path)
222222
{
223-
$path = rawurlencode((string) $path);
223+
$path = \rawurlencode((string) $path);
224224

225-
return str_replace('.', '%2E', $path);
225+
return \str_replace('.', '%2E', $path);
226226
}
227227

228228
/**
@@ -256,7 +256,7 @@ protected function createOptionsResolver()
256256
*/
257257
private function prepareBody(array $parameters = [])
258258
{
259-
$parameters = array_filter($parameters, function ($value) {
259+
$parameters = \array_filter($parameters, function ($value) {
260260
return null !== $value;
261261
});
262262

@@ -273,11 +273,11 @@ private function prepareBody(array $parameters = [])
273273
*/
274274
private function preparePath($path, array $parameters = [])
275275
{
276-
$parameters = array_filter($parameters, function ($value) {
276+
$parameters = \array_filter($parameters, function ($value) {
277277
return null !== $value;
278278
});
279279

280-
if (count($parameters) > 0) {
280+
if (\count($parameters) > 0) {
281281
$path .= '?'.QueryStringBuilder::build($parameters);
282282
}
283283

@@ -291,7 +291,7 @@ private function preparePath($path, array $parameters = [])
291291
*/
292292
private function guessContentType($file)
293293
{
294-
if (!class_exists(\finfo::class, false)) {
294+
if (!\class_exists(\finfo::class, false)) {
295295
return 'application/octet-stream';
296296
}
297297

@@ -319,17 +319,17 @@ private function guessContentType($file)
319319
private static function tryFopen($filename, $mode)
320320
{
321321
$ex = null;
322-
set_error_handler(function () use ($filename, $mode, &$ex) {
323-
$ex = new RuntimeException(sprintf(
322+
\set_error_handler(function () use ($filename, $mode, &$ex) {
323+
$ex = new RuntimeException(\sprintf(
324324
'Unable to open %s using mode %s: %s',
325325
$filename,
326326
$mode,
327-
func_get_args()[1]
327+
\func_get_args()[1]
328328
));
329329
});
330330

331-
$handle = fopen($filename, $mode);
332-
restore_error_handler();
331+
$handle = \fopen($filename, $mode);
332+
\restore_error_handler();
333333

334334
if (null !== $ex) {
335335
throw $ex;

lib/Gitlab/Api/Groups.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function create($name, $path, $description = null, $visibility = 'private
6363
'shared_runners_minutes_limit' => $shared_runners_minutes_limit,
6464
];
6565

66-
return $this->post('groups', array_filter($params, function ($value) {
67-
return null !== $value && (!is_string($value) || strlen($value) > 0);
66+
return $this->post('groups', \array_filter($params, function ($value) {
67+
return null !== $value && (!\is_string($value) || \strlen($value) > 0);
6868
}));
6969
}
7070

@@ -422,7 +422,7 @@ private function getGroupSearchResolver()
422422
$resolver->setDefined('skip_groups')
423423
->setAllowedTypes('skip_groups', 'array')
424424
->setAllowedValues('skip_groups', function (array $value) {
425-
return count($value) === count(array_filter($value, 'is_int'));
425+
return \count($value) === \count(\array_filter($value, 'is_int'));
426426
})
427427
;
428428
$resolver->setDefined('all_available')

lib/Gitlab/Api/GroupsMilestones.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function all($group_id, array $parameters = [])
2525
$resolver->setDefined('iids')
2626
->setAllowedTypes('iids', 'array')
2727
->setAllowedValues('iids', function (array $value) {
28-
return count($value) === count(array_filter($value, 'is_int'));
28+
return \count($value) === \count(\array_filter($value, 'is_int'));
2929
})
3030
;
3131
$resolver->setDefined('state')

lib/Gitlab/Api/Issues.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function removeNote($project_id, $issue_iid, $note_id)
181181
*/
182182
public function showComments($project_id, $issue_iid)
183183
{
184-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);
184+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);
185185

186186
return $this->showNotes($project_id, $issue_iid);
187187
}
@@ -197,7 +197,7 @@ public function showComments($project_id, $issue_iid)
197197
*/
198198
public function showComment($project_id, $issue_iid, $note_id)
199199
{
200-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the showNote() method instead.', __METHOD__), E_USER_DEPRECATED);
200+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the showNote() method instead.', __METHOD__), E_USER_DEPRECATED);
201201

202202
return $this->showNote($project_id, $issue_iid, $note_id);
203203
}
@@ -213,9 +213,9 @@ public function showComment($project_id, $issue_iid, $note_id)
213213
*/
214214
public function addComment($project_id, $issue_iid, $body)
215215
{
216-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);
216+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);
217217

218-
if (is_array($body)) {
218+
if (\is_array($body)) {
219219
return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/notes'), $body);
220220
}
221221

@@ -234,7 +234,7 @@ public function addComment($project_id, $issue_iid, $body)
234234
*/
235235
public function updateComment($project_id, $issue_iid, $note_id, $body)
236236
{
237-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the updateNote() method instead.', __METHOD__), E_USER_DEPRECATED);
237+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the updateNote() method instead.', __METHOD__), E_USER_DEPRECATED);
238238

239239
return $this->updateNote($project_id, $issue_iid, $note_id, $body);
240240
}
@@ -250,7 +250,7 @@ public function updateComment($project_id, $issue_iid, $note_id, $body)
250250
*/
251251
public function removeComment($project_id, $issue_iid, $note_id)
252252
{
253-
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the removeNote() method instead.', __METHOD__), E_USER_DEPRECATED);
253+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0. Use the removeNote() method instead.', __METHOD__), E_USER_DEPRECATED);
254254

255255
return $this->removeNote($project_id, $issue_iid, $note_id);
256256
}
@@ -288,8 +288,8 @@ public function showDiscussion($project_id, $issue_iid, $discussion_id)
288288
public function addDiscussion($project_id, $issue_iid, $body)
289289
{
290290
// backwards compatibility
291-
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);
291+
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);
293293
$params = $body;
294294
} else {
295295
$params = ['body' => $body];
@@ -309,8 +309,8 @@ public function addDiscussion($project_id, $issue_iid, $body)
309309
public function addDiscussionNote($project_id, $issue_iid, $discussion_id, $body)
310310
{
311311
// backwards compatibility
312-
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);
312+
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);
314314
$params = $body;
315315
} else {
316316
$params = ['body' => $body];
@@ -515,7 +515,7 @@ protected function createOptionsResolver()
515515
$resolver->setDefined('iids')
516516
->setAllowedTypes('iids', 'array')
517517
->setAllowedValues('iids', function (array $value) {
518-
return count($value) === count(array_filter($value, 'is_int'));
518+
return \count($value) === \count(\array_filter($value, 'is_int'));
519519
})
520520
;
521521
$resolver->setDefined('scope')

lib/Gitlab/Api/Jobs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function createOptionsResolver()
199199
->setAllowedTypes('scope', ['string', 'array'])
200200
->setAllowedValues('scope', $allowedScopeValues)
201201
->addAllowedValues('scope', function ($value) use ($allowedScopeValues) {
202-
return is_array($value) && 0 === count(array_diff($value, $allowedScopeValues));
202+
return \is_array($value) && 0 === \count(\array_diff($value, $allowedScopeValues));
203203
})
204204
->setNormalizer('scope', function (OptionsResolver $resolver, $value) {
205205
return (array) $value;

lib/Gitlab/Api/MergeRequests.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function all($project_id = null, array $parameters = [])
4848
$resolver->setDefined('iids')
4949
->setAllowedTypes('iids', 'array')
5050
->setAllowedValues('iids', function (array $value) {
51-
return count($value) === count(array_filter($value, 'is_int'));
51+
return \count($value) === \count(\array_filter($value, 'is_int'));
5252
})
5353
;
5454
$resolver->setDefined('state')
@@ -142,27 +142,27 @@ public function show($project_id, $mr_iid, $parameters = [])
142142
*/
143143
public function create($project_id, $source, $target, $title, $parameters = null, $target_project_id = null, $description = null, array $legacyParams = null)
144144
{
145-
if (is_array($parameters)) {
145+
if (\is_array($parameters)) {
146146
return $this->post(
147147
$this->getProjectPath($project_id, 'merge_requests'),
148148
$parameters
149149
);
150150
}
151151

152152
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);
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);
154154
}
155155

156156
if (null !== $target_project_id) {
157-
@trigger_error(sprintf('The %s() method\'s $target_project_id parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters[\'target_project_id\'] instead.', __METHOD__), E_USER_DEPRECATED);
157+
@\trigger_error(\sprintf('The %s() method\'s $target_project_id parameter is deprecated since version 9.18 and will be removed in 10.0. Use $parameters[\'target_project_id\'] instead.', __METHOD__), E_USER_DEPRECATED);
158158
}
159159

160160
if (null !== $description) {
161-
@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);
161+
@\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);
162162
}
163163

164164
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);
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);
166166
}
167167

168168
$baseParams = [
@@ -176,7 +176,7 @@ public function create($project_id, $source, $target, $title, $parameters = null
176176

177177
return $this->post(
178178
$this->getProjectPath($project_id, 'merge_requests'),
179-
array_merge($baseParams, null === $legacyParams ? [] : $legacyParams)
179+
\array_merge($baseParams, null === $legacyParams ? [] : $legacyParams)
180180
);
181181
}
182182

@@ -201,10 +201,10 @@ public function update($project_id, $mr_iid, array $parameters)
201201
*/
202202
public function merge($project_id, $mr_iid, $parameters = null)
203203
{
204-
if (is_array($parameters)) {
204+
if (\is_array($parameters)) {
205205
$params = $parameters;
206206
} else {
207-
@trigger_error(sprintf('Passing a string to the $parameters parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
207+
@\trigger_error(\sprintf('Passing a string to the $parameters parameter of %s() is deprecated since 9.18 and will be banned in 10.0.', __METHOD__), E_USER_DEPRECATED);
208208
$params = ['merge_commit_message' => $parameters];
209209
}
210210

@@ -245,7 +245,7 @@ public function showNote($project_id, $mr_iid, $note_id)
245245
public function addNote($project_id, $mr_iid, $body, $created_at = null)
246246
{
247247
if (null !== $created_at) {
248-
@trigger_error(sprintf('The %s() method\'s $created_at parameter is deprecated since version 9.18 and will be removed in 10.0. There is no replacement as this parameter was removed by GitLab.', __METHOD__), E_USER_DEPRECATED);
248+
@\trigger_error(\sprintf('The %s() method\'s $created_at parameter is deprecated since version 9.18 and will be removed in 10.0. There is no replacement as this parameter was removed by GitLab.', __METHOD__), E_USER_DEPRECATED);
249249

250250
return $this->post($this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/notes'), [
251251
'body' => $body,
@@ -295,7 +295,7 @@ public function removeNote($project_id, $mr_iid, $note_id)
295295
*/
296296
public function showComments($project_id, $mr_iid)
297297
{
298-
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);
298+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED);
299299

300300
return $this->showNotes($project_id, $mr_iid);
301301
}
@@ -312,7 +312,7 @@ public function showComments($project_id, $mr_iid)
312312
*/
313313
public function addComment($project_id, $mr_iid, $note, $created_at = null)
314314
{
315-
@trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);
315+
@\trigger_error(\sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED);
316316

317317
return $this->addNote($project_id, $mr_iid, $note, $created_at);
318318
}
@@ -378,8 +378,8 @@ public function resolveDiscussion($project_id, $mr_iid, $discussion_id, $resolve
378378
public function addDiscussionNote($project_id, $mr_iid, $discussion_id, $body)
379379
{
380380
// backwards compatibility
381-
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);
381+
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);
383383
$params = $body;
384384
} else {
385385
$params = ['body' => $body];
@@ -560,7 +560,7 @@ public function createLevelRule($project_id, $mr_iid, $name, $approvals_required
560560

561561
return $this->post(
562562
$this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/approval_rules'),
563-
array_merge($baseParam, $parameters)
563+
\array_merge($baseParam, $parameters)
564564
);
565565
}
566566

@@ -583,7 +583,7 @@ public function updateLevelRule($project_id, $mr_iid, $approval_rule_id, $name,
583583

584584
return $this->put(
585585
$this->getProjectPath($project_id, 'merge_requests/'.$this->encodePath($mr_iid).'/approval_rules/'.$this->encodePath($approval_rule_id)),
586-
array_merge($baseParam, $parameters)
586+
\array_merge($baseParam, $parameters)
587587
);
588588
}
589589

0 commit comments

Comments
 (0)