Skip to content

Commit adfa98a

Browse files
committed
Prefix all sprintf() calls
1 parent 60bc311 commit adfa98a

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

AbstractString.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function containsAny(string|iterable $needle): bool
263263
public function endsWith(string|iterable $suffix): bool
264264
{
265265
if (\is_string($suffix)) {
266-
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
266+
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
267267
}
268268

269269
foreach ($suffix as $s) {
@@ -312,7 +312,7 @@ public function ensureStart(string $prefix): static
312312
public function equalsTo(string|iterable $string): bool
313313
{
314314
if (\is_string($string)) {
315-
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
315+
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
316316
}
317317

318318
foreach ($string as $s) {
@@ -340,7 +340,7 @@ public function ignoreCase(): static
340340
public function indexOf(string|iterable $needle, int $offset = 0): ?int
341341
{
342342
if (\is_string($needle)) {
343-
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
343+
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
344344
}
345345

346346
$i = \PHP_INT_MAX;
@@ -362,7 +362,7 @@ public function indexOf(string|iterable $needle, int $offset = 0): ?int
362362
public function indexOfLast(string|iterable $needle, int $offset = 0): ?int
363363
{
364364
if (\is_string($needle)) {
365-
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
365+
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
366366
}
367367

368368
$i = null;
@@ -414,7 +414,7 @@ abstract public function prepend(string ...$prefix): static;
414414
public function repeat(int $multiplier): static
415415
{
416416
if (0 > $multiplier) {
417-
throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
417+
throw new InvalidArgumentException(\sprintf('Multiplier must be positive, %d given.', $multiplier));
418418
}
419419

420420
$str = clone $this;
@@ -481,7 +481,7 @@ public function split(string $delimiter, ?int $limit = null, ?int $flags = null)
481481
public function startsWith(string|iterable $prefix): bool
482482
{
483483
if (\is_string($prefix)) {
484-
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
484+
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
485485
}
486486

487487
foreach ($prefix as $prefix) {

AbstractUnicodeString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function ascii(array $rules = []): self
124124
}
125125

126126
if (null === $transliterator) {
127-
throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
127+
throw new InvalidArgumentException(\sprintf('Unknown transliteration rule "%s".', $rule));
128128
}
129129

130130
self::$transliterators['any-latin/bgn'] = $transliterator;
@@ -139,7 +139,7 @@ public function ascii(array $rules = []): self
139139
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
140140

141141
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
142-
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
142+
throw new \LogicException(\sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
143143
}
144144

145145
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');

ByteString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(string $string = '')
4646
public static function fromRandom(int $length = 16, ?string $alphabet = null): self
4747
{
4848
if ($length <= 0) {
49-
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
49+
throw new InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length));
5050
}
5151

5252
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
@@ -441,7 +441,7 @@ public function toCodePointString(?string $fromEncoding = null): CodePointString
441441
}
442442

443443
if (!$validEncoding) {
444-
throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
444+
throw new InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
445445
}
446446

447447
$u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');

LazyString.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class LazyString implements \Stringable, \JsonSerializable
2626
public static function fromCallable(callable|array $callback, mixed ...$arguments): static
2727
{
2828
if (\is_array($callback) && !\is_callable($callback) && !(($callback[0] ?? null) instanceof \Closure || 2 < \count($callback))) {
29-
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']'));
29+
throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']'));
3030
}
3131

3232
$lazyString = new static();
@@ -94,7 +94,7 @@ public function __toString(): string
9494
$r = new \ReflectionFunction($this->value);
9595
$callback = $r->getStaticVariables()['callback'];
9696

97-
$e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
97+
$e = new \TypeError(\sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
9898
}
9999

100100
throw $e;

Resources/WcswidthDataGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function write(string $fileName, string $version, array $rawData): void
7171
$content = $this->getHeader($version).'return '.VarExporter::export($this->format($rawData)).";\n";
7272

7373
if (!file_put_contents($this->outDir.'/'.$fileName, $content)) {
74-
throw new RuntimeException(sprintf('The "%s" file could not be written.', $fileName));
74+
throw new RuntimeException(\sprintf('The "%s" file could not be written.', $fileName));
7575
}
7676
}
7777

Slugger/AsciiSlugger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getLocale(): string
9292
public function withEmoji(bool|string $emoji = true): static
9393
{
9494
if (false !== $emoji && !class_exists(EmojiTransliterator::class)) {
95-
throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/emoji" package is not installed. Try running "composer require symfony/emoji".', __METHOD__));
95+
throw new \LogicException(\sprintf('You cannot use the "%s()" method as the "symfony/emoji" package is not installed. Try running "composer require symfony/emoji".', __METHOD__));
9696
}
9797

9898
$new = clone $this;

0 commit comments

Comments
 (0)