Skip to content

Commit f53dab3

Browse files
committed
Prefix all sprintf() calls
1 parent cb1de10 commit f53dab3

36 files changed

+126
-126
lines changed

AmpHttpClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function reset(): void
165165
foreach ($pushedResponses as [$pushedUrl, $pushDeferred]) {
166166
$pushDeferred->fail(new CancelledException());
167167

168-
$this->logger?->debug(sprintf('Unused pushed response: "%s"', $pushedUrl));
168+
$this->logger?->debug(\sprintf('Unused pushed response: "%s"', $pushedUrl));
169169
}
170170
}
171171

CachingHttpClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
array $defaultOptions = [],
4545
) {
4646
if (!class_exists(HttpClientKernel::class)) {
47-
throw new \LogicException(sprintf('Using "%s" requires that the HttpKernel component version 4.3 or higher is installed, try running "composer require symfony/http-kernel:^5.4".', __CLASS__));
47+
throw new \LogicException(\sprintf('Using "%s" requires that the HttpKernel component version 4.3 or higher is installed, try running "composer require symfony/http-kernel:^5.4".', __CLASS__));
4848
}
4949

5050
$kernel = new HttpClientKernel($client);

Chunk/ServerSentEvent.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ public function getArrayData(): array
9696
}
9797

9898
if ('' === $this->data) {
99-
throw new JsonException(sprintf('Server-Sent Event%s data is empty.', '' !== $this->id ? sprintf(' "%s"', $this->id) : ''));
99+
throw new JsonException(\sprintf('Server-Sent Event%s data is empty.', '' !== $this->id ? \sprintf(' "%s"', $this->id) : ''));
100100
}
101101

102102
try {
103103
$jsonData = json_decode($this->data, true, 512, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
104104
} catch (\JsonException $e) {
105-
throw new JsonException(sprintf('Decoding Server-Sent Event%s failed: ', '' !== $this->id ? sprintf(' "%s"', $this->id) : '').$e->getMessage(), $e->getCode());
105+
throw new JsonException(\sprintf('Decoding Server-Sent Event%s failed: ', '' !== $this->id ? \sprintf(' "%s"', $this->id) : '').$e->getMessage(), $e->getCode());
106106
}
107107

108108
if (!\is_array($jsonData)) {
109-
throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned in Server-Sent Event%s.', get_debug_type($jsonData), '' !== $this->id ? sprintf(' "%s"', $this->id) : ''));
109+
throw new JsonException(\sprintf('JSON content was expected to decode to an array, "%s" returned in Server-Sent Event%s.', get_debug_type($jsonData), '' !== $this->id ? \sprintf(' "%s"', $this->id) : ''));
110110
}
111111

112112
return $this->jsonData = $jsonData;

CurlHttpClient.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ public function request(string $method, string $url, array $options = []): Respo
152152
if (\is_array($options['auth_ntlm'])) {
153153
$count = \count($options['auth_ntlm']);
154154
if ($count <= 0 || $count > 2) {
155-
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must contain 1 or 2 elements, %d given.', $count));
155+
throw new InvalidArgumentException(\sprintf('Option "auth_ntlm" must contain 1 or 2 elements, %d given.', $count));
156156
}
157157

158158
$options['auth_ntlm'] = implode(':', $options['auth_ntlm']);
159159
}
160160

161161
if (!\is_string($options['auth_ntlm'])) {
162-
throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', get_debug_type($options['auth_ntlm'])));
162+
throw new InvalidArgumentException(\sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', get_debug_type($options['auth_ntlm'])));
163163
}
164164

165165
$curlopts[\CURLOPT_USERPWD] = $options['auth_ntlm'];
@@ -297,28 +297,28 @@ public function request(string $method, string $url, array $options = []): Respo
297297
unset($multi->pushedResponses[$url]);
298298

299299
if (self::acceptPushForRequest($method, $options, $pushedResponse)) {
300-
$this->logger?->debug(sprintf('Accepting pushed response: "%s %s"', $method, $url));
300+
$this->logger?->debug(\sprintf('Accepting pushed response: "%s %s"', $method, $url));
301301

302302
// Reinitialize the pushed response with request's options
303303
$ch = $pushedResponse->handle;
304304
$pushedResponse = $pushedResponse->response;
305305
$pushedResponse->__construct($multi, $url, $options, $this->logger);
306306
} else {
307-
$this->logger?->debug(sprintf('Rejecting pushed response: "%s"', $url));
307+
$this->logger?->debug(\sprintf('Rejecting pushed response: "%s"', $url));
308308
$pushedResponse = null;
309309
}
310310
}
311311

312312
if (!$pushedResponse) {
313313
$ch = curl_init();
314-
$this->logger?->info(sprintf('Request: "%s %s"', $method, $url));
314+
$this->logger?->info(\sprintf('Request: "%s %s"', $method, $url));
315315
$curlopts += [\CURLOPT_SHARE => $multi->share];
316316
}
317317

318318
foreach ($curlopts as $opt => $value) {
319319
if (null !== $value && !curl_setopt($ch, $opt, $value) && \CURLOPT_CERTINFO !== $opt && (!\defined('CURLOPT_HEADEROPT') || \CURLOPT_HEADEROPT !== $opt)) {
320320
$constantName = $this->findConstantName($opt);
321-
throw new TransportException(sprintf('Curl option "%s" is not supported.', $constantName ?? $opt));
321+
throw new TransportException(\sprintf('Curl option "%s" is not supported.', $constantName ?? $opt));
322322
}
323323
}
324324

@@ -385,7 +385,7 @@ private static function readRequestBody(int $length, \Closure $body, string &$bu
385385
{
386386
if (!$eof && \strlen($buffer) < $length) {
387387
if (!\is_string($data = $body($length))) {
388-
throw new TransportException(sprintf('The return value of the "body" option callback must be a string, "%s" returned.', get_debug_type($data)));
388+
throw new TransportException(\sprintf('The return value of the "body" option callback must be a string, "%s" returned.', get_debug_type($data)));
389389
}
390390

391391
$buffer .= $data;
@@ -551,7 +551,7 @@ private function validateExtraCurlOptions(array $options): void
551551
foreach ($options as $opt => $optValue) {
552552
if (isset($curloptsToConfig[$opt])) {
553553
$constName = $this->findConstantName($opt) ?? $opt;
554-
throw new InvalidArgumentException(sprintf('Cannot set "%s" with "extra.curl", use option "%s" instead.', $constName, $curloptsToConfig[$opt]));
554+
throw new InvalidArgumentException(\sprintf('Cannot set "%s" with "extra.curl", use option "%s" instead.', $constName, $curloptsToConfig[$opt]));
555555
}
556556

557557
if (\in_array($opt, $methodOpts, true)) {
@@ -560,7 +560,7 @@ private function validateExtraCurlOptions(array $options): void
560560

561561
if (\in_array($opt, $curloptsToCheck, true)) {
562562
$constName = $this->findConstantName($opt) ?? $opt;
563-
throw new InvalidArgumentException(sprintf('Cannot set "%s" with "extra.curl".', $constName));
563+
throw new InvalidArgumentException(\sprintf('Cannot set "%s" with "extra.curl".', $constName));
564564
}
565565
}
566566
}

DataCollector/HttpClientDataCollector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ private function getCurlCommand(array $trace): ?string
233233
}
234234

235235
if (preg_match('/^> ([A-Z]+)/', $line, $match)) {
236-
$command[] = sprintf('--request %s', $match[1]);
237-
$command[] = sprintf('--url %s', escapeshellarg($url));
236+
$command[] = \sprintf('--request %s', $match[1]);
237+
$command[] = \sprintf('--url %s', escapeshellarg($url));
238238
continue;
239239
}
240240

EventSourceHttpClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function request(string $method, string $url, array $options = []): Respo
108108
if (preg_match('/^text\/event-stream(;|$)/i', $context->getHeaders()['content-type'][0] ?? '')) {
109109
$state->buffer = '';
110110
} elseif (null !== $lastError || (null !== $state->buffer && 200 === $context->getStatusCode())) {
111-
throw new EventSourceException(sprintf('Response content-type is "%s" while "text/event-stream" was expected for "%s".', $context->getHeaders()['content-type'][0] ?? '', $context->getInfo('url')));
111+
throw new EventSourceException(\sprintf('Response content-type is "%s" while "text/event-stream" was expected for "%s".', $context->getHeaders()['content-type'][0] ?? '', $context->getInfo('url')));
112112
} else {
113113
$context->passthru();
114114
}

Exception/HttpExceptionTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(ResponseInterface $response)
2727
$this->response = $response;
2828
$code = $response->getInfo('http_code');
2929
$url = $response->getInfo('url');
30-
$message = sprintf('HTTP %d returned for "%s".', $code, $url);
30+
$message = \sprintf('HTTP %d returned for "%s".', $code, $url);
3131

3232
$httpCodeFound = false;
3333
$isJson = false;
@@ -37,7 +37,7 @@ public function __construct(ResponseInterface $response)
3737
break;
3838
}
3939

40-
$message = sprintf('%s returned for "%s".', $h, $url);
40+
$message = \sprintf('%s returned for "%s".', $h, $url);
4141
$httpCodeFound = true;
4242
}
4343

0 commit comments

Comments
 (0)