diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index 0315b77..b461c01 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -85,7 +85,7 @@ EOT $dotenvPath = $this->projectDirectory; if (is_file($composerFile = $this->projectDirectory.'/composer.json')) { - $runtimeConfig = (json_decode(file_get_contents($composerFile), true))['extra']['runtime'] ?? []; + $runtimeConfig = json_decode(file_get_contents($composerFile), true)['extra']['runtime'] ?? []; if (isset($runtimeConfig['dotenv_path'])) { $dotenvPath = $this->projectDirectory.'/'.$runtimeConfig['dotenv_path']; @@ -98,18 +98,18 @@ EOT $envFiles = $this->getEnvFiles($filePath); $availableFiles = array_filter($envFiles, 'is_file'); - if (\in_array(sprintf('%s.local.php', $filePath), $availableFiles, true)) { - $io->warning(sprintf('Due to existing dump file (%s.local.php) all other dotenv files are skipped.', $this->getRelativeName($filePath))); + if (\in_array(\sprintf('%s.local.php', $filePath), $availableFiles, true)) { + $io->warning(\sprintf('Due to existing dump file (%s.local.php) all other dotenv files are skipped.', $this->getRelativeName($filePath))); } - if (is_file($filePath) && is_file(sprintf('%s.dist', $filePath))) { - $io->warning(sprintf('The file %s.dist gets skipped due to the existence of %1$s.', $this->getRelativeName($filePath))); + if (is_file($filePath) && is_file(\sprintf('%s.dist', $filePath))) { + $io->warning(\sprintf('The file %s.dist gets skipped due to the existence of %1$s.', $this->getRelativeName($filePath))); } $io->section('Scanned Files (in descending priority)'); $io->listing(array_map(fn (string $envFile) => \in_array($envFile, $availableFiles, true) - ? sprintf('✓ %s', $this->getRelativeName($envFile)) - : sprintf('⨯ %s', $this->getRelativeName($envFile)), $envFiles)); + ? \sprintf('✓ %s', $this->getRelativeName($envFile)) + : \sprintf('⨯ %s', $this->getRelativeName($envFile)), $envFiles)); $nameFilter = $input->getArgument('filter'); $variables = $this->getVariables($availableFiles, $nameFilter); @@ -124,7 +124,7 @@ EOT $io->comment('Note that values might be different between web and CLI.'); } else { - $io->warning(sprintf('No variables match the given filter "%s".', $nameFilter)); + $io->warning(\sprintf('No variables match the given filter "%s".', $nameFilter)); } return 0; @@ -188,17 +188,17 @@ EOT private function getEnvFiles(string $filePath): array { $files = [ - sprintf('%s.local.php', $filePath), - sprintf('%s.%s.local', $filePath, $this->kernelEnvironment), - sprintf('%s.%s', $filePath, $this->kernelEnvironment), + \sprintf('%s.local.php', $filePath), + \sprintf('%s.%s.local', $filePath, $this->kernelEnvironment), + \sprintf('%s.%s', $filePath, $this->kernelEnvironment), ]; if ('test' !== $this->kernelEnvironment) { - $files[] = sprintf('%s.local', $filePath); + $files[] = \sprintf('%s.local', $filePath); } - if (!is_file($filePath) && is_file(sprintf('%s.dist', $filePath))) { - $files[] = sprintf('%s.dist', $filePath); + if (!is_file($filePath) && is_file(\sprintf('%s.dist', $filePath))) { + $files[] = \sprintf('%s.dist', $filePath); } else { $files[] = $filePath; } diff --git a/Command/DotenvDumpCommand.php b/Command/DotenvDumpCommand.php index cd0fb5d..49495b7 100644 --- a/Command/DotenvDumpCommand.php +++ b/Command/DotenvDumpCommand.php @@ -88,7 +88,7 @@ return $vars; EOF; file_put_contents($dotenvPath.'.local.php', $vars, \LOCK_EX); - $output->writeln(sprintf('Successfully dumped .env files in .env.local.php for the %s environment.', $env)); + $output->writeln(\sprintf('Successfully dumped .env files in .env.local.php for the %s environment.', $env)); return 0; } diff --git a/Dotenv.php b/Dotenv.php index 88bda29..2d72628 100644 --- a/Dotenv.php +++ b/Dotenv.php @@ -460,7 +460,7 @@ final class Dotenv try { $process->mustRun(); } catch (ProcessException) { - throw $this->createFormatException(sprintf('Issue expanding a command (%s)', $process->getErrorOutput())); + throw $this->createFormatException(\sprintf('Issue expanding a command (%s)', $process->getErrorOutput())); } return preg_replace('/[\r\n]+$/', '', $process->getOutput()); @@ -515,7 +515,7 @@ final class Dotenv if ('' === $value && isset($matches['default_value']) && '' !== $matches['default_value']) { $unsupportedChars = strpbrk($matches['default_value'], '\'"{$'); if (false !== $unsupportedChars) { - throw $this->createFormatException(sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name)); + throw $this->createFormatException(\sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name)); } $value = substr($matches['default_value'], 2); diff --git a/Exception/FormatException.php b/Exception/FormatException.php index 684d98c..c2866d8 100644 --- a/Exception/FormatException.php +++ b/Exception/FormatException.php @@ -24,7 +24,7 @@ final class FormatException extends \LogicException implements ExceptionInterfac { $this->context = $context; - parent::__construct(sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous); + parent::__construct(\sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous); } public function getContext(): FormatExceptionContext diff --git a/Exception/PathException.php b/Exception/PathException.php index e432b2e..568b009 100644 --- a/Exception/PathException.php +++ b/Exception/PathException.php @@ -20,6 +20,6 @@ final class PathException extends \RuntimeException implements ExceptionInterfac { public function __construct(string $path, int $code = 0, ?\Throwable $previous = null) { - parent::__construct(sprintf('Unable to read the "%s" environment file.', $path), $code, $previous); + parent::__construct(\sprintf('Unable to read the "%s" environment file.', $path), $code, $previous); } }