Skip to content

Commit a59a377

Browse files
committed
Prefix all sprintf() calls
1 parent eb07357 commit a59a377

20 files changed

+53
-53
lines changed

Envelope.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function setSender(Address $sender): void
4646
{
4747
// to ensure deliverability of bounce emails independent of UTF-8 capabilities of SMTP servers
4848
if (!preg_match('/^[^@\x80-\xFF]++@/', $sender->getAddress())) {
49-
throw new InvalidArgumentException(sprintf('Invalid sender "%s": non-ASCII characters not supported in local-part of email.', $sender->getAddress()));
49+
throw new InvalidArgumentException(\sprintf('Invalid sender "%s": non-ASCII characters not supported in local-part of email.', $sender->getAddress()));
5050
}
5151
$this->sender = $sender;
5252
}
@@ -72,7 +72,7 @@ public function setRecipients(array $recipients): void
7272
$this->recipients = [];
7373
foreach ($recipients as $recipient) {
7474
if (!$recipient instanceof Address) {
75-
throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, get_debug_type($recipient)));
75+
throw new InvalidArgumentException(\sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, get_debug_type($recipient)));
7676
}
7777
$this->recipients[] = new Address($recipient->getAddress());
7878
}

Event/MessageEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function reject(): void
8181
public function addStamp(StampInterface $stamp): void
8282
{
8383
if (!$this->queued) {
84-
throw new LogicException(sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__));
84+
throw new LogicException(\sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__));
8585
}
8686

8787
$this->stamps[] = $stamp;
@@ -93,7 +93,7 @@ public function addStamp(StampInterface $stamp): void
9393
public function getStamps(): array
9494
{
9595
if (!$this->queued) {
96-
throw new LogicException(sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__));
96+
throw new LogicException(\sprintf('Cannot call "%s()" on a message that is not meant to be queued.', __METHOD__));
9797
}
9898

9999
return $this->stamps;

EventListener/MessageListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(
5454
public function addHeaderRule(string $headerName, int $rule): void
5555
{
5656
if ($rule < 1 || $rule > 3) {
57-
throw new InvalidArgumentException(sprintf('The "%d" rule is not supported.', $rule));
57+
throw new InvalidArgumentException(\sprintf('The "%d" rule is not supported.', $rule));
5858
}
5959

6060
$this->headerRules[strtolower($headerName)] = $rule;
@@ -104,7 +104,7 @@ private function setHeaders(Message $message): void
104104

105105
$h = $headers->get($name);
106106
if (!$h instanceof MailboxListHeader) {
107-
throw new RuntimeException(sprintf('Unable to set header "%s".', $name));
107+
throw new RuntimeException(\sprintf('Unable to set header "%s".', $name));
108108
}
109109

110110
Headers::checkHeaderClass($header);

Exception/UnsupportedSchemeException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public function __construct(Dsn $dsn, ?string $name = null, array $supported = [
8686
}
8787
$package = self::SCHEME_TO_PACKAGE_MAP[$provider] ?? null;
8888
if ($package && !class_exists($package['class'])) {
89-
parent::__construct(sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $provider, $package['package']));
89+
parent::__construct(\sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $provider, $package['package']));
9090

9191
return;
9292
}
9393

94-
$message = sprintf('The "%s" scheme is not supported', $dsn->getScheme());
94+
$message = \sprintf('The "%s" scheme is not supported', $dsn->getScheme());
9595
if ($name && $supported) {
96-
$message .= sprintf('; supported schemes for mailer "%s" are: "%s"', $name, implode('", "', $supported));
96+
$message .= \sprintf('; supported schemes for mailer "%s" are: "%s"', $name, implode('", "', $supported));
9797
}
9898

9999
parent::__construct($message.'.');

Test/Constraint/EmailCount.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(
2525

2626
public function toString(): string
2727
{
28-
return sprintf('%shas %s "%d" emails', $this->transport ? $this->transport.' ' : '', $this->queued ? 'queued' : 'sent', $this->expectedValue);
28+
return \sprintf('%shas %s "%d" emails', $this->transport ? $this->transport.' ' : '', $this->queued ? 'queued' : 'sent', $this->expectedValue);
2929
}
3030

3131
/**
@@ -41,7 +41,7 @@ protected function matches($events): bool
4141
*/
4242
protected function failureDescription($events): string
4343
{
44-
return sprintf('the Transport %s (%d %s)', $this->toString(), $this->countEmails($events), $this->queued ? 'queued' : 'sent');
44+
return \sprintf('the Transport %s (%d %s)', $this->toString(), $this->countEmails($events), $this->queued ? 'queued' : 'sent');
4545
}
4646

4747
private function countEmails(MessageEvents $events): int

Tests/Exception/UnsupportedSchemeExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme,
6464
$dsn = new Dsn($scheme, 'localhost');
6565

6666
$this->assertSame(
67-
sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $scheme, $package),
67+
\sprintf('Unable to send emails via "%s" as the bridge is not installed. Try running "composer require %s".', $scheme, $package),
6868
(new UnsupportedSchemeException($dsn))->getMessage()
6969
);
7070
}

Transport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private function parseDsn(#[\SensitiveParameter] string $dsn, int $offset = 0):
142142
}
143143

144144
if (preg_match('{(\w+)\(}A', $dsn, $matches, 0, $offset)) {
145-
throw new InvalidArgumentException(sprintf('The "%s" keyword is not valid (valid ones are "%s"), ', $matches[1], implode('", "', array_keys($keywords))));
145+
throw new InvalidArgumentException(\sprintf('The "%s" keyword is not valid (valid ones are "%s"), ', $matches[1], implode('", "', array_keys($keywords))));
146146
}
147147

148148
if ($pos = strcspn($dsn, ' )', $offset)) {

Transport/AbstractApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
3131
try {
3232
$email = MessageConverter::toEmail($message->getOriginalMessage());
3333
} catch (\Exception $e) {
34-
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
34+
throw new RuntimeException(\sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
3535
}
3636

3737
return $this->doSendApi($message, $email, $message->getEnvelope());

Transport/AbstractHttpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(
3434
) {
3535
if (null === $client) {
3636
if (!class_exists(HttpClient::class)) {
37-
throw new \LogicException(sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__));
37+
throw new \LogicException(\sprintf('You cannot use "%s" as the HttpClient component is not installed. Try running "composer require symfony/http-client".', __CLASS__));
3838
}
3939

4040
$this->client = HttpClient::create();

Transport/AbstractTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMess
8181
$message = $event->getMessage();
8282

8383
if ($message instanceof TemplatedEmail && !$message->isRendered()) {
84-
throw new LogicException(sprintf('You must configure a "%s" when a "%s" instance has a text or HTML template set.', BodyRendererInterface::class, get_debug_type($message)));
84+
throw new LogicException(\sprintf('You must configure a "%s" when a "%s" instance has a text or HTML template set.', BodyRendererInterface::class, get_debug_type($message)));
8585
}
8686

8787
$sentMessage = new SentMessage($message, $envelope);
@@ -128,7 +128,7 @@ private function checkThrottling(): void
128128

129129
$sleep = (1 / $this->rate) - (microtime(true) - $this->lastSent);
130130
if (0 < $sleep) {
131-
$this->logger->debug(sprintf('Email transport "%s" sleeps for %.2f seconds', __CLASS__, $sleep));
131+
$this->logger->debug(\sprintf('Email transport "%s" sleeps for %.2f seconds', __CLASS__, $sleep));
132132
usleep((int) ($sleep * 1000000));
133133
}
134134
$this->lastSent = microtime(true);

0 commit comments

Comments
 (0)