mirror of
https://github.com/symfony/console.git
synced 2026-03-24 01:12:13 +01:00
Prefix all sprintf() calls
This commit is contained in:
@@ -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 <info>%s</info>', $this->getName(), $this->getVersion());
|
||||
return \sprintf('%s <info>%s</info>', $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('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
|
||||
$output->writeln(\sprintf('<info>%s</info>', 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('<comment>%s</comment>', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
|
||||
$messages[] = \sprintf('<comment>%s</comment>', OutputFormatter::escape(\sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
|
||||
}
|
||||
$messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
|
||||
$messages[] = $emptyLine = \sprintf('<error>%s</error>', str_repeat(' ', $len));
|
||||
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
|
||||
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
|
||||
$messages[] = \sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
|
||||
}
|
||||
foreach ($lines as $line) {
|
||||
$messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
|
||||
$messages[] = \sprintf('<error> %s %s</error>', 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 <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
|
||||
$output->writeln(\sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
|
||||
}
|
||||
|
||||
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -98,9 +98,9 @@ EOH
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
if ($shell) {
|
||||
$output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
|
||||
$output->writeln(\sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
|
||||
} else {
|
||||
$output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
|
||||
$output->writeln(\sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
|
||||
}
|
||||
|
||||
return 2;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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];
|
||||
|
||||
14
Cursor.php
14
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);
|
||||
|
||||
|
||||
@@ -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'])
|
||||
);
|
||||
|
||||
|
||||
@@ -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() ?? '');
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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))),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
|
||||
$default = \sprintf('<comment> [default: %s]</comment>', $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(' <info>%s</info> %s%s%s',
|
||||
$this->writeText(\sprintf(' <info>%s</info> %s%s%s',
|
||||
$argument->getName(),
|
||||
str_repeat(' ', $spacingWidth),
|
||||
// + 4 = 2 spaces before <info>, 2 spaces after </info>
|
||||
@@ -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('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
|
||||
$default = \sprintf('<comment> [default: %s]</comment>', $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(' <info>%s</info> %s%s%s%s',
|
||||
$this->writeText(\sprintf(' <info>%s</info> %s%s%s%s',
|
||||
$synopsis,
|
||||
str_repeat(' ', $spacingWidth),
|
||||
// + 4 = 2 spaces before <info>, 2 spaces after </info>
|
||||
@@ -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('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
|
||||
$this->writeText(\sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
|
||||
} else {
|
||||
$this->writeText('<comment>Available commands:</comment>', $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(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
|
||||
$this->writeText(\sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)];
|
||||
|
||||
@@ -31,7 +31,7 @@ class DebugFormatterHelper extends Helper
|
||||
{
|
||||
$this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
|
||||
|
||||
return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
|
||||
return \sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%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<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
|
||||
$message .= \sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
|
||||
$this->started[$id]['err'] = true;
|
||||
}
|
||||
|
||||
$message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
|
||||
$message .= str_replace("\n", \sprintf("\n%s<bg=red;fg=white> %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<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
|
||||
$message .= \sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
|
||||
$this->started[$id]['out'] = true;
|
||||
}
|
||||
|
||||
$message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
|
||||
$message .= str_replace("\n", \sprintf("\n%s<bg=green;fg=white> %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<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
|
||||
return \sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
|
||||
}
|
||||
|
||||
$message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
|
||||
$message = \sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%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('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
|
||||
return \sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -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']];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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('<error>%s</error>', $this->escapeString($error)));
|
||||
$output->writeln(\sprintf('<error>%s</error>', $this->escapeString($error)));
|
||||
}
|
||||
|
||||
return $process;
|
||||
|
||||
@@ -621,7 +621,7 @@ final class ProgressBar
|
||||
}
|
||||
|
||||
if (isset($matches[2])) {
|
||||
$text = sprintf('%'.$matches[2], $text);
|
||||
$text = \sprintf('%'.$matches[2], $text);
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(' <info>%s</info>:', $text);
|
||||
$text = \sprintf(' <info>%s</info>:', $text);
|
||||
|
||||
break;
|
||||
|
||||
case $question instanceof ConfirmationQuestion:
|
||||
$text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
|
||||
$text = \sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
|
||||
|
||||
break;
|
||||
|
||||
@@ -53,18 +53,18 @@ class SymfonyQuestionHelper extends QuestionHelper
|
||||
$default[$key] = $choices[trim($value)];
|
||||
}
|
||||
|
||||
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
|
||||
$text = \sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
|
||||
|
||||
break;
|
||||
|
||||
case $question instanceof ChoiceQuestion:
|
||||
$choices = $question->getChoices();
|
||||
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
|
||||
$text = \sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
|
||||
$text = \sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
|
||||
}
|
||||
|
||||
$output->writeln($text);
|
||||
|
||||
@@ -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(
|
||||
'<comment>%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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -73,8 +73,8 @@ class SymfonyStyle extends OutputStyle
|
||||
{
|
||||
$this->autoPrependBlock();
|
||||
$this->writeln([
|
||||
sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
|
||||
sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
|
||||
\sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
|
||||
\sprintf('<comment>%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('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
|
||||
sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
|
||||
\sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
|
||||
\sprintf('<comment>%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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user