diff --git a/Application.php b/Application.php
index 87eb7a6c..aa4af5c5 100644
--- a/Application.php
+++ b/Application.php
@@ -262,9 +262,9 @@ class Application implements ResetInterface
$style = new SymfonyStyle($input, $output);
$output->writeln('');
- $formattedBlock = (new FormatterHelper())->formatBlock(sprintf('Command "%s" is not defined.', $name), 'error', true);
+ $formattedBlock = (new FormatterHelper())->formatBlock(\sprintf('Command "%s" is not defined.', $name), 'error', true);
$output->writeln($formattedBlock);
- if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
+ if (!$style->confirm(\sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
if (null !== $this->dispatcher) {
$event = new ConsoleErrorEvent($input, $output, $e);
$this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
@@ -475,7 +475,7 @@ class Application implements ResetInterface
{
if ('UNKNOWN' !== $this->getName()) {
if ('UNKNOWN' !== $this->getVersion()) {
- return sprintf('%s %s', $this->getName(), $this->getVersion());
+ return \sprintf('%s %s', $this->getName(), $this->getVersion());
}
return $this->getName();
@@ -530,7 +530,7 @@ class Application implements ResetInterface
}
if (!$command->getName()) {
- throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
+ throw new LogicException(\sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
}
$this->commands[$command->getName()] = $command;
@@ -552,12 +552,12 @@ class Application implements ResetInterface
$this->init();
if (!$this->has($name)) {
- throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
+ throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
}
// When the command has a different name than the one used at the command loader level
if (!isset($this->commands[$name])) {
- throw new CommandNotFoundException(sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
+ throw new CommandNotFoundException(\sprintf('The "%s" command cannot be found because it is registered under multiple names. Make sure you don\'t set a different name via constructor or "setName()".', $name));
}
$command = $this->commands[$name];
@@ -621,7 +621,7 @@ class Application implements ResetInterface
$namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
if (!$namespaces) {
- $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
+ $message = \sprintf('There are no commands defined in the "%s" namespace.', $namespace);
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
if (1 == \count($alternatives)) {
@@ -638,7 +638,7 @@ class Application implements ResetInterface
$exact = \in_array($namespace, $namespaces, true);
if (\count($namespaces) > 1 && !$exact) {
- throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
+ throw new NamespaceNotFoundException(\sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
}
return $exact ? $namespace : reset($namespaces);
@@ -685,7 +685,7 @@ class Application implements ResetInterface
$this->findNamespace(substr($name, 0, $pos));
}
- $message = sprintf('Command "%s" is not defined.', $name);
+ $message = \sprintf('Command "%s" is not defined.', $name);
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
// remove hidden commands
@@ -740,14 +740,14 @@ class Application implements ResetInterface
if (\count($commands) > 1) {
$suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));
- throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
+ throw new CommandNotFoundException(\sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
}
}
$command = $this->get(reset($commands));
if ($command->isHidden()) {
- throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
+ throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
}
return $command;
@@ -822,7 +822,7 @@ class Application implements ResetInterface
$this->doRenderThrowable($e, $output);
if (null !== $this->runningCommand) {
- $output->writeln(sprintf('%s', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
+ $output->writeln(\sprintf('%s', OutputFormatter::escape(\sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
}
}
@@ -833,7 +833,7 @@ class Application implements ResetInterface
$message = trim($e->getMessage());
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
$class = get_debug_type($e);
- $title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
+ $title = \sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
$len = Helper::width($title);
} else {
$len = 0;
@@ -857,14 +857,14 @@ class Application implements ResetInterface
$messages = [];
if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
- $messages[] = sprintf('%s', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
+ $messages[] = \sprintf('%s', OutputFormatter::escape(\sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
}
- $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len));
+ $messages[] = $emptyLine = \sprintf('%s', str_repeat(' ', $len));
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
- $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
+ $messages[] = \sprintf('%s%s', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
}
foreach ($lines as $line) {
- $messages[] = sprintf(' %s %s', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
+ $messages[] = \sprintf(' %s %s', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
}
$messages[] = $emptyLine;
$messages[] = '';
@@ -891,7 +891,7 @@ class Application implements ResetInterface
$file = $trace[$i]['file'] ?? 'n/a';
$line = $trace[$i]['line'] ?? 'n/a';
- $output->writeln(sprintf(' %s%s at %s:%s', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
+ $output->writeln(\sprintf(' %s%s at %s:%s', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
}
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
diff --git a/CI/GithubActionReporter.php b/CI/GithubActionReporter.php
index 2cae6fd8..28112c2a 100644
--- a/CI/GithubActionReporter.php
+++ b/CI/GithubActionReporter.php
@@ -89,11 +89,11 @@ class GithubActionReporter
if (!$file) {
// No file provided, output the message solely:
- $this->output->writeln(sprintf('::%s::%s', $type, $message));
+ $this->output->writeln(\sprintf('::%s::%s', $type, $message));
return;
}
- $this->output->writeln(sprintf('::%s file=%s,line=%s,col=%s::%s', $type, strtr($file, self::ESCAPED_PROPERTIES), strtr($line ?? 1, self::ESCAPED_PROPERTIES), strtr($col ?? 0, self::ESCAPED_PROPERTIES), $message));
+ $this->output->writeln(\sprintf('::%s file=%s,line=%s,col=%s::%s', $type, strtr($file, self::ESCAPED_PROPERTIES), strtr($line ?? 1, self::ESCAPED_PROPERTIES), strtr($col ?? 0, self::ESCAPED_PROPERTIES), $message));
}
}
diff --git a/Color.php b/Color.php
index 60ed046a..b1914c19 100644
--- a/Color.php
+++ b/Color.php
@@ -60,7 +60,7 @@ final class Color
foreach ($options as $option) {
if (!isset(self::AVAILABLE_OPTIONS[$option])) {
- throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
+ throw new InvalidArgumentException(\sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
}
$this->options[$option] = self::AVAILABLE_OPTIONS[$option];
@@ -88,7 +88,7 @@ final class Color
return '';
}
- return sprintf("\033[%sm", implode(';', $setCodes));
+ return \sprintf("\033[%sm", implode(';', $setCodes));
}
public function unset(): string
@@ -107,7 +107,7 @@ final class Color
return '';
}
- return sprintf("\033[%sm", implode(';', $unsetCodes));
+ return \sprintf("\033[%sm", implode(';', $unsetCodes));
}
private function parseColor(string $color, bool $background = false): string
@@ -128,6 +128,6 @@ final class Color
return ($background ? '10' : '9').self::BRIGHT_COLORS[$color];
}
- throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
+ throw new InvalidArgumentException(\sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
}
}
diff --git a/Command/Command.php b/Command/Command.php
index 03da6db4..244a419f 100644
--- a/Command/Command.php
+++ b/Command/Command.php
@@ -395,7 +395,7 @@ class Command
*/
public function getNativeDefinition(): InputDefinition
{
- return $this->definition ?? throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
+ return $this->definition ?? throw new LogicException(\sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
}
/**
@@ -603,7 +603,7 @@ class Command
$key = $short ? 'short' : 'long';
if (!isset($this->synopsis[$key])) {
- $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
+ $this->synopsis[$key] = trim(\sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
}
return $this->synopsis[$key];
@@ -617,7 +617,7 @@ class Command
public function addUsage(string $usage): static
{
if (!str_starts_with($usage, $this->name)) {
- $usage = sprintf('%s %s', $this->name, $usage);
+ $usage = \sprintf('%s %s', $this->name, $usage);
}
$this->usages[] = $usage;
@@ -642,7 +642,7 @@ class Command
public function getHelper(string $name): HelperInterface
{
if (null === $this->helperSet) {
- throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
+ throw new LogicException(\sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
}
return $this->helperSet->get($name);
@@ -658,7 +658,7 @@ class Command
private function validateName(string $name): void
{
if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
- throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
+ throw new InvalidArgumentException(\sprintf('Command name "%s" is invalid.', $name));
}
}
}
diff --git a/Command/CompleteCommand.php b/Command/CompleteCommand.php
index 38aa737f..df0cddab 100644
--- a/Command/CompleteCommand.php
+++ b/Command/CompleteCommand.php
@@ -74,7 +74,7 @@ final class CompleteCommand extends Command
// "symfony" must be kept for compat with the shell scripts generated by Symfony Console 5.4 - 6.1
$version = $input->getOption('symfony') ? '1' : $input->getOption('api-version');
if ($version && version_compare($version, self::COMPLETION_API_VERSION, '<')) {
- $message = sprintf('Completion script version is not supported ("%s" given, ">=%s" required).', $version, self::COMPLETION_API_VERSION);
+ $message = \sprintf('Completion script version is not supported ("%s" given, ">=%s" required).', $version, self::COMPLETION_API_VERSION);
$this->log($message);
$output->writeln($message.' Install the Symfony completion script again by using the "completion" command.');
@@ -88,7 +88,7 @@ final class CompleteCommand extends Command
}
if (!$completionOutput = $this->completionOutputs[$shell] ?? false) {
- throw new \RuntimeException(sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
+ throw new \RuntimeException(\sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
}
$completionInput = $this->createCompletionInput($input);
diff --git a/Command/DumpCompletionCommand.php b/Command/DumpCompletionCommand.php
index be6f5459..daf3553a 100644
--- a/Command/DumpCompletionCommand.php
+++ b/Command/DumpCompletionCommand.php
@@ -98,9 +98,9 @@ EOH
$output = $output->getErrorOutput();
}
if ($shell) {
- $output->writeln(sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").>', $shell, implode('", "', $supportedShells)));
+ $output->writeln(\sprintf('Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").>', $shell, implode('", "', $supportedShells)));
} else {
- $output->writeln(sprintf('Shell not detected, Symfony shell completion only supports "%s").>', implode('", "', $supportedShells)));
+ $output->writeln(\sprintf('Shell not detected, Symfony shell completion only supports "%s").>', implode('", "', $supportedShells)));
}
return 2;
diff --git a/CommandLoader/ContainerCommandLoader.php b/CommandLoader/ContainerCommandLoader.php
index 84e25be7..eb494513 100644
--- a/CommandLoader/ContainerCommandLoader.php
+++ b/CommandLoader/ContainerCommandLoader.php
@@ -34,7 +34,7 @@ class ContainerCommandLoader implements CommandLoaderInterface
public function get(string $name): Command
{
if (!$this->has($name)) {
- throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
+ throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name));
}
return $this->container->get($this->commandMap[$name]);
diff --git a/CommandLoader/FactoryCommandLoader.php b/CommandLoader/FactoryCommandLoader.php
index ae16bf6f..2d13139c 100644
--- a/CommandLoader/FactoryCommandLoader.php
+++ b/CommandLoader/FactoryCommandLoader.php
@@ -37,7 +37,7 @@ class FactoryCommandLoader implements CommandLoaderInterface
public function get(string $name): Command
{
if (!isset($this->factories[$name])) {
- throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
+ throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name));
}
$factory = $this->factories[$name];
diff --git a/Cursor.php b/Cursor.php
index 965f996e..e2618cf1 100644
--- a/Cursor.php
+++ b/Cursor.php
@@ -36,7 +36,7 @@ final class Cursor
*/
public function moveUp(int $lines = 1): static
{
- $this->output->write(sprintf("\x1b[%dA", $lines));
+ $this->output->write(\sprintf("\x1b[%dA", $lines));
return $this;
}
@@ -46,7 +46,7 @@ final class Cursor
*/
public function moveDown(int $lines = 1): static
{
- $this->output->write(sprintf("\x1b[%dB", $lines));
+ $this->output->write(\sprintf("\x1b[%dB", $lines));
return $this;
}
@@ -56,7 +56,7 @@ final class Cursor
*/
public function moveRight(int $columns = 1): static
{
- $this->output->write(sprintf("\x1b[%dC", $columns));
+ $this->output->write(\sprintf("\x1b[%dC", $columns));
return $this;
}
@@ -66,7 +66,7 @@ final class Cursor
*/
public function moveLeft(int $columns = 1): static
{
- $this->output->write(sprintf("\x1b[%dD", $columns));
+ $this->output->write(\sprintf("\x1b[%dD", $columns));
return $this;
}
@@ -76,7 +76,7 @@ final class Cursor
*/
public function moveToColumn(int $column): static
{
- $this->output->write(sprintf("\x1b[%dG", $column));
+ $this->output->write(\sprintf("\x1b[%dG", $column));
return $this;
}
@@ -86,7 +86,7 @@ final class Cursor
*/
public function moveToPosition(int $column, int $row): static
{
- $this->output->write(sprintf("\x1b[%d;%dH", $row + 1, $column));
+ $this->output->write(\sprintf("\x1b[%d;%dH", $row + 1, $column));
return $this;
}
@@ -195,7 +195,7 @@ final class Cursor
$code = trim(fread($this->input, 1024));
- shell_exec(sprintf('stty %s', $sttyMode));
+ shell_exec(\sprintf('stty %s', $sttyMode));
sscanf($code, "\033[%d;%dR", $row, $col);
diff --git a/DataCollector/CommandDataCollector.php b/DataCollector/CommandDataCollector.php
index 45138c7d..3cbe72b5 100644
--- a/DataCollector/CommandDataCollector.php
+++ b/DataCollector/CommandDataCollector.php
@@ -118,7 +118,7 @@ final class CommandDataCollector extends DataCollector
public function getInterruptedBySignal(): ?string
{
if (isset($this->data['interrupted_by_signal'])) {
- return sprintf('%s (%d)', SignalMap::getSignalName($this->data['interrupted_by_signal']), $this->data['interrupted_by_signal']);
+ return \sprintf('%s (%d)', SignalMap::getSignalName($this->data['interrupted_by_signal']), $this->data['interrupted_by_signal']);
}
return null;
@@ -204,7 +204,7 @@ final class CommandDataCollector extends DataCollector
public function getSignalable(): array
{
return array_map(
- static fn (int $signal): string => sprintf('%s (%d)', SignalMap::getSignalName($signal), $signal),
+ static fn (int $signal): string => \sprintf('%s (%d)', SignalMap::getSignalName($signal), $signal),
$this->data['signalable']
);
}
@@ -212,7 +212,7 @@ final class CommandDataCollector extends DataCollector
public function getHandledSignals(): array
{
$keys = array_map(
- static fn (int $signal): string => sprintf('%s (%d)', SignalMap::getSignalName($signal), $signal),
+ static fn (int $signal): string => \sprintf('%s (%d)', SignalMap::getSignalName($signal), $signal),
array_keys($this->data['handled_signals'])
);
diff --git a/DependencyInjection/AddConsoleCommandPass.php b/DependencyInjection/AddConsoleCommandPass.php
index f712c614..642247e3 100644
--- a/DependencyInjection/AddConsoleCommandPass.php
+++ b/DependencyInjection/AddConsoleCommandPass.php
@@ -45,10 +45,10 @@ class AddConsoleCommandPass implements CompilerPassInterface
$aliases = $tags[0]['command'];
} else {
if (!$r = $container->getReflectionClass($class)) {
- throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
+ throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
}
if (!$r->isSubclassOf(Command::class)) {
- throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
+ throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
}
$aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
}
@@ -102,10 +102,10 @@ class AddConsoleCommandPass implements CompilerPassInterface
if (!$description) {
if (!$r = $container->getReflectionClass($class)) {
- throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
+ throw new InvalidArgumentException(\sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
}
if (!$r->isSubclassOf(Command::class)) {
- throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
+ throw new InvalidArgumentException(\sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
}
$description = str_replace('%', '%%', $class::getDefaultDescription() ?? '');
}
diff --git a/Descriptor/ApplicationDescription.php b/Descriptor/ApplicationDescription.php
index 5149fde4..802d6856 100644
--- a/Descriptor/ApplicationDescription.php
+++ b/Descriptor/ApplicationDescription.php
@@ -70,7 +70,7 @@ class ApplicationDescription
public function getCommand(string $name): Command
{
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
- throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
+ throw new CommandNotFoundException(\sprintf('Command "%s" does not exist.', $name));
}
return $this->commands[$name] ?? $this->aliases[$name];
diff --git a/Descriptor/Descriptor.php b/Descriptor/Descriptor.php
index 7b2509c6..2143a17c 100644
--- a/Descriptor/Descriptor.php
+++ b/Descriptor/Descriptor.php
@@ -38,7 +38,7 @@ abstract class Descriptor implements DescriptorInterface
$object instanceof InputDefinition => $this->describeInputDefinition($object, $options),
$object instanceof Command => $this->describeCommand($object, $options),
$object instanceof Application => $this->describeApplication($object, $options),
- default => throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))),
+ default => throw new InvalidArgumentException(\sprintf('Object of type "%s" is not describable.', get_debug_type($object))),
};
}
diff --git a/Descriptor/MarkdownDescriptor.php b/Descriptor/MarkdownDescriptor.php
index b3f16ee9..8b707594 100644
--- a/Descriptor/MarkdownDescriptor.php
+++ b/Descriptor/MarkdownDescriptor.php
@@ -149,7 +149,7 @@ class MarkdownDescriptor extends Descriptor
}
$this->write("\n\n");
- $this->write(implode("\n", array_map(fn ($commandName) => sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName())), $namespace['commands'])));
+ $this->write(implode("\n", array_map(fn ($commandName) => \sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName())), $namespace['commands'])));
}
foreach ($description->getCommands() as $command) {
@@ -162,7 +162,7 @@ class MarkdownDescriptor extends Descriptor
{
if ('UNKNOWN' !== $application->getName()) {
if ('UNKNOWN' !== $application->getVersion()) {
- return sprintf('%s %s', $application->getName(), $application->getVersion());
+ return \sprintf('%s %s', $application->getName(), $application->getVersion());
}
return $application->getName();
diff --git a/Descriptor/ReStructuredTextDescriptor.php b/Descriptor/ReStructuredTextDescriptor.php
index f12fecb6..462b9bb0 100644
--- a/Descriptor/ReStructuredTextDescriptor.php
+++ b/Descriptor/ReStructuredTextDescriptor.php
@@ -167,7 +167,7 @@ class ReStructuredTextDescriptor extends Descriptor
return 'Console Tool';
}
if ('UNKNOWN' !== $application->getVersion()) {
- return sprintf('%s %s', $application->getName(), $application->getVersion());
+ return \sprintf('%s %s', $application->getName(), $application->getVersion());
}
return $application->getName();
@@ -209,7 +209,7 @@ class ReStructuredTextDescriptor extends Descriptor
$commands = $this->removeAliasesAndHiddenCommands($commands);
$this->write("\n\n");
- $this->write(implode("\n", array_map(static fn ($commandName) => sprintf('- `%s`_', $commandName), array_keys($commands))));
+ $this->write(implode("\n", array_map(static fn ($commandName) => \sprintf('- `%s`_', $commandName), array_keys($commands))));
}
}
diff --git a/Descriptor/TextDescriptor.php b/Descriptor/TextDescriptor.php
index d04d1023..51c411f4 100644
--- a/Descriptor/TextDescriptor.php
+++ b/Descriptor/TextDescriptor.php
@@ -31,7 +31,7 @@ class TextDescriptor extends Descriptor
protected function describeInputArgument(InputArgument $argument, array $options = []): void
{
if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
- $default = sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault()));
+ $default = \sprintf(' [default: %s]', $this->formatDefaultValue($argument->getDefault()));
} else {
$default = '';
}
@@ -39,7 +39,7 @@ class TextDescriptor extends Descriptor
$totalWidth = $options['total_width'] ?? Helper::width($argument->getName());
$spacingWidth = $totalWidth - \strlen($argument->getName());
- $this->writeText(sprintf(' %s %s%s%s',
+ $this->writeText(\sprintf(' %s %s%s%s',
$argument->getName(),
str_repeat(' ', $spacingWidth),
// + 4 = 2 spaces before , 2 spaces after
@@ -51,7 +51,7 @@ class TextDescriptor extends Descriptor
protected function describeInputOption(InputOption $option, array $options = []): void
{
if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
- $default = sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault()));
+ $default = \sprintf(' [default: %s]', $this->formatDefaultValue($option->getDefault()));
} else {
$default = '';
}
@@ -66,14 +66,14 @@ class TextDescriptor extends Descriptor
}
$totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
- $synopsis = sprintf('%s%s',
- $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
- sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
+ $synopsis = \sprintf('%s%s',
+ $option->getShortcut() ? \sprintf('-%s, ', $option->getShortcut()) : ' ',
+ \sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
);
$spacingWidth = $totalWidth - Helper::width($synopsis);
- $this->writeText(sprintf(' %s %s%s%s%s',
+ $this->writeText(\sprintf(' %s %s%s%s%s',
$synopsis,
str_repeat(' ', $spacingWidth),
// + 4 = 2 spaces before , 2 spaces after
@@ -166,7 +166,7 @@ class TextDescriptor extends Descriptor
$width = $this->getColumnWidth($description->getCommands());
foreach ($description->getCommands() as $command) {
- $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
+ $this->writeText(\sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
$this->writeText("\n");
}
} else {
@@ -196,7 +196,7 @@ class TextDescriptor extends Descriptor
$width = $this->getColumnWidth(array_merge(...array_values(array_map(fn ($namespace) => array_intersect($namespace['commands'], array_keys($commands)), array_values($namespaces)))));
if ($describedNamespace) {
- $this->writeText(sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options);
+ $this->writeText(\sprintf('Available commands for the "%s" namespace:', $describedNamespace), $options);
} else {
$this->writeText('Available commands:', $options);
}
@@ -218,7 +218,7 @@ class TextDescriptor extends Descriptor
$spacingWidth = $width - Helper::width($name);
$command = $commands[$name];
$commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
- $this->writeText(sprintf(' %s%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
+ $this->writeText(\sprintf(' %s%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
}
}
diff --git a/Formatter/OutputFormatter.php b/Formatter/OutputFormatter.php
index 8e81e590..1f3d04a2 100644
--- a/Formatter/OutputFormatter.php
+++ b/Formatter/OutputFormatter.php
@@ -106,7 +106,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
public function getStyle(string $name): OutputFormatterStyleInterface
{
if (!$this->hasStyle($name)) {
- throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
+ throw new InvalidArgumentException(\sprintf('Undefined style: "%s".', $name));
}
return $this->styles[strtolower($name)];
diff --git a/Helper/DebugFormatterHelper.php b/Helper/DebugFormatterHelper.php
index 9ea7fb91..dfdb8a82 100644
--- a/Helper/DebugFormatterHelper.php
+++ b/Helper/DebugFormatterHelper.php
@@ -31,7 +31,7 @@ class DebugFormatterHelper extends Helper
{
$this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
- return sprintf("%s %s > %s>\n", $this->getBorder($id), $prefix, $message);
+ return \sprintf("%s %s > %s>\n", $this->getBorder($id), $prefix, $message);
}
/**
@@ -47,22 +47,22 @@ class DebugFormatterHelper extends Helper
unset($this->started[$id]['out']);
}
if (!isset($this->started[$id]['err'])) {
- $message .= sprintf('%s %s > ', $this->getBorder($id), $errorPrefix);
+ $message .= \sprintf('%s %s > ', $this->getBorder($id), $errorPrefix);
$this->started[$id]['err'] = true;
}
- $message .= str_replace("\n", sprintf("\n%s %s > ", $this->getBorder($id), $errorPrefix), $buffer);
+ $message .= str_replace("\n", \sprintf("\n%s %s > ", $this->getBorder($id), $errorPrefix), $buffer);
} else {
if (isset($this->started[$id]['err'])) {
$message .= "\n";
unset($this->started[$id]['err']);
}
if (!isset($this->started[$id]['out'])) {
- $message .= sprintf('%s %s > ', $this->getBorder($id), $prefix);
+ $message .= \sprintf('%s %s > ', $this->getBorder($id), $prefix);
$this->started[$id]['out'] = true;
}
- $message .= str_replace("\n", sprintf("\n%s %s > ", $this->getBorder($id), $prefix), $buffer);
+ $message .= str_replace("\n", \sprintf("\n%s %s > ", $this->getBorder($id), $prefix), $buffer);
}
return $message;
@@ -76,10 +76,10 @@ class DebugFormatterHelper extends Helper
$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
if ($successful) {
- return sprintf("%s%s %s > %s>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
+ return \sprintf("%s%s %s > %s>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
}
- $message = sprintf("%s%s %s > %s>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
+ $message = \sprintf("%s%s %s > %s>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
unset($this->started[$id]['out'], $this->started[$id]['err']);
@@ -88,7 +88,7 @@ class DebugFormatterHelper extends Helper
private function getBorder(string $id): string
{
- return sprintf(' >', self::COLORS[$this->started[$id]['border']]);
+ return \sprintf(' >', self::COLORS[$this->started[$id]['border']]);
}
public function getName(): string
diff --git a/Helper/DescriptorHelper.php b/Helper/DescriptorHelper.php
index 300c7b10..9422271f 100644
--- a/Helper/DescriptorHelper.php
+++ b/Helper/DescriptorHelper.php
@@ -60,7 +60,7 @@ class DescriptorHelper extends Helper
], $options);
if (!isset($this->descriptors[$options['format']])) {
- throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
+ throw new InvalidArgumentException(\sprintf('Unsupported format "%s".', $options['format']));
}
$descriptor = $this->descriptors[$options['format']];
diff --git a/Helper/FormatterHelper.php b/Helper/FormatterHelper.php
index 279e4c79..3646b3d6 100644
--- a/Helper/FormatterHelper.php
+++ b/Helper/FormatterHelper.php
@@ -25,7 +25,7 @@ class FormatterHelper extends Helper
*/
public function formatSection(string $section, string $message, string $style = 'info'): string
{
- return sprintf('<%s>[%s]%s> %s', $style, $section, $style, $message);
+ return \sprintf('<%s>[%s]%s> %s', $style, $section, $style, $message);
}
/**
@@ -41,7 +41,7 @@ class FormatterHelper extends Helper
$lines = [];
foreach ($messages as $message) {
$message = OutputFormatter::escape($message);
- $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
+ $lines[] = \sprintf($large ? ' %s ' : ' %s ', $message);
$len = max(self::width($message) + ($large ? 4 : 2), $len);
}
@@ -54,7 +54,7 @@ class FormatterHelper extends Helper
}
for ($i = 0; isset($messages[$i]); ++$i) {
- $messages[$i] = sprintf('<%s>%s%s>', $style, $messages[$i], $style);
+ $messages[$i] = \sprintf('<%s>%s%s>', $style, $messages[$i], $style);
}
return implode("\n", $messages);
diff --git a/Helper/Helper.php b/Helper/Helper.php
index de090063..3981bbf3 100644
--- a/Helper/Helper.php
+++ b/Helper/Helper.php
@@ -128,18 +128,18 @@ abstract class Helper implements HelperInterface
public static function formatMemory(int $memory): string
{
if ($memory >= 1024 * 1024 * 1024) {
- return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
+ return \sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
}
if ($memory >= 1024 * 1024) {
- return sprintf('%.1f MiB', $memory / 1024 / 1024);
+ return \sprintf('%.1f MiB', $memory / 1024 / 1024);
}
if ($memory >= 1024) {
- return sprintf('%d KiB', $memory / 1024);
+ return \sprintf('%d KiB', $memory / 1024);
}
- return sprintf('%d B', $memory);
+ return \sprintf('%d B', $memory);
}
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string): string
diff --git a/Helper/HelperSet.php b/Helper/HelperSet.php
index 30df9f95..ffe756c9 100644
--- a/Helper/HelperSet.php
+++ b/Helper/HelperSet.php
@@ -61,7 +61,7 @@ class HelperSet implements \IteratorAggregate
public function get(string $name): HelperInterface
{
if (!$this->has($name)) {
- throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
+ throw new InvalidArgumentException(\sprintf('The helper "%s" is not defined.', $name));
}
return $this->helpers[$name];
diff --git a/Helper/OutputWrapper.php b/Helper/OutputWrapper.php
index 0ea2b705..a615ed2f 100644
--- a/Helper/OutputWrapper.php
+++ b/Helper/OutputWrapper.php
@@ -59,7 +59,7 @@ final class OutputWrapper
return $text;
}
- $tagPattern = sprintf('<(?:(?:%s)|/(?:%s)?)>', self::TAG_OPEN_REGEX_SEGMENT, self::TAG_CLOSE_REGEX_SEGMENT);
+ $tagPattern = \sprintf('<(?:(?:%s)|/(?:%s)?)>', self::TAG_OPEN_REGEX_SEGMENT, self::TAG_CLOSE_REGEX_SEGMENT);
$limitPattern = "{1,$width}";
$patternBlocks = [$tagPattern];
if (!$this->allowCutUrls) {
@@ -68,7 +68,7 @@ final class OutputWrapper
$patternBlocks[] = '.';
$blocks = implode('|', $patternBlocks);
$rowPattern = "(?:$blocks)$limitPattern";
- $pattern = sprintf('#(?:((?>(%1$s)((?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|(%1$s))(?:\r?\n)?|(?:\r?\n|$))#imux', $rowPattern);
+ $pattern = \sprintf('#(?:((?>(%1$s)((?<=[^\S\r\n])[^\S\r\n]?|(?=\r?\n)|$|[^\S\r\n]))|(%1$s))(?:\r?\n)?|(?:\r?\n|$))#imux', $rowPattern);
$output = rtrim(preg_replace($pattern, '\\1'.$break, $text), $break);
return str_replace(' '.$break, $break, $output);
diff --git a/Helper/ProcessHelper.php b/Helper/ProcessHelper.php
index 3ef6f71f..ae55a83c 100644
--- a/Helper/ProcessHelper.php
+++ b/Helper/ProcessHelper.php
@@ -55,7 +55,7 @@ class ProcessHelper extends Helper
$process = $cmd[0];
unset($cmd[0]);
} else {
- throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__));
+ throw new \InvalidArgumentException(\sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__));
}
if ($verbosity <= $output->getVerbosity()) {
@@ -69,12 +69,12 @@ class ProcessHelper extends Helper
$process->run($callback, $cmd);
if ($verbosity <= $output->getVerbosity()) {
- $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
+ $message = $process->isSuccessful() ? 'Command ran successfully' : \sprintf('%s Command did not run successfully', $process->getExitCode());
$output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
}
if (!$process->isSuccessful() && null !== $error) {
- $output->writeln(sprintf('%s', $this->escapeString($error)));
+ $output->writeln(\sprintf('%s', $this->escapeString($error)));
}
return $process;
diff --git a/Helper/ProgressBar.php b/Helper/ProgressBar.php
index 7c22b7d5..5f1a32bc 100644
--- a/Helper/ProgressBar.php
+++ b/Helper/ProgressBar.php
@@ -621,7 +621,7 @@ final class ProgressBar
}
if (isset($matches[2])) {
- $text = sprintf('%'.$matches[2], $text);
+ $text = \sprintf('%'.$matches[2], $text);
}
return $text;
diff --git a/Helper/QuestionHelper.php b/Helper/QuestionHelper.php
index 54825c6c..69afc2a6 100644
--- a/Helper/QuestionHelper.php
+++ b/Helper/QuestionHelper.php
@@ -211,7 +211,7 @@ class QuestionHelper extends Helper
foreach ($choices as $key => $value) {
$padding = str_repeat(' ', $maxWidth - self::width($key));
- $messages[] = sprintf(" [<$tag>%s$padding$tag>] %s", $key, $value);
+ $messages[] = \sprintf(" [<$tag>%s$padding$tag>] %s", $key, $value);
}
return $messages;
diff --git a/Helper/SymfonyQuestionHelper.php b/Helper/SymfonyQuestionHelper.php
index 48d947b7..b452bf04 100644
--- a/Helper/SymfonyQuestionHelper.php
+++ b/Helper/SymfonyQuestionHelper.php
@@ -31,17 +31,17 @@ class SymfonyQuestionHelper extends QuestionHelper
$default = $question->getDefault();
if ($question->isMultiline()) {
- $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
+ $text .= \sprintf(' (press %s to continue)', $this->getEofShortcut());
}
switch (true) {
case null === $default:
- $text = sprintf(' %s:', $text);
+ $text = \sprintf(' %s:', $text);
break;
case $question instanceof ConfirmationQuestion:
- $text = sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no');
+ $text = \sprintf(' %s (yes/no) [%s]:', $text, $default ? 'yes' : 'no');
break;
@@ -53,18 +53,18 @@ class SymfonyQuestionHelper extends QuestionHelper
$default[$key] = $choices[trim($value)];
}
- $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape(implode(', ', $default)));
+ $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape(implode(', ', $default)));
break;
case $question instanceof ChoiceQuestion:
$choices = $question->getChoices();
- $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
+ $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
break;
default:
- $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape($default));
+ $text = \sprintf(' %s [%s]:', $text, OutputFormatter::escape($default));
}
$output->writeln($text);
diff --git a/Helper/Table.php b/Helper/Table.php
index 09709a28..9ff73d2c 100644
--- a/Helper/Table.php
+++ b/Helper/Table.php
@@ -79,7 +79,7 @@ class Table
{
self::$styles ??= self::initStyles();
- return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
+ return self::$styles[$name] ?? throw new InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name));
}
/**
@@ -164,7 +164,7 @@ class Table
public function setColumnMaxWidth(int $columnIndex, int $width): static
{
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
- throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter())));
+ throw new \LogicException(\sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter())));
}
$this->columnMaxWidths[$columnIndex] = $width;
@@ -233,7 +233,7 @@ class Table
public function appendRow(TableSeparator|array $row): static
{
if (!$this->output instanceof ConsoleSectionOutput) {
- throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
+ throw new RuntimeException(\sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
}
if ($this->rendered) {
@@ -364,14 +364,14 @@ class Table
foreach ($parts as $idx => $part) {
if ($headers && !$containsColspan) {
if (0 === $idx) {
- $rows[] = [sprintf(
+ $rows[] = [\sprintf(
'%s%s>: %s',
str_repeat(' ', $maxHeaderLength - Helper::width(Helper::removeDecoration($formatter, $headers[$i] ?? ''))),
$headers[$i] ?? '',
$part
)];
} else {
- $rows[] = [sprintf(
+ $rows[] = [\sprintf(
'%s %s',
str_pad('', $maxHeaderLength, ' ', \STR_PAD_LEFT),
$part
@@ -491,12 +491,12 @@ class Table
}
if (null !== $title) {
- $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title)));
+ $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = \sprintf($titleFormat, $title)));
$markupLength = Helper::width($markup);
if ($titleLength > $limit = $markupLength - 4) {
$titleLength = $limit;
- $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, '')));
- $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
+ $formatLength = Helper::width(Helper::removeDecoration($formatter, \sprintf($titleFormat, '')));
+ $formattedTitle = \sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
}
$titleStart = intdiv($markupLength - $titleLength, 2);
@@ -507,7 +507,7 @@ class Table
}
}
- $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
+ $this->output->writeln(\sprintf($this->style->getBorderFormat(), $markup));
}
/**
@@ -517,7 +517,7 @@ class Table
{
$borders = $this->style->getBorderChars();
- return sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
+ return \sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
}
/**
@@ -565,11 +565,11 @@ class Table
$style = $this->getColumnStyle($column);
if ($cell instanceof TableSeparator) {
- return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
+ return \sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
}
$width += Helper::length($cell) - Helper::length(Helper::removeDecoration($this->output->getFormatter(), $cell));
- $content = sprintf($style->getCellRowContentFormat(), $cell);
+ $content = \sprintf($style->getCellRowContentFormat(), $cell);
$padType = $style->getPadType();
if ($cell instanceof TableCell && $cell->getStyle() instanceof TableCellStyle) {
@@ -594,7 +594,7 @@ class Table
$padType = $cell->getStyle()->getPadByAlign();
}
- return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $padType));
+ return \sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $padType));
}
/**
@@ -691,7 +691,7 @@ class Table
$unmergedRows = [];
foreach ($rows[$line] as $column => $cell) {
if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) {
- throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
+ throw new InvalidArgumentException(\sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
}
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
$nbLines = $cell->getRowspan() - 1;
@@ -836,7 +836,7 @@ class Table
private function getColumnSeparatorWidth(): int
{
- return Helper::width(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
+ return Helper::width(\sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
}
private function getCellWidth(array $row, int $column): int
@@ -919,6 +919,6 @@ class Table
return $name;
}
- return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
+ return self::$styles[$name] ?? throw new InvalidArgumentException(\sprintf('Style "%s" is not defined.', $name));
}
}
diff --git a/Helper/TableCell.php b/Helper/TableCell.php
index 1c4eeea2..ab833920 100644
--- a/Helper/TableCell.php
+++ b/Helper/TableCell.php
@@ -30,7 +30,7 @@ class TableCell
) {
// check option names
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
- throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
+ throw new InvalidArgumentException(\sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
}
if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
diff --git a/Helper/TableCellStyle.php b/Helper/TableCellStyle.php
index 49b97f85..af1a17e9 100644
--- a/Helper/TableCellStyle.php
+++ b/Helper/TableCellStyle.php
@@ -43,11 +43,11 @@ class TableCellStyle
public function __construct(array $options = [])
{
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
- throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
+ throw new InvalidArgumentException(\sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
}
if (isset($options['align']) && !\array_key_exists($options['align'], self::ALIGN_MAP)) {
- throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys(self::ALIGN_MAP))));
+ throw new InvalidArgumentException(\sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys(self::ALIGN_MAP))));
}
$this->options = array_merge($this->options, $options);
diff --git a/Input/ArgvInput.php b/Input/ArgvInput.php
index 2ebbdf08..e0f42651 100644
--- a/Input/ArgvInput.php
+++ b/Input/ArgvInput.php
@@ -51,7 +51,7 @@ class ArgvInput extends Input
foreach ($argv as $arg) {
if (!\is_scalar($arg) && !$arg instanceof \Stringable) {
- throw new RuntimeException(sprintf('Argument values expected to be all scalars, got "%s".', get_debug_type($arg)));
+ throw new RuntimeException(\sprintf('Argument values expected to be all scalars, got "%s".', get_debug_type($arg)));
}
}
@@ -125,7 +125,7 @@ class ArgvInput extends Input
for ($i = 0; $i < $len; ++$i) {
if (!$this->definition->hasShortcut($name[$i])) {
$encoding = mb_detect_encoding($name, null, true);
- throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
+ throw new RuntimeException(\sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
}
$option = $this->definition->getOptionForShortcut($name[$i]);
@@ -186,14 +186,14 @@ class ArgvInput extends Input
if (\count($all)) {
if ($symfonyCommandName) {
- $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
+ $message = \sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
} else {
- $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
+ $message = \sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
}
} elseif ($symfonyCommandName) {
- $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
+ $message = \sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
} else {
- $message = sprintf('No arguments expected, got "%s".', $token);
+ $message = \sprintf('No arguments expected, got "%s".', $token);
}
throw new RuntimeException($message);
@@ -208,7 +208,7 @@ class ArgvInput extends Input
private function addShortOption(string $shortcut, mixed $value): void
{
if (!$this->definition->hasShortcut($shortcut)) {
- throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
+ throw new RuntimeException(\sprintf('The "-%s" option does not exist.', $shortcut));
}
$this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
@@ -223,12 +223,12 @@ class ArgvInput extends Input
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
- throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
+ throw new RuntimeException(\sprintf('The "--%s" option does not exist.', $name));
}
$optionName = $this->definition->negationToName($name);
if (null !== $value) {
- throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
+ throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name));
}
$this->options[$optionName] = false;
@@ -238,7 +238,7 @@ class ArgvInput extends Input
$option = $this->definition->getOption($name);
if (null !== $value && !$option->acceptValue()) {
- throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
+ throw new RuntimeException(\sprintf('The "--%s" option does not accept a value.', $name));
}
if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
@@ -254,7 +254,7 @@ class ArgvInput extends Input
if (null === $value) {
if ($option->isValueRequired()) {
- throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
+ throw new RuntimeException(\sprintf('The "--%s" option requires a value.', $name));
}
if (!$option->isArray() && !$option->isValueOptional()) {
diff --git a/Input/ArrayInput.php b/Input/ArrayInput.php
index d27ff411..7335632b 100644
--- a/Input/ArrayInput.php
+++ b/Input/ArrayInput.php
@@ -135,7 +135,7 @@ class ArrayInput extends Input
private function addShortOption(string $shortcut, mixed $value): void
{
if (!$this->definition->hasShortcut($shortcut)) {
- throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
+ throw new InvalidOptionException(\sprintf('The "-%s" option does not exist.', $shortcut));
}
$this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
@@ -151,7 +151,7 @@ class ArrayInput extends Input
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
- throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
+ throw new InvalidOptionException(\sprintf('The "--%s" option does not exist.', $name));
}
$optionName = $this->definition->negationToName($name);
@@ -164,7 +164,7 @@ class ArrayInput extends Input
if (null === $value) {
if ($option->isValueRequired()) {
- throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
+ throw new InvalidOptionException(\sprintf('The "--%s" option requires a value.', $name));
}
if (!$option->isValueOptional()) {
@@ -183,7 +183,7 @@ class ArrayInput extends Input
private function addArgument(string|int $name, mixed $value): void
{
if (!$this->definition->hasArgument($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
}
$this->arguments[$name] = $value;
diff --git a/Input/Input.php b/Input/Input.php
index 5a8b9a27..d2881c60 100644
--- a/Input/Input.php
+++ b/Input/Input.php
@@ -66,7 +66,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
$missingArguments = array_filter(array_keys($definition->getArguments()), fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired());
if (\count($missingArguments) > 0) {
- throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
+ throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
}
}
@@ -88,7 +88,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
public function getArgument(string $name): mixed
{
if (!$this->definition->hasArgument($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
}
return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
@@ -97,7 +97,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
public function setArgument(string $name, mixed $value): void
{
if (!$this->definition->hasArgument($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
}
$this->arguments[$name] = $value;
@@ -124,7 +124,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
}
if (!$this->definition->hasOption($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
}
return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
@@ -137,7 +137,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
return;
} elseif (!$this->definition->hasOption($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
}
$this->options[$name] = $value;
diff --git a/Input/InputArgument.php b/Input/InputArgument.php
index a5d94927..6fbb64ed 100644
--- a/Input/InputArgument.php
+++ b/Input/InputArgument.php
@@ -62,7 +62,7 @@ class InputArgument
if (null === $mode) {
$mode = self::OPTIONAL;
} elseif ($mode >= (self::IS_ARRAY << 1) || $mode < 1) {
- throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
+ throw new InvalidArgumentException(\sprintf('Argument mode "%s" is not valid.', $mode));
}
$this->mode = $mode;
@@ -143,7 +143,7 @@ class InputArgument
{
$values = $this->suggestedValues;
if ($values instanceof \Closure && !\is_array($values = $values($input))) {
- throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
+ throw new LogicException(\sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
}
if ($values) {
$suggestions->suggestValues($values);
diff --git a/Input/InputDefinition.php b/Input/InputDefinition.php
index f27e2974..a8b006d4 100644
--- a/Input/InputDefinition.php
+++ b/Input/InputDefinition.php
@@ -97,15 +97,15 @@ class InputDefinition
public function addArgument(InputArgument $argument): void
{
if (isset($this->arguments[$argument->getName()])) {
- throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
+ throw new LogicException(\sprintf('An argument with name "%s" already exists.', $argument->getName()));
}
if (null !== $this->lastArrayArgument) {
- throw new LogicException(sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
+ throw new LogicException(\sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
}
if ($argument->isRequired() && null !== $this->lastOptionalArgument) {
- throw new LogicException(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
+ throw new LogicException(\sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
}
if ($argument->isArray()) {
@@ -129,7 +129,7 @@ class InputDefinition
public function getArgument(string|int $name): InputArgument
{
if (!$this->hasArgument($name)) {
- throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
}
$arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
@@ -217,16 +217,16 @@ class InputDefinition
public function addOption(InputOption $option): void
{
if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
- throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
+ throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName()));
}
if (isset($this->negations[$option->getName()])) {
- throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
+ throw new LogicException(\sprintf('An option named "%s" already exists.', $option->getName()));
}
if ($option->getShortcut()) {
foreach (explode('|', $option->getShortcut()) as $shortcut) {
if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
- throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
+ throw new LogicException(\sprintf('An option with shortcut "%s" already exists.', $shortcut));
}
}
}
@@ -241,7 +241,7 @@ class InputDefinition
if ($option->isNegatable()) {
$negatedName = 'no-'.$option->getName();
if (isset($this->options[$negatedName])) {
- throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
+ throw new LogicException(\sprintf('An option named "%s" already exists.', $negatedName));
}
$this->negations[$negatedName] = $option->getName();
}
@@ -255,7 +255,7 @@ class InputDefinition
public function getOption(string $name): InputOption
{
if (!$this->hasOption($name)) {
- throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
+ throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $name));
}
return $this->options[$name];
@@ -329,7 +329,7 @@ class InputDefinition
public function shortcutToName(string $shortcut): string
{
if (!isset($this->shortcuts[$shortcut])) {
- throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
+ throw new InvalidArgumentException(\sprintf('The "-%s" option does not exist.', $shortcut));
}
return $this->shortcuts[$shortcut];
@@ -345,7 +345,7 @@ class InputDefinition
public function negationToName(string $negation): string
{
if (!isset($this->negations[$negation])) {
- throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
+ throw new InvalidArgumentException(\sprintf('The "--%s" option does not exist.', $negation));
}
return $this->negations[$negation];
@@ -364,7 +364,7 @@ class InputDefinition
foreach ($this->getOptions() as $option) {
$value = '';
if ($option->acceptValue()) {
- $value = sprintf(
+ $value = \sprintf(
' %s%s%s',
$option->isValueOptional() ? '[' : '',
strtoupper($option->getName()),
@@ -372,9 +372,9 @@ class InputDefinition
);
}
- $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
- $negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
- $elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
+ $shortcut = $option->getShortcut() ? \sprintf('-%s|', $option->getShortcut()) : '';
+ $negation = $option->isNegatable() ? \sprintf('|--no-%s', $option->getName()) : '';
+ $elements[] = \sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
}
}
diff --git a/Input/InputOption.php b/Input/InputOption.php
index 617c348d..25fb9178 100644
--- a/Input/InputOption.php
+++ b/Input/InputOption.php
@@ -99,7 +99,7 @@ class InputOption
if (null === $mode) {
$mode = self::VALUE_NONE;
} elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
- throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
+ throw new InvalidArgumentException(\sprintf('Option mode "%s" is not valid.', $mode));
}
$this->name = $name;
@@ -238,7 +238,7 @@ class InputOption
{
$values = $this->suggestedValues;
if ($values instanceof \Closure && !\is_array($values = $values($input))) {
- throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
+ throw new LogicException(\sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
}
if ($values) {
$suggestions->suggestValues($values);
diff --git a/Input/StringInput.php b/Input/StringInput.php
index 83570014..a70f048f 100644
--- a/Input/StringInput.php
+++ b/Input/StringInput.php
@@ -70,7 +70,7 @@ class StringInput extends ArgvInput
$token .= $match[1];
} else {
// should never happen
- throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
+ throw new InvalidArgumentException(\sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
}
$cursor += \strlen($match[0]);
diff --git a/Logger/ConsoleLogger.php b/Logger/ConsoleLogger.php
index ad6e49ce..a6ef49ea 100644
--- a/Logger/ConsoleLogger.php
+++ b/Logger/ConsoleLogger.php
@@ -63,7 +63,7 @@ class ConsoleLogger extends AbstractLogger
public function log($level, $message, array $context = []): void
{
if (!isset($this->verbosityLevelMap[$level])) {
- throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
+ throw new InvalidArgumentException(\sprintf('The log level "%s" does not exist.', $level));
}
$output = $this->output;
@@ -79,7 +79,7 @@ class ConsoleLogger extends AbstractLogger
// the if condition check isn't necessary -- it's the same one that $output will do internally anyway.
// We only do it for efficiency here as the message formatting is relatively expensive.
if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
- $output->writeln(sprintf('<%1$s>[%2$s] %3$s%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
+ $output->writeln(\sprintf('<%1$s>[%2$s] %3$s%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
}
}
diff --git a/Messenger/RunCommandMessageHandler.php b/Messenger/RunCommandMessageHandler.php
index 1bc49949..0fdf7d01 100644
--- a/Messenger/RunCommandMessageHandler.php
+++ b/Messenger/RunCommandMessageHandler.php
@@ -41,7 +41,7 @@ final class RunCommandMessageHandler
}
if ($message->throwOnFailure && Command::SUCCESS !== $exitCode) {
- throw new RunCommandFailedException(sprintf('Command "%s" exited with code "%s".', $message->input, $exitCode), new RunCommandContext($message, $exitCode, $output->fetch()));
+ throw new RunCommandFailedException(\sprintf('Command "%s" exited with code "%s".', $message->input, $exitCode), new RunCommandContext($message, $exitCode, $output->fetch()));
}
return new RunCommandContext($message, $exitCode, $output->fetch());
diff --git a/Output/AnsiColorMode.php b/Output/AnsiColorMode.php
index ca40ffb7..dcdd1d5c 100644
--- a/Output/AnsiColorMode.php
+++ b/Output/AnsiColorMode.php
@@ -51,7 +51,7 @@ enum AnsiColorMode
}
if (6 !== \strlen($hexColor)) {
- throw new InvalidArgumentException(sprintf('Invalid "#%s" color.', $hexColor));
+ throw new InvalidArgumentException(\sprintf('Invalid "#%s" color.', $hexColor));
}
$color = hexdec($hexColor);
@@ -63,7 +63,7 @@ enum AnsiColorMode
return match ($this) {
self::Ansi4 => (string) $this->convertFromRGB($r, $g, $b),
self::Ansi8 => '8;5;'.((string) $this->convertFromRGB($r, $g, $b)),
- self::Ansi24 => sprintf('8;2;%d;%d;%d', $r, $g, $b),
+ self::Ansi24 => \sprintf('8;2;%d;%d;%d', $r, $g, $b),
};
}
diff --git a/Output/ConsoleSectionOutput.php b/Output/ConsoleSectionOutput.php
index 09aa7fe9..44728dfd 100644
--- a/Output/ConsoleSectionOutput.php
+++ b/Output/ConsoleSectionOutput.php
@@ -222,7 +222,7 @@ class ConsoleSectionOutput extends StreamOutput
if ($numberOfLinesToClear > 0) {
// move cursor up n lines
- parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
+ parent::doWrite(\sprintf("\x1b[%dA", $numberOfLinesToClear), false);
// erase to end of screen
parent::doWrite("\x1b[0J", false);
}
diff --git a/Output/TrimmedBufferOutput.php b/Output/TrimmedBufferOutput.php
index c1862a2b..f0f95054 100644
--- a/Output/TrimmedBufferOutput.php
+++ b/Output/TrimmedBufferOutput.php
@@ -27,7 +27,7 @@ class TrimmedBufferOutput extends Output
public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null)
{
if ($maxLength <= 0) {
- throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
+ throw new InvalidArgumentException(\sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
}
parent::__construct($verbosity, $decorated, $formatter);
diff --git a/Question/ChoiceQuestion.php b/Question/ChoiceQuestion.php
index 0ccad051..d184ef76 100644
--- a/Question/ChoiceQuestion.php
+++ b/Question/ChoiceQuestion.php
@@ -121,7 +121,7 @@ class ChoiceQuestion extends Question
if ($multiselect) {
// Check for a separated comma values
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
- throw new InvalidArgumentException(sprintf($errorMessage, $selected));
+ throw new InvalidArgumentException(\sprintf($errorMessage, $selected));
}
$selectedChoices = explode(',', (string) $selected);
@@ -145,7 +145,7 @@ class ChoiceQuestion extends Question
}
if (\count($results) > 1) {
- throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
+ throw new InvalidArgumentException(\sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
}
$result = array_search($value, $choices);
@@ -161,7 +161,7 @@ class ChoiceQuestion extends Question
}
if (false === $result) {
- throw new InvalidArgumentException(sprintf($errorMessage, $value));
+ throw new InvalidArgumentException(\sprintf($errorMessage, $value));
}
// For associative choices, consistently return the key as string:
diff --git a/Style/SymfonyStyle.php b/Style/SymfonyStyle.php
index 19ad892e..4cf62cdb 100644
--- a/Style/SymfonyStyle.php
+++ b/Style/SymfonyStyle.php
@@ -73,8 +73,8 @@ class SymfonyStyle extends OutputStyle
{
$this->autoPrependBlock();
$this->writeln([
- sprintf('%s>', OutputFormatter::escapeTrailingBackslash($message)),
- sprintf('%s>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
+ \sprintf('%s>', OutputFormatter::escapeTrailingBackslash($message)),
+ \sprintf('%s>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
]);
$this->newLine();
}
@@ -83,8 +83,8 @@ class SymfonyStyle extends OutputStyle
{
$this->autoPrependBlock();
$this->writeln([
- sprintf('%s>', OutputFormatter::escapeTrailingBackslash($message)),
- sprintf('%s>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
+ \sprintf('%s>', OutputFormatter::escapeTrailingBackslash($message)),
+ \sprintf('%s>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
]);
$this->newLine();
}
@@ -92,7 +92,7 @@ class SymfonyStyle extends OutputStyle
public function listing(array $elements): void
{
$this->autoPrependText();
- $elements = array_map(fn ($element) => sprintf(' * %s', $element), $elements);
+ $elements = array_map(fn ($element) => \sprintf(' * %s', $element), $elements);
$this->writeln($elements);
$this->newLine();
@@ -104,7 +104,7 @@ class SymfonyStyle extends OutputStyle
$messages = \is_array($message) ? array_values($message) : [$message];
foreach ($messages as $message) {
- $this->writeln(sprintf(' %s', $message));
+ $this->writeln(\sprintf(' %s', $message));
}
}
@@ -404,7 +404,7 @@ class SymfonyStyle extends OutputStyle
$lines = [];
if (null !== $type) {
- $type = sprintf('[%s] ', $type);
+ $type = \sprintf('[%s] ', $type);
$indentLength = Helper::width($type);
$lineIndentation = str_repeat(' ', $indentLength);
}
@@ -446,7 +446,7 @@ class SymfonyStyle extends OutputStyle
$line .= str_repeat(' ', max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0));
if ($style) {
- $line = sprintf('<%s>%s>', $style, $line);
+ $line = \sprintf('<%s>%s>', $style, $line);
}
}
diff --git a/Tester/Constraint/CommandIsSuccessful.php b/Tester/Constraint/CommandIsSuccessful.php
index 09c6194b..d677c27a 100644
--- a/Tester/Constraint/CommandIsSuccessful.php
+++ b/Tester/Constraint/CommandIsSuccessful.php
@@ -38,6 +38,6 @@ final class CommandIsSuccessful extends Constraint
Command::INVALID => 'Command was invalid.',
];
- return $mapping[$other] ?? sprintf('Command returned exit status %d.', $other);
+ return $mapping[$other] ?? \sprintf('Command returned exit status %d.', $other);
}
}
diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php
index d8e1ae8b..4fd2466e 100644
--- a/Tests/ApplicationTest.php
+++ b/Tests/ApplicationTest.php
@@ -637,7 +637,7 @@ class ApplicationTest extends TestCase
} catch (\Exception $e) {
$this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist');
$this->assertSame([], $e->getAlternatives());
- $this->assertEquals(sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives');
+ $this->assertEquals(\sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without alternatives');
}
// Test if "bar1" command throw a "CommandNotFoundException" and does not contain
@@ -648,7 +648,7 @@ class ApplicationTest extends TestCase
} catch (\Exception $e) {
$this->assertInstanceOf(CommandNotFoundException::class, $e, '->find() throws a CommandNotFoundException if command does not exist');
$this->assertSame(['afoobar1', 'foo:bar1'], $e->getAlternatives());
- $this->assertMatchesRegularExpression(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
+ $this->assertMatchesRegularExpression(\sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
$this->assertMatchesRegularExpression('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"');
$this->assertMatchesRegularExpression('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"');
$this->assertDoesNotMatchRegularExpression('/foo:bar(?!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative');
@@ -967,7 +967,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
- throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', (new class() {})::class));
+ throw new \InvalidArgumentException(\sprintf('Dummy type "%s" is invalid.', (new class() {})::class));
});
$tester = new ApplicationTester($application);
@@ -993,7 +993,7 @@ class ApplicationTest extends TestCase
$application = new Application();
$application->setAutoExit(false);
$application->register('foo')->setCode(function () {
- throw new \InvalidArgumentException(sprintf('Dummy type "%s" is invalid.', (new class() {})::class));
+ throw new \InvalidArgumentException(\sprintf('Dummy type "%s" is invalid.', (new class() {})::class));
});
$tester = new ApplicationTester($application);
diff --git a/Tests/Command/CommandTest.php b/Tests/Command/CommandTest.php
index f3e4b51d..199c0c30 100644
--- a/Tests/Command/CommandTest.php
+++ b/Tests/Command/CommandTest.php
@@ -139,7 +139,7 @@ class CommandTest extends TestCase
public function testInvalidCommandNames($name)
{
$this->expectException(\InvalidArgumentException::class);
- $this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
+ $this->expectExceptionMessage(\sprintf('Command name "%s" is invalid.', $name));
(new \TestCommand())->setName($name);
}
diff --git a/Tests/Descriptor/AbstractDescriptorTestCase.php b/Tests/Descriptor/AbstractDescriptorTestCase.php
index 1f813048..93658f4b 100644
--- a/Tests/Descriptor/AbstractDescriptorTestCase.php
+++ b/Tests/Descriptor/AbstractDescriptorTestCase.php
@@ -87,7 +87,7 @@ abstract class AbstractDescriptorTestCase extends TestCase
{
$data = [];
foreach ($objects as $name => $object) {
- $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, static::getFormat()));
+ $description = file_get_contents(\sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, static::getFormat()));
$data[] = [$object, $description];
}
diff --git a/Tests/Helper/ProgressIndicatorTest.php b/Tests/Helper/ProgressIndicatorTest.php
index 7f7dbc0a..8e2e10e3 100644
--- a/Tests/Helper/ProgressIndicatorTest.php
+++ b/Tests/Helper/ProgressIndicatorTest.php
@@ -179,6 +179,6 @@ class ProgressIndicatorTest extends TestCase
{
$count = substr_count($expected, "\n");
- return "\x0D\x1B[2K".($count ? sprintf("\033[%dA", $count) : '').$expected;
+ return "\x0D\x1B[2K".($count ? \sprintf("\033[%dA", $count) : '').$expected;
}
}
diff --git a/Tests/Input/InputDefinitionTest.php b/Tests/Input/InputDefinitionTest.php
index 470f3ca7..4479f440 100644
--- a/Tests/Input/InputDefinitionTest.php
+++ b/Tests/Input/InputDefinitionTest.php
@@ -113,7 +113,7 @@ class InputDefinitionTest extends TestCase
{
$this->initializeArguments();
$this->expectException(\LogicException::class);
- $this->expectExceptionMessage(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $this->foo2->getName(), $this->foo->getName()));
+ $this->expectExceptionMessage(\sprintf('Cannot add a required argument "%s" after an optional one "%s".', $this->foo2->getName(), $this->foo->getName()));
$definition = new InputDefinition();
$definition->addArgument($this->foo);
diff --git a/Tests/Output/ConsoleSectionOutputTest.php b/Tests/Output/ConsoleSectionOutputTest.php
index e50f8d54..6d2fa6c3 100644
--- a/Tests/Output/ConsoleSectionOutputTest.php
+++ b/Tests/Output/ConsoleSectionOutputTest.php
@@ -44,7 +44,7 @@ class ConsoleSectionOutputTest extends TestCase
$output->clear();
rewind($output->getStream());
- $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
+ $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.\sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
}
public function testClearNumberOfLines()
@@ -56,7 +56,7 @@ class ConsoleSectionOutputTest extends TestCase
$output->clear(2);
rewind($output->getStream());
- $this->assertEquals("Foo\nBar\nBaz\nFooBar".\PHP_EOL.sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
+ $this->assertEquals("Foo\nBar\nBaz\nFooBar".\PHP_EOL.\sprintf("\x1b[%dA", 2)."\x1b[0J", stream_get_contents($output->getStream()));
}
public function testClearNumberOfLinesWithMultipleSections()
@@ -197,7 +197,7 @@ class ConsoleSectionOutputTest extends TestCase
$output->overwrite('Bar');
rewind($output->getStream());
- $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'.\PHP_EOL.sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.\PHP_EOL, stream_get_contents($output->getStream()));
+ $this->assertEquals('Foo'.\PHP_EOL.'Bar'.\PHP_EOL.'Baz'.\PHP_EOL.\sprintf("\x1b[%dA", 3)."\x1b[0J".'Bar'.\PHP_EOL, stream_get_contents($output->getStream()));
}
public function testAddingMultipleSections()
diff --git a/Tests/Question/ConfirmationQuestionTest.php b/Tests/Question/ConfirmationQuestionTest.php
index 44f4c870..bd11047b 100644
--- a/Tests/Question/ConfirmationQuestionTest.php
+++ b/Tests/Question/ConfirmationQuestionTest.php
@@ -26,7 +26,7 @@ class ConfirmationQuestionTest extends TestCase
foreach ($answers as $answer) {
$normalizer = $sut->getNormalizer();
$actual = $normalizer($answer);
- $this->assertEquals($expected, $actual, sprintf($message, $answer));
+ $this->assertEquals($expected, $actual, \sprintf($message, $answer));
}
}