Skip to content

Commit f526c09

Browse files
committed
Prefix all sprintf() calls
1 parent 1a9b119 commit f526c09

16 files changed

+26
-26
lines changed

Data/Bundle/Compiler/GenrbCompiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(string $genrb = 'genrb', string $envVars = '')
3737
exec('which '.$genrb, $output, $status);
3838

3939
if (0 !== $status) {
40-
throw new RuntimeException(sprintf('The command "%s" is not installed.', $genrb));
40+
throw new RuntimeException(\sprintf('The command "%s" is not installed.', $genrb));
4141
}
4242

4343
$this->genrb = ($envVars ? $envVars.' ' : '').$genrb;
@@ -52,7 +52,7 @@ public function compile(string $sourcePath, string $targetDir): void
5252
exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status);
5353

5454
if (0 !== $status) {
55-
throw new RuntimeException(sprintf('genrb failed with status %d while compiling "%s" to "%s".', $status, $sourcePath, $targetDir));
55+
throw new RuntimeException(\sprintf('genrb failed with status %d while compiling "%s" to "%s".', $status, $sourcePath, $targetDir));
5656
}
5757
}
5858
}

Data/Bundle/Reader/BundleEntryReader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function readEntry(string $path, string $locale, array $indices, bool $fa
146146

147147
// Entry is still NULL, read error occurred. Throw an exception
148148
// containing the detailed path and locale
149-
$errorMessage = sprintf(
149+
$errorMessage = \sprintf(
150150
'Couldn\'t read the indices [%s] for the locale "%s" in "%s".',
151151
implode('][', $indices),
152152
$locale,
@@ -158,7 +158,7 @@ public function readEntry(string $path, string $locale, array $indices, bool $fa
158158
// Remove original locale
159159
array_shift($testedLocales);
160160

161-
$errorMessage .= sprintf(
161+
$errorMessage .= \sprintf(
162162
' The indices also couldn\'t be found for the fallback locale(s) "%s".',
163163
implode('", "', $testedLocales)
164164
);

Data/Bundle/Reader/IntlBundleReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function read(string $path, string $locale): mixed
3737
// The bundle is NULL if the path does not look like a resource bundle
3838
// (i.e. contain a bunch of *.res files)
3939
if (null === $bundle) {
40-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.res" could not be found.', $path, $locale));
40+
throw new ResourceBundleNotFoundException(\sprintf('The resource bundle "%s/%s.res" could not be found.', $path, $locale));
4141
}
4242

4343
// Other possible errors are U_USING_FALLBACK_WARNING and U_ZERO_ERROR,

Data/Bundle/Reader/JsonBundleReader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public function read(string $path, string $locale): mixed
2929

3030
// prevent directory traversal attacks
3131
if (\dirname($fileName) !== $path) {
32-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
32+
throw new ResourceBundleNotFoundException(\sprintf('The resource bundle "%s" does not exist.', $fileName));
3333
}
3434

3535
if (!is_file($fileName)) {
36-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
36+
throw new ResourceBundleNotFoundException(\sprintf('The resource bundle "%s" does not exist.', $fileName));
3737
}
3838

3939
$data = json_decode(file_get_contents($fileName), true);
4040

4141
if (null === $data) {
42-
throw new RuntimeException(sprintf('The resource bundle "%s" contains invalid JSON: ', $fileName).json_last_error_msg());
42+
throw new RuntimeException(\sprintf('The resource bundle "%s" contains invalid JSON: ', $fileName).json_last_error_msg());
4343
}
4444

4545
return $data;

Data/Bundle/Reader/PhpBundleReader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function read(string $path, string $locale): mixed
2929

3030
// prevent directory traversal attacks
3131
if (\dirname($fileName) !== $path) {
32-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
32+
throw new ResourceBundleNotFoundException(\sprintf('The resource bundle "%s" does not exist.', $fileName));
3333
}
3434

3535
if (is_file($fileName.'.gz')) {
3636
return GzipStreamWrapper::require($fileName.'.gz');
3737
}
3838

3939
if (!is_file($fileName)) {
40-
throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName));
40+
throw new ResourceBundleNotFoundException(\sprintf('The resource bundle "%s" does not exist.', $fileName));
4141
}
4242

4343
return include $fileName;

Data/Bundle/Writer/PhpBundleWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function write(string $path, string $locale, mixed $data): void
4141
}
4242
});
4343

44-
file_put_contents($path.'/'.$locale.'.php', sprintf($template, VarExporter::export($data)));
44+
file_put_contents($path.'/'.$locale.'.php', \sprintf($template, VarExporter::export($data)));
4545
}
4646
}

Data/Generator/LocaleDataGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private function generateLocaleName(BundleEntryReaderInterface $reader, string $
147147
// i.e. in de_AT, "AT" is the region
148148
if ($region = \Locale::getRegion($locale)) {
149149
if (ctype_alpha($region) && !RegionDataGenerator::isValidCountryCode($region)) {
150-
throw new MissingResourceException(sprintf('Skipping "%s" due an invalid country.', $locale));
150+
throw new MissingResourceException(\sprintf('Skipping "%s" due an invalid country.', $locale));
151151
}
152152

153153
$extras[] = str_replace(['(', ')'], ['[', ']'], $reader->readEntry($tempDir.'/region', $displayLocale, ['Countries', $region]));

Data/Util/RecursiveArrayAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function get(mixed $array, array $indices): mixed
3636
}
3737
}
3838

39-
throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $index));
39+
throw new OutOfBoundsException(\sprintf('The index "%s" does not exist.', $index));
4040
}
4141

4242
return $array;

Data/Util/RingBuffer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function offsetExists(mixed $key): bool
5050
public function offsetGet(mixed $key): mixed
5151
{
5252
if (!isset($this->indices[$key])) {
53-
throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $key));
53+
throw new OutOfBoundsException(\sprintf('The index "%s" does not exist.', $key));
5454
}
5555

5656
return $this->values[$this->indices[$key]];

Exception/UnexpectedTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ class UnexpectedTypeException extends InvalidArgumentException
2020
{
2121
public function __construct(mixed $value, string $expectedType)
2222
{
23-
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value)));
23+
parent::__construct(\sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value)));
2424
}
2525
}

0 commit comments

Comments
 (0)