8000 Prefix all sprintf() calls · symfony/dotenv@f38d8a3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f38d8a3

Browse files
committed
Prefix all sprintf() calls
1 parent efa715e commit f38d8a3

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

Command/DebugCommand.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8686
$envFiles = $this->getEnvFiles($filePath);
8787
$availableFiles = array_filter($envFiles, 'is_file');
8888

89-
if (\in_array(sprintf('%s.local.php', $filePath), $availableFiles, true)) {
90-
$io->warning(sprintf('Due to existing dump file (%s.local.php) all other dotenv files are skipped.', $this->getRelativeName($filePath)));
89+
if (\in_array(\sprintf('%s.local.php', $filePath), $availableFiles, true)) {
90+
$io->warning(\sprintf('Due to existing dump file (%s.local.php) all other dotenv files are skipped.', $this->getRelativeName($filePath)));
9191
}
9292

93-
if (is_file($filePath) && is_file(sprintf('%s.dist', $filePath))) {
94-
$io->warning(sprintf('The file %s.dist gets skipped due to the existence of %1$s.', $this->getRelativeName($filePath)));
93+
if (is_file($filePath) && is_file(\sprintf('%s.dist', $filePath))) {
94+
$io->warning(\sprintf('The file %s.dist gets skipped due to the existence of %1$s.', $this->getRelativeName($filePath)));
9595
}
9696

9797
$io->section('Scanned Files (in descending priority)');
9898
$io->listing(array_map(fn (string $envFile) => \in_array($envFile, $availableFiles, true)
99-
? sprintf('<fg=green>✓</> %s', $this->getRelativeName($envFile))
100-
: sprintf('<fg=red>⨯</> %s', $this->getRelativeName($envFile)), $envFiles));
99+
? \sprintf('<fg=green>✓</> %s', $this->getRelativeName($envFile))
100+
: \sprintf('<fg=red>⨯</> %s', $this->getRelativeName($envFile)), $envFiles));
101101

102102
$nameFilter = $input->getArgument('filter');
103103
$variables = $this->getVariables($availableFiles, $nameFilter);
@@ -112,7 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112112

113113
$io->comment('Note that values might be different between web and CLI.');
114114
} else {
115-
$io->warning(sprintf('No variables match the given filter "%s".', $nameFilter));
115+
$io->warning(\sprintf('No variables match the given filter "%s".', $nameFilter));
116116
}
117117

118118
return 0;
@@ -176,17 +176,17 @@ private function getAvailableVars(): array
176176
private function getEnvFiles(string $filePath): array
177177
{
178178
$files = [
179-
sprintf('%s.local.php', $filePath),
180-
sprintf('%s.%s.local', $filePath, $this->kernelEnvironment),
181-
sprintf('%s.%s', $filePath, $this->kernelEnvironment),
179+
\sprintf('%s.local.php', $filePath),
180+
\sprintf('%s.%s.local', $filePath, $this->kernelEnvironment),
181+
\sprintf('%s.%s', $filePath, $this->kernelEnvironment),
182182
];
183183

184184
if ('test' !== $this->kernelEnvironment) {
185-
$files[] = sprintf('%s.local', $filePath);
185+
$files[] = \sprintf('%s.local', $filePath);
186186
}
187187

188-
if (!is_file($filePath) && is_file(sprintf('%s.dist', $filePath))) {
189-
$files[] = sprintf('%s.dist', $filePath);
188+
if (!is_file($filePath) && is_file(\sprintf('%s.dist', $filePath))) {
189+
$files[] = \sprintf('%s.dist', $filePath);
190190
} else {
191191
$files[] = $filePath;
192192
}

Command/DotenvDumpCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8484
EOF;
8585
file_put_contents($dotenvPath.'.local.php', $vars, \LOCK_EX);
8686

87-
$output->writeln(sprintf('Successfully dumped .env files in <info>.env.local.php</> for the <info>%s</> environment.', $env));
87+
$output->writeln(\sprintf('Successfully dumped .env files in <info>.env.local.php</> for the <info>%s</> environment.', $env));
8888

8989
return 0;
9090
}

Dotenv.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ private function resolveCommands(string $value, array $loadedVars): string
461461
try {
462462
$process->mustRun();
463463
} catch (ProcessException) {
464-
throw $this->createFormatException(sprintf('Issue expanding a command (%s)', $process->getErrorOutput()));
464+
throw $this->createFormatException(\sprintf('Issue expanding a command (%s)', $process->getErrorOutput()));
465465
}
466466

467467
return rtrim($process->getOutput(), "\n\r");
@@ -516,7 +516,7 @@ private function resolveVariables(string $value, array $loadedVars): string
516516
if ('' === $value && isset($matches['default_value']) && '' !== $matches['default_value']) {
517517
$unsupportedChars = strpbrk($matches['default_value'], '\'"{$');
518518
if (false !== $unsupportedChars) {
519-
throw $this->createFormatException(sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name));
519+
throw $this->createFormatException(\sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name));
520520
}
521521

522522
$value = substr($matches['default_value'], 2);

Exception/FormatException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
int $code = 0,
2525
?\Throwable $previous = null,
2626
) {
27-
parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
27+
parent::__construct(\sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
2828
}
2929

3030
public function getContext(): FormatExceptionContext

Exception/PathException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ final class PathException extends \RuntimeException implements ExceptionInterfac
2020
{
2121
public function __construct(string $path, int $code = 0, ?\Throwable $previous = null)
2222
{
23-
parent::__construct(sprintf('Unable to read the "%s" environment file.', $path), $code, $previous);
23+
parent::__construct(\sprintf('Unable to read the "%s" environment file.', $path), $code, $previous);
2424
}
2525
}

0 commit comments

Comments
 (0)
0