composer update
This commit is contained in:
3
vendor/symfony/console/.gitattributes
vendored
Normal file
3
vendor/symfony/console/.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/Tests export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/.gitignore export-ignore
|
||||
190
vendor/symfony/console/Application.php
vendored
190
vendor/symfony/console/Application.php
vendored
@@ -41,10 +41,12 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
/**
|
||||
* An Application is the container for a collection of commands.
|
||||
@@ -61,7 +63,7 @@ use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Application
|
||||
class Application implements ResetInterface
|
||||
{
|
||||
private $commands = [];
|
||||
private $wantHelps = false;
|
||||
@@ -124,22 +126,19 @@ class Application
|
||||
$output = new ConsoleOutput();
|
||||
}
|
||||
|
||||
$renderException = function ($e) use ($output) {
|
||||
if (!$e instanceof \Exception) {
|
||||
$e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
||||
}
|
||||
$renderException = function (\Throwable $e) use ($output) {
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$this->renderException($e, $output->getErrorOutput());
|
||||
$this->renderThrowable($e, $output->getErrorOutput());
|
||||
} else {
|
||||
$this->renderException($e, $output);
|
||||
$this->renderThrowable($e, $output);
|
||||
}
|
||||
};
|
||||
if ($phpHandler = set_exception_handler($renderException)) {
|
||||
restore_exception_handler();
|
||||
if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
|
||||
$debugHandler = true;
|
||||
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
|
||||
$phpHandler[0]->setExceptionHandler($debugHandler);
|
||||
if (!\is_array($phpHandler) || (!$phpHandler[0] instanceof ErrorHandler && !$phpHandler[0] instanceof LegacyErrorHandler)) {
|
||||
$errorHandler = true;
|
||||
} elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
|
||||
$phpHandler[0]->setExceptionHandler($errorHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +170,7 @@ class Application
|
||||
restore_exception_handler();
|
||||
}
|
||||
restore_exception_handler();
|
||||
} elseif (!$debugHandler) {
|
||||
} elseif (!$errorHandler) {
|
||||
$finalHandler = $phpHandler[0]->setExceptionHandler(null);
|
||||
if ($finalHandler !== $renderException) {
|
||||
$phpHandler[0]->setExceptionHandler($finalHandler);
|
||||
@@ -276,6 +275,13 @@ class Application
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
}
|
||||
|
||||
public function setHelperSet(HelperSet $helperSet)
|
||||
{
|
||||
$this->helperSet = $helperSet;
|
||||
@@ -472,12 +478,11 @@ class Application
|
||||
if (!$command->isEnabled()) {
|
||||
$command->setApplication(null);
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null === $command->getDefinition()) {
|
||||
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
|
||||
}
|
||||
// Will throw if the command is not correctly initialized.
|
||||
$command->getDefinition();
|
||||
|
||||
if (!$command->getName()) {
|
||||
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command)));
|
||||
@@ -548,6 +553,10 @@ class Application
|
||||
{
|
||||
$namespaces = [];
|
||||
foreach ($this->all() as $command) {
|
||||
if ($command->isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
|
||||
|
||||
foreach ($command->getAliases() as $alias) {
|
||||
@@ -623,6 +632,10 @@ class Application
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->has($name)) {
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
$allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
|
||||
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
|
||||
$commands = preg_grep('{^'.$expr.'}', $allCommands);
|
||||
@@ -641,6 +654,11 @@ class Application
|
||||
$message = sprintf('Command "%s" is not defined.', $name);
|
||||
|
||||
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
|
||||
// remove hidden commands
|
||||
$alternatives = array_filter($alternatives, function ($name) {
|
||||
return !$this->get($name)->isHidden();
|
||||
});
|
||||
|
||||
if (1 == \count($alternatives)) {
|
||||
$message .= "\n\nDid you mean this?\n ";
|
||||
} else {
|
||||
@@ -649,7 +667,7 @@ class Application
|
||||
$message .= implode("\n ", $alternatives);
|
||||
}
|
||||
|
||||
throw new CommandNotFoundException($message, $alternatives);
|
||||
throw new CommandNotFoundException($message, array_values($alternatives));
|
||||
}
|
||||
|
||||
// filter out aliases for commands which are already on the list
|
||||
@@ -663,28 +681,43 @@ class Application
|
||||
}));
|
||||
}
|
||||
|
||||
$exact = \in_array($name, $commands, true) || isset($aliases[$name]);
|
||||
if (\count($commands) > 1 && !$exact) {
|
||||
if (\count($commands) > 1) {
|
||||
$usableWidth = $this->terminal->getWidth() - 10;
|
||||
$abbrevs = array_values($commands);
|
||||
$maxLen = 0;
|
||||
foreach ($abbrevs as $abbrev) {
|
||||
$maxLen = max(Helper::strlen($abbrev), $maxLen);
|
||||
}
|
||||
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen) {
|
||||
$abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
|
||||
if (!$commandList[$cmd] instanceof Command) {
|
||||
return $cmd;
|
||||
$commandList[$cmd] = $this->commandLoader->get($cmd);
|
||||
}
|
||||
|
||||
if ($commandList[$cmd]->isHidden()) {
|
||||
unset($commands[array_search($cmd, $commands)]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription();
|
||||
|
||||
return Helper::strlen($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev;
|
||||
}, array_values($commands));
|
||||
$suggestions = $this->getAbbreviationSuggestions($abbrevs);
|
||||
|
||||
throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $name, $suggestions), array_values($commands));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->get($exact ? $name : reset($commands));
|
||||
$command = $this->get(reset($commands));
|
||||
|
||||
if ($command->isHidden()) {
|
||||
@trigger_error(sprintf('Command "%s" is hidden, finding it using an abbreviation is deprecated since Symfony 4.4, use its full name instead.', $command->getName()), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -755,20 +788,77 @@ class Application
|
||||
|
||||
/**
|
||||
* Renders a caught exception.
|
||||
*
|
||||
* @deprecated since Symfony 4.4, use "renderThrowable()" instead
|
||||
*/
|
||||
public function renderException(\Exception $e, OutputInterface $output)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
|
||||
|
||||
$this->doRenderException($e, $output);
|
||||
|
||||
$this->finishRenderThrowableOrException($output);
|
||||
}
|
||||
|
||||
public function renderThrowable(\Throwable $e, OutputInterface $output): void
|
||||
{
|
||||
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'renderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'renderException'))->getDeclaringClass()->getName()) {
|
||||
@trigger_error(sprintf('The "%s::renderException()" method is deprecated since Symfony 4.4, use "renderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
if (!$e instanceof \Exception) {
|
||||
$e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
||||
}
|
||||
|
||||
$this->renderException($e, $output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
|
||||
|
||||
$this->doRenderThrowable($e, $output);
|
||||
|
||||
$this->finishRenderThrowableOrException($output);
|
||||
}
|
||||
|
||||
private function finishRenderThrowableOrException(OutputInterface $output): void
|
||||
{
|
||||
if (null !== $this->runningCommand) {
|
||||
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
|
||||
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.4, use "doRenderThrowable()" instead
|
||||
*/
|
||||
protected function doRenderException(\Exception $e, OutputInterface $output)
|
||||
{
|
||||
@trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
$this->doActuallyRenderThrowable($e, $output);
|
||||
}
|
||||
|
||||
protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
|
||||
{
|
||||
if (__CLASS__ !== \get_class($this) && __CLASS__ === (new \ReflectionMethod($this, 'doRenderThrowable'))->getDeclaringClass()->getName() && __CLASS__ !== (new \ReflectionMethod($this, 'doRenderException'))->getDeclaringClass()->getName()) {
|
||||
@trigger_error(sprintf('The "%s::doRenderException()" method is deprecated since Symfony 4.4, use "doRenderThrowable()" instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
if (!$e instanceof \Exception) {
|
||||
$e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
|
||||
}
|
||||
|
||||
$this->doRenderException($e, $output);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->doActuallyRenderThrowable($e, $output);
|
||||
}
|
||||
|
||||
private function doActuallyRenderThrowable(\Throwable $e, OutputInterface $output): void
|
||||
{
|
||||
do {
|
||||
$message = trim($e->getMessage());
|
||||
@@ -831,11 +921,11 @@ class Application
|
||||
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
|
||||
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
|
||||
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
|
||||
$function = $trace[$i]['function'];
|
||||
$function = isset($trace[$i]['function']) ? $trace[$i]['function'] : '';
|
||||
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
|
||||
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
|
||||
|
||||
$output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $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);
|
||||
@@ -963,7 +1053,7 @@ class Application
|
||||
/**
|
||||
* Gets the name of the command based on input.
|
||||
*
|
||||
* @return string The command name
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getCommandName(InputInterface $input)
|
||||
{
|
||||
@@ -1017,12 +1107,8 @@ class Application
|
||||
|
||||
/**
|
||||
* Returns abbreviated suggestions in string format.
|
||||
*
|
||||
* @param array $abbrevs Abbreviated suggestions to convert
|
||||
*
|
||||
* @return string A formatted string of abbreviated suggestions
|
||||
*/
|
||||
private function getAbbreviationSuggestions($abbrevs)
|
||||
private function getAbbreviationSuggestions(array $abbrevs): string
|
||||
{
|
||||
return ' '.implode("\n ", $abbrevs);
|
||||
}
|
||||
@@ -1039,8 +1125,7 @@ class Application
|
||||
*/
|
||||
public function extractNamespace($name, $limit = null)
|
||||
{
|
||||
$parts = explode(':', $name);
|
||||
array_pop($parts);
|
||||
$parts = explode(':', $name, -1);
|
||||
|
||||
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
|
||||
}
|
||||
@@ -1049,12 +1134,9 @@ class Application
|
||||
* Finds alternative of $name among $collection,
|
||||
* if nothing is found in $collection, try in $abbrevs.
|
||||
*
|
||||
* @param string $name The string
|
||||
* @param iterable $collection The collection
|
||||
*
|
||||
* @return string[] A sorted array of similar string
|
||||
*/
|
||||
private function findAlternatives($name, $collection)
|
||||
private function findAlternatives(string $name, iterable $collection): array
|
||||
{
|
||||
$threshold = 1e3;
|
||||
$alternatives = [];
|
||||
@@ -1121,12 +1203,12 @@ class Application
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function isSingleCommand()
|
||||
public function isSingleCommand(): bool
|
||||
{
|
||||
return $this->singleCommand;
|
||||
}
|
||||
|
||||
private function splitStringByWidth($string, $width)
|
||||
private function splitStringByWidth(string $string, int $width): array
|
||||
{
|
||||
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
|
||||
// additionally, array_slice() is not enough as some character has doubled width.
|
||||
@@ -1138,15 +1220,21 @@ class Application
|
||||
$utf8String = mb_convert_encoding($string, 'utf8', $encoding);
|
||||
$lines = [];
|
||||
$line = '';
|
||||
foreach (preg_split('//u', $utf8String) as $char) {
|
||||
// test if $char could be appended to current line
|
||||
if (mb_strwidth($line.$char, 'utf8') <= $width) {
|
||||
$line .= $char;
|
||||
continue;
|
||||
|
||||
$offset = 0;
|
||||
while (preg_match('/.{1,10000}/u', $utf8String, $m, 0, $offset)) {
|
||||
$offset += \strlen($m[0]);
|
||||
|
||||
foreach (preg_split('//u', $m[0]) as $char) {
|
||||
// test if $char could be appended to current line
|
||||
if (mb_strwidth($line.$char, 'utf8') <= $width) {
|
||||
$line .= $char;
|
||||
continue;
|
||||
}
|
||||
// if not, push current line to array and make new line
|
||||
$lines[] = str_pad($line, $width);
|
||||
$line = $char;
|
||||
}
|
||||
// if not, push current line to array and make new line
|
||||
$lines[] = str_pad($line, $width);
|
||||
$line = $char;
|
||||
}
|
||||
|
||||
$lines[] = \count($lines) ? str_pad($line, $width) : $line;
|
||||
@@ -1159,11 +1247,9 @@ class Application
|
||||
/**
|
||||
* Returns all namespaces of the command name.
|
||||
*
|
||||
* @param string $name The full name of the command
|
||||
*
|
||||
* @return string[] The namespaces of the command
|
||||
*/
|
||||
private function extractAllNamespaces($name)
|
||||
private function extractAllNamespaces(string $name): array
|
||||
{
|
||||
// -1 as third argument is needed to skip the command short name when exploding
|
||||
$parts = explode(':', $name, -1);
|
||||
|
||||
20
vendor/symfony/console/CHANGELOG.md
vendored
20
vendor/symfony/console/CHANGELOG.md
vendored
@@ -1,6 +1,20 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* deprecated finding hidden commands using an abbreviation, use the full name instead
|
||||
* added `Question::setTrimmable` default to true to allow the answer to be trimmed
|
||||
* added method `minSecondsBetweenRedraws()` and `maxSecondsBetweenRedraws()` on `ProgressBar`
|
||||
* `Application` implements `ResetInterface`
|
||||
* marked all dispatched event classes as `@final`
|
||||
* added support for displaying table horizontally
|
||||
* deprecated returning `null` from `Command::execute()`, return `0` instead
|
||||
* Deprecated the `Application::renderException()` and `Application::doRenderException()` methods,
|
||||
use `renderThrowable()` and `doRenderThrowable()` instead.
|
||||
* added support for the `NO_COLOR` env var (https://no-color.org/)
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
@@ -32,7 +46,7 @@ CHANGELOG
|
||||
|
||||
* `OutputFormatter` throws an exception when unknown options are used
|
||||
* removed `QuestionHelper::setInputStream()/getInputStream()`
|
||||
* removed `Application::getTerminalWidth()/getTerminalHeight()` and
|
||||
* removed `Application::getTerminalWidth()/getTerminalHeight()` and
|
||||
`Application::setTerminalDimensions()/getTerminalDimensions()`
|
||||
* removed `ConsoleExceptionEvent`
|
||||
* removed `ConsoleEvents::EXCEPTION`
|
||||
@@ -58,7 +72,7 @@ CHANGELOG
|
||||
with value optional explicitly passed empty
|
||||
* added console.error event to catch exceptions thrown by other listeners
|
||||
* deprecated console.exception event in favor of console.error
|
||||
* added ability to handle `CommandNotFoundException` through the
|
||||
* added ability to handle `CommandNotFoundException` through the
|
||||
`console.error` event
|
||||
* deprecated default validation in `SymfonyQuestionHelper::ask`
|
||||
|
||||
@@ -74,7 +88,7 @@ CHANGELOG
|
||||
-----
|
||||
|
||||
* added truncate method to FormatterHelper
|
||||
* added setColumnWidth(s) method to Table
|
||||
* added setColumnWidth(s) method to Table
|
||||
|
||||
2.8.3
|
||||
-----
|
||||
|
||||
20
vendor/symfony/console/Command/Command.php
vendored
20
vendor/symfony/console/Command/Command.php
vendored
@@ -40,8 +40,8 @@ class Command
|
||||
private $aliases = [];
|
||||
private $definition;
|
||||
private $hidden = false;
|
||||
private $help;
|
||||
private $description;
|
||||
private $help = '';
|
||||
private $description = '';
|
||||
private $ignoreValidationErrors = false;
|
||||
private $applicationDefinitionMerged = false;
|
||||
private $applicationDefinitionMergedWithArgs = false;
|
||||
@@ -105,7 +105,7 @@ class Command
|
||||
/**
|
||||
* Gets the helper set.
|
||||
*
|
||||
* @return HelperSet A HelperSet instance
|
||||
* @return HelperSet|null A HelperSet instance
|
||||
*/
|
||||
public function getHelperSet()
|
||||
{
|
||||
@@ -115,7 +115,7 @@ class Command
|
||||
/**
|
||||
* Gets the application instance for this command.
|
||||
*
|
||||
* @return Application An Application instance
|
||||
* @return Application|null An Application instance
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
@@ -150,7 +150,7 @@ class Command
|
||||
* execute() method, you set the code to execute by passing
|
||||
* a Closure to the setCode() method.
|
||||
*
|
||||
* @return int|null null or 0 if everything went fine, or an error code
|
||||
* @return int 0 if everything went fine, or an exit code
|
||||
*
|
||||
* @throws LogicException When this abstract method is not implemented
|
||||
*
|
||||
@@ -253,6 +253,10 @@ class Command
|
||||
$statusCode = ($this->code)($input, $output);
|
||||
} else {
|
||||
$statusCode = $this->execute($input, $output);
|
||||
|
||||
if (!\is_int($statusCode)) {
|
||||
@trigger_error(sprintf('Return value of "%s::execute()" should always be of the type int since Symfony 4.4, %s returned.', \get_class($this), \gettype($statusCode)), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
return is_numeric($statusCode) ? (int) $statusCode : 0;
|
||||
@@ -339,6 +343,10 @@ class Command
|
||||
*/
|
||||
public function getDefinition()
|
||||
{
|
||||
if (null === $this->definition) {
|
||||
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($this)));
|
||||
}
|
||||
|
||||
return $this->definition;
|
||||
}
|
||||
|
||||
@@ -441,7 +449,7 @@ class Command
|
||||
/**
|
||||
* Returns the command name.
|
||||
*
|
||||
* @return string The command name
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
|
||||
@@ -77,5 +77,7 @@ EOF
|
||||
]);
|
||||
|
||||
$this->command = null;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,11 @@ EOF
|
||||
'raw_text' => $input->getOption('raw'),
|
||||
'namespace' => $input->getArgument('namespace'),
|
||||
]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
private function createDefinition()
|
||||
private function createDefinition(): InputDefinition
|
||||
{
|
||||
return new InputDefinition([
|
||||
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Lock\Factory;
|
||||
use Symfony\Component\Lock\Lock;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
@@ -29,10 +29,8 @@ trait LockableTrait
|
||||
|
||||
/**
|
||||
* Locks a command.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function lock($name = null, $blocking = false)
|
||||
private function lock(string $name = null, bool $blocking = false): bool
|
||||
{
|
||||
if (!class_exists(SemaphoreStore::class)) {
|
||||
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
|
||||
@@ -48,7 +46,7 @@ trait LockableTrait
|
||||
$store = new FlockStore();
|
||||
}
|
||||
|
||||
$this->lock = (new Factory($store))->createLock($name ?: $this->getName());
|
||||
$this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
|
||||
if (!$this->lock->acquire($blocking)) {
|
||||
$this->lock = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\CommandLoader;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\CommandLoader;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
@@ -16,8 +25,7 @@ class ContainerCommandLoader implements CommandLoaderInterface
|
||||
private $commandMap;
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container A container from which to load command services
|
||||
* @param array $commandMap An array with command names as keys and service ids as values
|
||||
* @param array $commandMap An array with command names as keys and service ids as values
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, array $commandMap)
|
||||
{
|
||||
|
||||
@@ -50,10 +50,7 @@ class ApplicationDescription
|
||||
$this->showHidden = $showHidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getNamespaces()
|
||||
public function getNamespaces(): array
|
||||
{
|
||||
if (null === $this->namespaces) {
|
||||
$this->inspectApplication();
|
||||
@@ -65,7 +62,7 @@ class ApplicationDescription
|
||||
/**
|
||||
* @return Command[]
|
||||
*/
|
||||
public function getCommands()
|
||||
public function getCommands(): array
|
||||
{
|
||||
if (null === $this->commands) {
|
||||
$this->inspectApplication();
|
||||
@@ -75,13 +72,9 @@ class ApplicationDescription
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Command
|
||||
*
|
||||
* @throws CommandNotFoundException
|
||||
*/
|
||||
public function getCommand($name)
|
||||
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));
|
||||
|
||||
@@ -23,9 +23,7 @@ interface DescriptorInterface
|
||||
/**
|
||||
* Describes an object if supported.
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param object $object
|
||||
* @param array $options
|
||||
* @param object $object
|
||||
*/
|
||||
public function describe(OutputInterface $output, $object, array $options = []);
|
||||
}
|
||||
|
||||
@@ -92,8 +92,6 @@ class JsonDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* Writes data as json.
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
private function writeData(array $data, array $options)
|
||||
{
|
||||
@@ -102,10 +100,7 @@ class JsonDescriptor extends Descriptor
|
||||
$this->write(json_encode($data, $flags));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getInputArgumentData(InputArgument $argument)
|
||||
private function getInputArgumentData(InputArgument $argument): array
|
||||
{
|
||||
return [
|
||||
'name' => $argument->getName(),
|
||||
@@ -116,10 +111,7 @@ class JsonDescriptor extends Descriptor
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getInputOptionData(InputOption $option)
|
||||
private function getInputOptionData(InputOption $option): array
|
||||
{
|
||||
return [
|
||||
'name' => '--'.$option->getName(),
|
||||
@@ -132,10 +124,7 @@ class JsonDescriptor extends Descriptor
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getInputDefinitionData(InputDefinition $definition)
|
||||
private function getInputDefinitionData(InputDefinition $definition): array
|
||||
{
|
||||
$inputArguments = [];
|
||||
foreach ($definition->getArguments() as $name => $argument) {
|
||||
@@ -150,10 +139,7 @@ class JsonDescriptor extends Descriptor
|
||||
return ['arguments' => $inputArguments, 'options' => $inputOptions];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getCommandData(Command $command)
|
||||
private function getCommandData(Command $command): array
|
||||
{
|
||||
$command->getSynopsis();
|
||||
$command->mergeApplicationDefinition(false);
|
||||
|
||||
@@ -167,7 +167,7 @@ class MarkdownDescriptor extends Descriptor
|
||||
}
|
||||
}
|
||||
|
||||
private function getApplicationTitle(Application $application)
|
||||
private function getApplicationTitle(Application $application): string
|
||||
{
|
||||
if ('UNKNOWN' !== $application->getName()) {
|
||||
if ('UNKNOWN' !== $application->getVersion()) {
|
||||
|
||||
@@ -250,7 +250,7 @@ class TextDescriptor extends Descriptor
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
private function writeText($content, array $options = [])
|
||||
private function writeText(string $content, array $options = [])
|
||||
{
|
||||
$this->write(
|
||||
isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
|
||||
|
||||
@@ -26,10 +26,7 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
*/
|
||||
class XmlDescriptor extends Descriptor
|
||||
{
|
||||
/**
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getInputDefinitionDocument(InputDefinition $definition)
|
||||
public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$dom->appendChild($definitionXML = $dom->createElement('definition'));
|
||||
@@ -47,10 +44,7 @@ class XmlDescriptor extends Descriptor
|
||||
return $dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getCommandDocument(Command $command)
|
||||
public function getCommandDocument(Command $command): \DOMDocument
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$dom->appendChild($commandXML = $dom->createElement('command'));
|
||||
@@ -80,13 +74,7 @@ class XmlDescriptor extends Descriptor
|
||||
return $dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Application $application
|
||||
* @param string|null $namespace
|
||||
*
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getApplicationDocument(Application $application, $namespace = null)
|
||||
public function getApplicationDocument(Application $application, string $namespace = null): \DOMDocument
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
$dom->appendChild($rootXml = $dom->createElement('symfony'));
|
||||
@@ -179,8 +167,6 @@ class XmlDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* Writes DOM document.
|
||||
*
|
||||
* @return \DOMDocument|string
|
||||
*/
|
||||
private function writeDocument(\DOMDocument $dom)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Symfony\Component\Console\Event;
|
||||
* Allows to do things before the command is executed, like skipping the command or changing the input.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ConsoleCommandEvent extends ConsoleEvent
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
* Allows to manipulate the exit code of a command after its execution.
|
||||
*
|
||||
* @author Francesco Levorato <git@flevour.net>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ConsoleTerminateEvent extends ConsoleEvent
|
||||
{
|
||||
|
||||
@@ -40,7 +40,9 @@ class ErrorListener implements EventSubscriberInterface
|
||||
$error = $event->getError();
|
||||
|
||||
if (!$inputString = $this->getInputString($event)) {
|
||||
return $this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
|
||||
$this->logger->error('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->error('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
|
||||
@@ -59,7 +61,9 @@ class ErrorListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if (!$inputString = $this->getInputString($event)) {
|
||||
return $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
|
||||
$this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);
|
||||
@@ -73,7 +77,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
];
|
||||
}
|
||||
|
||||
private static function getInputString(ConsoleEvent $event)
|
||||
private static function getInputString(ConsoleEvent $event): ?string
|
||||
{
|
||||
$commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
|
||||
$input = $event->getInput();
|
||||
|
||||
@@ -42,13 +42,9 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* Escapes trailing "\" in given text.
|
||||
*
|
||||
* @param string $text Text to escape
|
||||
*
|
||||
* @return string Escaped text
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function escapeTrailingBackslash($text)
|
||||
public static function escapeTrailingBackslash(string $text): string
|
||||
{
|
||||
if ('\\' === substr($text, -1)) {
|
||||
$len = \strlen($text);
|
||||
@@ -63,8 +59,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* Initializes console output formatter.
|
||||
*
|
||||
* @param bool $decorated Whether this formatter should actually decorate strings
|
||||
* @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances
|
||||
* @param OutputFormatterStyleInterface[] $styles Array of "name => FormatterStyle" instances
|
||||
*/
|
||||
public function __construct(bool $decorated = false, array $styles = [])
|
||||
{
|
||||
@@ -166,7 +161,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
if (!$open && !$tag) {
|
||||
// </>
|
||||
$this->styleStack->pop();
|
||||
} elseif (false === $style = $this->createStyleFromString($tag)) {
|
||||
} elseif (null === $style = $this->createStyleFromString($tag)) {
|
||||
$output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
|
||||
} elseif ($open) {
|
||||
$this->styleStack->push($style);
|
||||
@@ -194,17 +189,15 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Tries to create new style instance from string.
|
||||
*
|
||||
* @return OutputFormatterStyle|false False if string is not format string
|
||||
*/
|
||||
private function createStyleFromString(string $string)
|
||||
private function createStyleFromString(string $string): ?OutputFormatterStyleInterface
|
||||
{
|
||||
if (isset($this->styles[$string])) {
|
||||
return $this->styles[$string];
|
||||
}
|
||||
|
||||
if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$style = new OutputFormatterStyle();
|
||||
@@ -225,7 +218,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
$style->setOption($option);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ interface OutputFormatterInterface
|
||||
/**
|
||||
* Sets a new style.
|
||||
*
|
||||
* @param string $name The style name
|
||||
* @param OutputFormatterStyleInterface $style The style instance
|
||||
* @param string $name The style name
|
||||
*/
|
||||
public function setStyle($name, OutputFormatterStyleInterface $style);
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
*
|
||||
* @param string|null $foreground The style foreground color name
|
||||
* @param string|null $background The style background color name
|
||||
* @param array $options The style options
|
||||
*/
|
||||
public function __construct(string $foreground = null, string $background = null, array $options = [])
|
||||
{
|
||||
@@ -77,11 +76,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets style foreground color.
|
||||
*
|
||||
* @param string|null $color The color name
|
||||
*
|
||||
* @throws InvalidArgumentException When the color name isn't defined
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setForeground($color = null)
|
||||
{
|
||||
@@ -99,11 +94,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets style background color.
|
||||
*
|
||||
* @param string|null $color The color name
|
||||
*
|
||||
* @throws InvalidArgumentException When the color name isn't defined
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setBackground($color = null)
|
||||
{
|
||||
@@ -126,11 +117,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets some specific style option.
|
||||
*
|
||||
* @param string $option The option name
|
||||
*
|
||||
* @throws InvalidArgumentException When the option name isn't defined
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOption($option)
|
||||
{
|
||||
@@ -144,11 +131,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets some specific style option.
|
||||
*
|
||||
* @param string $option The option name
|
||||
*
|
||||
* @throws InvalidArgumentException When the option name isn't defined
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function unsetOption($option)
|
||||
{
|
||||
@@ -175,11 +158,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the style to a given text.
|
||||
*
|
||||
* @param string $text The text to style
|
||||
*
|
||||
* @return string
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply($text)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ interface OutputFormatterStyleInterface
|
||||
/**
|
||||
* Sets style foreground color.
|
||||
*
|
||||
* @param string $color The color name
|
||||
* @param string|null $color The color name
|
||||
*/
|
||||
public function setForeground($color = null);
|
||||
|
||||
|
||||
@@ -107,12 +107,7 @@ class DebugFormatterHelper extends Helper
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id The id of the formatting session
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getBorder($id)
|
||||
private function getBorder(string $id): string
|
||||
{
|
||||
return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,7 @@ class DescriptorHelper extends Helper
|
||||
* * format: string, the output format name
|
||||
* * raw_text: boolean, sets output type as raw
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param object $object
|
||||
* @param array $options
|
||||
* @param object $object
|
||||
*
|
||||
* @throws InvalidArgumentException when the given format is not supported
|
||||
*/
|
||||
@@ -72,8 +70,7 @@ class DescriptorHelper extends Helper
|
||||
/**
|
||||
* Registers a descriptor.
|
||||
*
|
||||
* @param string $format
|
||||
* @param DescriptorInterface $descriptor
|
||||
* @param string $format
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
3
vendor/symfony/console/Helper/HelperSet.php
vendored
3
vendor/symfony/console/Helper/HelperSet.php
vendored
@@ -40,8 +40,7 @@ class HelperSet implements \IteratorAggregate
|
||||
/**
|
||||
* Sets a helper.
|
||||
*
|
||||
* @param HelperInterface $helper The helper instance
|
||||
* @param string $alias An alias
|
||||
* @param string $alias An alias
|
||||
*/
|
||||
public function set(HelperInterface $helper, $alias = null)
|
||||
{
|
||||
|
||||
26
vendor/symfony/console/Helper/ProcessHelper.php
vendored
26
vendor/symfony/console/Helper/ProcessHelper.php
vendored
@@ -28,12 +28,11 @@ class ProcessHelper extends Helper
|
||||
/**
|
||||
* Runs an external process.
|
||||
*
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param array|Process $cmd An instance of Process or an array of the command and arguments
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param int $verbosity The threshold for verbosity
|
||||
* @param array|Process $cmd An instance of Process or an array of the command and arguments
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param int $verbosity The threshold for verbosity
|
||||
*
|
||||
* @return Process The process that ran
|
||||
*/
|
||||
@@ -92,11 +91,10 @@ class ProcessHelper extends Helper
|
||||
* This is identical to run() except that an exception is thrown if the process
|
||||
* exits with a non-zero exit code.
|
||||
*
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param string|Process $cmd An instance of Process or a command to run
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
* @param string|Process $cmd An instance of Process or a command to run
|
||||
* @param string|null $error An error message that must be displayed if something went wrong
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*
|
||||
* @return Process The process that ran
|
||||
*
|
||||
@@ -118,10 +116,6 @@ class ProcessHelper extends Helper
|
||||
/**
|
||||
* Wraps a Process callback to add debugging output.
|
||||
*
|
||||
* @param OutputInterface $output An OutputInterface interface
|
||||
* @param Process $process The Process
|
||||
* @param callable|null $callback A PHP callable
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null)
|
||||
@@ -141,7 +135,7 @@ class ProcessHelper extends Helper
|
||||
};
|
||||
}
|
||||
|
||||
private function escapeString($str)
|
||||
private function escapeString(string $str): string
|
||||
{
|
||||
return str_replace('<', '\\<', $str);
|
||||
}
|
||||
|
||||
75
vendor/symfony/console/Helper/ProgressBar.php
vendored
75
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -32,6 +32,10 @@ final class ProgressBar
|
||||
private $format;
|
||||
private $internalFormat;
|
||||
private $redrawFreq = 1;
|
||||
private $writeCount;
|
||||
private $lastWriteTime;
|
||||
private $minSecondsBetweenRedraws = 0;
|
||||
private $maxSecondsBetweenRedraws = 1;
|
||||
private $output;
|
||||
private $step = 0;
|
||||
private $max;
|
||||
@@ -42,16 +46,15 @@ final class ProgressBar
|
||||
private $messages = [];
|
||||
private $overwrite = true;
|
||||
private $terminal;
|
||||
private $firstRun = true;
|
||||
private $previousMessage;
|
||||
|
||||
private static $formatters;
|
||||
private static $formats;
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output An OutputInterface instance
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
*/
|
||||
public function __construct(OutputInterface $output, int $max = 0)
|
||||
public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 0.1)
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
@@ -61,12 +64,17 @@ final class ProgressBar
|
||||
$this->setMaxSteps($max);
|
||||
$this->terminal = new Terminal();
|
||||
|
||||
if (0 < $minSecondsBetweenRedraws) {
|
||||
$this->redrawFreq = null;
|
||||
$this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
|
||||
}
|
||||
|
||||
if (!$this->output->isDecorated()) {
|
||||
// disable overwrite when output does not support ANSI codes.
|
||||
$this->overwrite = false;
|
||||
|
||||
// set a reasonable redraw frequency so output isn't flooded
|
||||
$this->setRedrawFrequency($max / 10);
|
||||
$this->redrawFreq = null;
|
||||
}
|
||||
|
||||
$this->startTime = time();
|
||||
@@ -183,6 +191,11 @@ final class ProgressBar
|
||||
return $this->percent;
|
||||
}
|
||||
|
||||
public function getBarOffset(): int
|
||||
{
|
||||
return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? min(5, $this->barWidth / 15) * $this->writeCount : $this->step) % $this->barWidth);
|
||||
}
|
||||
|
||||
public function setBarWidth(int $size)
|
||||
{
|
||||
$this->barWidth = max(1, $size);
|
||||
@@ -238,9 +251,19 @@ final class ProgressBar
|
||||
*
|
||||
* @param int|float $freq The frequency in steps
|
||||
*/
|
||||
public function setRedrawFrequency(int $freq)
|
||||
public function setRedrawFrequency(?int $freq)
|
||||
{
|
||||
$this->redrawFreq = max($freq, 1);
|
||||
$this->redrawFreq = null !== $freq ? max(1, $freq) : null;
|
||||
}
|
||||
|
||||
public function minSecondsBetweenRedraws(float $seconds): void
|
||||
{
|
||||
$this->minSecondsBetweenRedraws = $seconds;
|
||||
}
|
||||
|
||||
public function maxSecondsBetweenRedraws(float $seconds): void
|
||||
{
|
||||
$this->maxSecondsBetweenRedraws = $seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +271,7 @@ final class ProgressBar
|
||||
*
|
||||
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
|
||||
*/
|
||||
public function iterate(iterable $iterable, ?int $max = null): iterable
|
||||
public function iterate(iterable $iterable, int $max = null): iterable
|
||||
{
|
||||
$this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
|
||||
|
||||
@@ -305,11 +328,27 @@ final class ProgressBar
|
||||
$step = 0;
|
||||
}
|
||||
|
||||
$prevPeriod = (int) ($this->step / $this->redrawFreq);
|
||||
$currPeriod = (int) ($step / $this->redrawFreq);
|
||||
$redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
|
||||
$prevPeriod = (int) ($this->step / $redrawFreq);
|
||||
$currPeriod = (int) ($step / $redrawFreq);
|
||||
$this->step = $step;
|
||||
$this->percent = $this->max ? (float) $this->step / $this->max : 0;
|
||||
if ($prevPeriod !== $currPeriod || $this->max === $step) {
|
||||
$timeInterval = microtime(true) - $this->lastWriteTime;
|
||||
|
||||
// Draw regardless of other limits
|
||||
if ($this->max === $step) {
|
||||
$this->display();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Throttling
|
||||
if ($timeInterval < $this->minSecondsBetweenRedraws) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw each step period, but not too late
|
||||
if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
@@ -393,8 +432,14 @@ final class ProgressBar
|
||||
*/
|
||||
private function overwrite(string $message): void
|
||||
{
|
||||
if ($this->previousMessage === $message) {
|
||||
return;
|
||||
}
|
||||
|
||||
$originalMessage = $message;
|
||||
|
||||
if ($this->overwrite) {
|
||||
if (!$this->firstRun) {
|
||||
if (null !== $this->previousMessage) {
|
||||
if ($this->output instanceof ConsoleSectionOutput) {
|
||||
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
|
||||
$this->output->clear($lines);
|
||||
@@ -412,9 +457,11 @@ final class ProgressBar
|
||||
$message = PHP_EOL.$message;
|
||||
}
|
||||
|
||||
$this->firstRun = false;
|
||||
$this->previousMessage = $originalMessage;
|
||||
$this->lastWriteTime = microtime(true);
|
||||
|
||||
$this->output->write($message);
|
||||
++$this->writeCount;
|
||||
}
|
||||
|
||||
private function determineBestFormat(): string
|
||||
@@ -436,7 +483,7 @@ final class ProgressBar
|
||||
{
|
||||
return [
|
||||
'bar' => function (self $bar, OutputInterface $output) {
|
||||
$completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
|
||||
$completeBars = $bar->getBarOffset();
|
||||
$display = str_repeat($bar->getBarCharacter(), $completeBars);
|
||||
if ($completeBars < $bar->getBarWidth()) {
|
||||
$emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
|
||||
|
||||
@@ -34,10 +34,9 @@ class ProgressIndicator
|
||||
private static $formats;
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
* @param string|null $format Indicator format
|
||||
* @param int $indicatorChangeInterval Change interval in milliseconds
|
||||
* @param array|null $indicatorValues Animated indicator characters
|
||||
* @param string|null $format Indicator format
|
||||
* @param int $indicatorChangeInterval Change interval in milliseconds
|
||||
* @param array|null $indicatorValues Animated indicator characters
|
||||
*/
|
||||
public function __construct(OutputInterface $output, string $format = null, int $indicatorChangeInterval = 100, array $indicatorValues = null)
|
||||
{
|
||||
@@ -192,18 +191,16 @@ class ProgressIndicator
|
||||
return;
|
||||
}
|
||||
|
||||
$self = $this;
|
||||
|
||||
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
|
||||
if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
return $formatter($self);
|
||||
$this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
|
||||
if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
return $formatter($this);
|
||||
}
|
||||
|
||||
return $matches[0];
|
||||
}, $this->format));
|
||||
}
|
||||
|
||||
private function determineBestFormat()
|
||||
private function determineBestFormat(): string
|
||||
{
|
||||
switch ($this->output->getVerbosity()) {
|
||||
// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
|
||||
@@ -230,12 +227,12 @@ class ProgressIndicator
|
||||
}
|
||||
}
|
||||
|
||||
private function getCurrentTimeInMilliseconds()
|
||||
private function getCurrentTimeInMilliseconds(): float
|
||||
{
|
||||
return round(microtime(true) * 1000);
|
||||
}
|
||||
|
||||
private static function initPlaceholderFormatters()
|
||||
private static function initPlaceholderFormatters(): array
|
||||
{
|
||||
return [
|
||||
'indicator' => function (self $indicator) {
|
||||
@@ -253,7 +250,7 @@ class ProgressIndicator
|
||||
];
|
||||
}
|
||||
|
||||
private static function initFormats()
|
||||
private static function initFormats(): array
|
||||
{
|
||||
return [
|
||||
'normal' => ' %indicator% %message%',
|
||||
|
||||
54
vendor/symfony/console/Helper/QuestionHelper.php
vendored
54
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -21,6 +21,7 @@ use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* The QuestionHelper class provides helpers to interact with the user.
|
||||
@@ -64,7 +65,7 @@ class QuestionHelper extends Helper
|
||||
|
||||
$default = explode(',', $default);
|
||||
foreach ($default as $k => $v) {
|
||||
$v = trim($v);
|
||||
$v = $question->isTrimmable() ? trim($v) : $v;
|
||||
$default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
|
||||
}
|
||||
}
|
||||
@@ -117,11 +118,12 @@ class QuestionHelper extends Helper
|
||||
$inputStream = $this->inputStream ?: STDIN;
|
||||
$autocomplete = $question->getAutocompleterCallback();
|
||||
|
||||
if (null === $autocomplete || !$this->hasSttyAvailable()) {
|
||||
if (null === $autocomplete || !Terminal::hasSttyAvailable()) {
|
||||
$ret = false;
|
||||
if ($question->isHidden()) {
|
||||
try {
|
||||
$ret = trim($this->getHiddenResponse($output, $inputStream));
|
||||
$hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable());
|
||||
$ret = $question->isTrimmable() ? trim($hiddenResponse) : $hiddenResponse;
|
||||
} catch (RuntimeException $e) {
|
||||
if (!$question->isHiddenFallback()) {
|
||||
throw $e;
|
||||
@@ -134,10 +136,13 @@ class QuestionHelper extends Helper
|
||||
if (false === $ret) {
|
||||
throw new RuntimeException('Aborted.');
|
||||
}
|
||||
$ret = trim($ret);
|
||||
if ($question->isTrimmable()) {
|
||||
$ret = trim($ret);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ret = trim($this->autocomplete($output, $question, $inputStream, $autocomplete));
|
||||
$autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete);
|
||||
$ret = $question->isTrimmable() ? trim($autocomplete) : $autocomplete;
|
||||
}
|
||||
|
||||
if ($output instanceof ConsoleSectionOutput) {
|
||||
@@ -331,7 +336,7 @@ class QuestionHelper extends Helper
|
||||
return $fullChoice;
|
||||
}
|
||||
|
||||
private function mostRecentlyEnteredValue($entered)
|
||||
private function mostRecentlyEnteredValue(string $entered): string
|
||||
{
|
||||
// Determine the most recent value that the user entered
|
||||
if (false === strpos($entered, ',')) {
|
||||
@@ -349,12 +354,12 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Gets a hidden response from user.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param resource $inputStream The handler resource
|
||||
* @param resource $inputStream The handler resource
|
||||
* @param bool $trimmable Is the answer trimmable
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream): string
|
||||
private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||
@@ -366,7 +371,8 @@ class QuestionHelper extends Helper
|
||||
$exe = $tmpExe;
|
||||
}
|
||||
|
||||
$value = rtrim(shell_exec($exe));
|
||||
$sExec = shell_exec($exe);
|
||||
$value = $trimmable ? rtrim($sExec) : $sExec;
|
||||
$output->writeln('');
|
||||
|
||||
if (isset($tmpExe)) {
|
||||
@@ -376,7 +382,7 @@ class QuestionHelper extends Helper
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($this->hasSttyAvailable()) {
|
||||
if (Terminal::hasSttyAvailable()) {
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
shell_exec('stty -echo');
|
||||
@@ -386,8 +392,9 @@ class QuestionHelper extends Helper
|
||||
if (false === $value) {
|
||||
throw new RuntimeException('Aborted.');
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
if ($trimmable) {
|
||||
$value = trim($value);
|
||||
}
|
||||
$output->writeln('');
|
||||
|
||||
return $value;
|
||||
@@ -396,7 +403,8 @@ class QuestionHelper extends Helper
|
||||
if (false !== $shell = $this->getShell()) {
|
||||
$readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
|
||||
$command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
|
||||
$value = rtrim(shell_exec($command));
|
||||
$sCommand = shell_exec($command);
|
||||
$value = $trimmable ? rtrim($sCommand) : $sCommand;
|
||||
$output->writeln('');
|
||||
|
||||
return $value;
|
||||
@@ -408,9 +416,7 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Validates an attempt.
|
||||
*
|
||||
* @param callable $interviewer A callable that will ask for a question and return the result
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param Question $question A Question instance
|
||||
* @param callable $interviewer A callable that will ask for a question and return the result
|
||||
*
|
||||
* @return mixed The validated response
|
||||
*
|
||||
@@ -462,18 +468,4 @@ class QuestionHelper extends Helper
|
||||
|
||||
return self::$shell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether Stty is available or not.
|
||||
*/
|
||||
private function hasSttyAvailable(): bool
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
}
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
}
|
||||
|
||||
69
vendor/symfony/console/Helper/Table.php
vendored
69
vendor/symfony/console/Helper/Table.php
vendored
@@ -48,6 +48,7 @@ class Table
|
||||
* Table rows.
|
||||
*/
|
||||
private $rows = [];
|
||||
private $horizontal = false;
|
||||
|
||||
/**
|
||||
* Column widths cache.
|
||||
@@ -102,8 +103,7 @@ class Table
|
||||
/**
|
||||
* Sets a style definition.
|
||||
*
|
||||
* @param string $name The style name
|
||||
* @param TableStyle $style A TableStyle instance
|
||||
* @param string $name The style name
|
||||
*/
|
||||
public static function setStyleDefinition($name, TableStyle $style)
|
||||
{
|
||||
@@ -207,8 +207,6 @@ class Table
|
||||
/**
|
||||
* Sets the minimum width of all columns.
|
||||
*
|
||||
* @param array $widths
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidths(array $widths)
|
||||
@@ -325,6 +323,13 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHorizontal(bool $horizontal = true): self
|
||||
{
|
||||
$this->horizontal = $horizontal;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders table to output.
|
||||
*
|
||||
@@ -340,14 +345,35 @@ class Table
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$rows = array_merge($this->headers, [$divider = new TableSeparator()], $this->rows);
|
||||
$divider = new TableSeparator();
|
||||
if ($this->horizontal) {
|
||||
$rows = [];
|
||||
foreach ($this->headers[0] ?? [] as $i => $header) {
|
||||
$rows[$i] = [$header];
|
||||
foreach ($this->rows as $row) {
|
||||
if ($row instanceof TableSeparator) {
|
||||
continue;
|
||||
}
|
||||
if (isset($row[$i])) {
|
||||
$rows[$i][] = $row[$i];
|
||||
} elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) {
|
||||
// Noop, there is a "title"
|
||||
} else {
|
||||
$rows[$i][] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$rows = array_merge($this->headers, [$divider], $this->rows);
|
||||
}
|
||||
|
||||
$this->calculateNumberOfColumns($rows);
|
||||
|
||||
$rows = $this->buildTableRows($rows);
|
||||
$this->calculateColumnsWidth($rows);
|
||||
|
||||
$isHeader = true;
|
||||
$isFirstRow = false;
|
||||
$isHeader = !$this->horizontal;
|
||||
$isFirstRow = $this->horizontal;
|
||||
foreach ($rows as $row) {
|
||||
if ($divider === $row) {
|
||||
$isHeader = false;
|
||||
@@ -372,8 +398,11 @@ class Table
|
||||
$this->renderRowSeparator(self::SEPARATOR_TOP, $this->headerTitle, $this->style->getHeaderTitleFormat());
|
||||
}
|
||||
}
|
||||
|
||||
$this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
|
||||
if ($this->horizontal) {
|
||||
$this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());
|
||||
} else {
|
||||
$this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
|
||||
}
|
||||
}
|
||||
$this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
|
||||
|
||||
@@ -439,7 +468,7 @@ class Table
|
||||
/**
|
||||
* Renders vertical column separator.
|
||||
*/
|
||||
private function renderColumnSeparator($type = self::BORDER_OUTSIDE)
|
||||
private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE): string
|
||||
{
|
||||
$borders = $this->style->getBorderChars();
|
||||
|
||||
@@ -453,13 +482,17 @@ class Table
|
||||
*
|
||||
* | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
|
||||
*/
|
||||
private function renderRow(array $row, string $cellFormat)
|
||||
private function renderRow(array $row, string $cellFormat, string $firstCellFormat = null)
|
||||
{
|
||||
$rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
|
||||
$columns = $this->getRowColumns($row);
|
||||
$last = \count($columns) - 1;
|
||||
foreach ($columns as $i => $column) {
|
||||
$rowContent .= $this->renderCell($row, $column, $cellFormat);
|
||||
if ($firstCellFormat && 0 === $i) {
|
||||
$rowContent .= $this->renderCell($row, $column, $firstCellFormat);
|
||||
} else {
|
||||
$rowContent .= $this->renderCell($row, $column, $cellFormat);
|
||||
}
|
||||
$rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE);
|
||||
}
|
||||
$this->output->writeln($rowContent);
|
||||
@@ -468,7 +501,7 @@ class Table
|
||||
/**
|
||||
* Renders table cell with padding.
|
||||
*/
|
||||
private function renderCell(array $row, int $column, string $cellFormat)
|
||||
private function renderCell(array $row, int $column, string $cellFormat): string
|
||||
{
|
||||
$cell = isset($row[$column]) ? $row[$column] : '';
|
||||
$width = $this->effectiveColumnWidths[$column];
|
||||
@@ -499,7 +532,7 @@ class Table
|
||||
/**
|
||||
* Calculate number of columns for this table.
|
||||
*/
|
||||
private function calculateNumberOfColumns($rows)
|
||||
private function calculateNumberOfColumns(array $rows)
|
||||
{
|
||||
$columns = [0];
|
||||
foreach ($rows as $row) {
|
||||
@@ -513,7 +546,7 @@ class Table
|
||||
$this->numberOfColumns = max($columns);
|
||||
}
|
||||
|
||||
private function buildTableRows($rows)
|
||||
private function buildTableRows(array $rows): TableRows
|
||||
{
|
||||
/** @var WrappableOutputFormatterInterface $formatter */
|
||||
$formatter = $this->output->getFormatter();
|
||||
@@ -547,7 +580,7 @@ class Table
|
||||
}
|
||||
}
|
||||
|
||||
return new TableRows(function () use ($rows, $unmergedRows) {
|
||||
return new TableRows(function () use ($rows, $unmergedRows): \Traversable {
|
||||
foreach ($rows as $rowKey => $row) {
|
||||
yield $this->fillCells($row);
|
||||
|
||||
@@ -751,7 +784,7 @@ class Table
|
||||
$this->numberOfColumns = null;
|
||||
}
|
||||
|
||||
private static function initStyles()
|
||||
private static function initStyles(): array
|
||||
{
|
||||
$borderless = new TableStyle();
|
||||
$borderless
|
||||
@@ -798,7 +831,7 @@ class Table
|
||||
];
|
||||
}
|
||||
|
||||
private function resolveStyle($name)
|
||||
private function resolveStyle($name): TableStyle
|
||||
{
|
||||
if ($name instanceof TableStyle) {
|
||||
return $name;
|
||||
|
||||
2
vendor/symfony/console/Helper/TableRows.php
vendored
2
vendor/symfony/console/Helper/TableRows.php
vendored
@@ -23,7 +23,7 @@ class TableRows implements \IteratorAggregate
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
$g = $this->generator;
|
||||
|
||||
|
||||
2
vendor/symfony/console/Helper/TableStyle.php
vendored
2
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -192,7 +192,7 @@ class TableStyle
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getBorderChars()
|
||||
public function getBorderChars(): array
|
||||
{
|
||||
return [
|
||||
$this->horizontalOutsideBorderChar,
|
||||
|
||||
31
vendor/symfony/console/Input/ArgvInput.php
vendored
31
vendor/symfony/console/Input/ArgvInput.php
vendored
@@ -44,8 +44,7 @@ class ArgvInput extends Input
|
||||
private $parsed;
|
||||
|
||||
/**
|
||||
* @param array|null $argv An array of parameters from the CLI (in the argv format)
|
||||
* @param InputDefinition|null $definition A InputDefinition instance
|
||||
* @param array|null $argv An array of parameters from the CLI (in the argv format)
|
||||
*/
|
||||
public function __construct(array $argv = null, InputDefinition $definition = null)
|
||||
{
|
||||
@@ -90,10 +89,8 @@ class ArgvInput extends Input
|
||||
|
||||
/**
|
||||
* Parses a short option.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*/
|
||||
private function parseShortOption($token)
|
||||
private function parseShortOption(string $token)
|
||||
{
|
||||
$name = substr($token, 1);
|
||||
|
||||
@@ -112,11 +109,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Parses a short option set.
|
||||
*
|
||||
* @param string $name The current token
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function parseShortOptionSet($name)
|
||||
private function parseShortOptionSet(string $name)
|
||||
{
|
||||
$len = \strlen($name);
|
||||
for ($i = 0; $i < $len; ++$i) {
|
||||
@@ -138,10 +133,8 @@ class ArgvInput extends Input
|
||||
|
||||
/**
|
||||
* Parses a long option.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*/
|
||||
private function parseLongOption($token)
|
||||
private function parseLongOption(string $token)
|
||||
{
|
||||
$name = substr($token, 2);
|
||||
|
||||
@@ -158,11 +151,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Parses an argument.
|
||||
*
|
||||
* @param string $token The current token
|
||||
*
|
||||
* @throws RuntimeException When too many arguments are given
|
||||
*/
|
||||
private function parseArgument($token)
|
||||
private function parseArgument(string $token)
|
||||
{
|
||||
$c = \count($this->arguments);
|
||||
|
||||
@@ -190,12 +181,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Adds a short option value.
|
||||
*
|
||||
* @param string $shortcut The short option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption($shortcut, $value)
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@@ -207,12 +195,9 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* Adds a long option value.
|
||||
*
|
||||
* @param string $name The long option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addLongOption($name, $value)
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
|
||||
@@ -283,6 +268,8 @@ class ArgvInput extends Input
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
18
vendor/symfony/console/Input/ArrayInput.php
vendored
18
vendor/symfony/console/Input/ArrayInput.php
vendored
@@ -46,6 +46,8 @@ class ArrayInput extends Input
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +134,7 @@ class ArrayInput extends Input
|
||||
}
|
||||
if (0 === strpos($key, '--')) {
|
||||
$this->addLongOption(substr($key, 2), $value);
|
||||
} elseif ('-' === $key[0]) {
|
||||
} elseif (0 === strpos($key, '-')) {
|
||||
$this->addShortOption(substr($key, 1), $value);
|
||||
} else {
|
||||
$this->addArgument($key, $value);
|
||||
@@ -143,12 +145,9 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds a short option value.
|
||||
*
|
||||
* @param string $shortcut The short option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption($shortcut, $value)
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@@ -160,13 +159,10 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds a long option value.
|
||||
*
|
||||
* @param string $name The long option key
|
||||
* @param mixed $value The value for the option
|
||||
*
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
* @throws InvalidOptionException When a required value is missing
|
||||
*/
|
||||
private function addLongOption($name, $value)
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
|
||||
@@ -190,8 +186,8 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds an argument value.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
* @param mixed $value The value for the argument
|
||||
* @param string|int $name The argument name
|
||||
* @param mixed $value The value for the argument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
|
||||
@@ -333,15 +333,11 @@ class InputDefinition
|
||||
/**
|
||||
* Returns the InputOption name given a shortcut.
|
||||
*
|
||||
* @param string $shortcut The shortcut
|
||||
*
|
||||
* @return string The InputOption name
|
||||
*
|
||||
* @throws InvalidArgumentException When option given does not exist
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function shortcutToName($shortcut)
|
||||
public function shortcutToName(string $shortcut): string
|
||||
{
|
||||
if (!isset($this->shortcuts[$shortcut])) {
|
||||
throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
|
||||
6
vendor/symfony/console/Input/StringInput.php
vendored
6
vendor/symfony/console/Input/StringInput.php
vendored
@@ -40,13 +40,9 @@ class StringInput extends ArgvInput
|
||||
/**
|
||||
* Tokenizes a string.
|
||||
*
|
||||
* @param string $input The input to tokenize
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*
|
||||
* @throws InvalidArgumentException When unable to parse input (should never happen)
|
||||
*/
|
||||
private function tokenize($input)
|
||||
private function tokenize(string $input): array
|
||||
{
|
||||
$tokens = [];
|
||||
$length = \strlen($input);
|
||||
|
||||
@@ -22,7 +22,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*
|
||||
* @see http://www.php-fig.org/psr/psr-3/
|
||||
* @see https://www.php-fig.org/psr/psr-3/
|
||||
*/
|
||||
class ConsoleLogger extends AbstractLogger
|
||||
{
|
||||
@@ -61,6 +61,8 @@ class ConsoleLogger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
|
||||
@@ -125,10 +125,8 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
/**
|
||||
* Checks if current executing environment is IBM iSeries (OS400), which
|
||||
* doesn't properly convert character-encodings between ASCII to EBCDIC.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isRunningOS400()
|
||||
private function isRunningOS400(): bool
|
||||
{
|
||||
$checks = [
|
||||
\function_exists('php_uname') ? php_uname('s') : '',
|
||||
|
||||
@@ -95,7 +95,9 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
protected function doWrite($message, $newline)
|
||||
{
|
||||
if (!$this->isDecorated()) {
|
||||
return parent::doWrite($message, $newline);
|
||||
parent::doWrite($message, $newline);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$erasedContent = $this->popStreamContentUntilCurrentSection();
|
||||
|
||||
@@ -97,6 +97,11 @@ class StreamOutput extends Output
|
||||
*/
|
||||
protected function hasColorSupport()
|
||||
{
|
||||
// Follow https://no-color.org/
|
||||
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('Hyper' === getenv('TERM_PROGRAM')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,19 +129,23 @@ class ChoiceQuestion extends Question
|
||||
$isAssoc = $this->isAssoc($choices);
|
||||
|
||||
return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
|
||||
// Collapse all spaces.
|
||||
$selectedChoices = str_replace(' ', '', $selected);
|
||||
|
||||
if ($multiselect) {
|
||||
// Check for a separated comma values
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selected, $matches)) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
|
||||
}
|
||||
$selectedChoices = explode(',', $selectedChoices);
|
||||
|
||||
$selectedChoices = explode(',', $selected);
|
||||
} else {
|
||||
$selectedChoices = [$selected];
|
||||
}
|
||||
|
||||
if ($this->isTrimmable()) {
|
||||
foreach ($selectedChoices as $k => $v) {
|
||||
$selectedChoices[$k] = trim($v);
|
||||
}
|
||||
}
|
||||
|
||||
$multiselectChoices = [];
|
||||
foreach ($selectedChoices as $value) {
|
||||
$results = [];
|
||||
|
||||
@@ -35,10 +35,8 @@ class ConfirmationQuestion extends Question
|
||||
|
||||
/**
|
||||
* Returns the default answer normalizer.
|
||||
*
|
||||
* @return callable
|
||||
*/
|
||||
private function getDefaultNormalizer()
|
||||
private function getDefaultNormalizer(): callable
|
||||
{
|
||||
$default = $this->getDefault();
|
||||
$regex = $this->trueAnswerRegex;
|
||||
|
||||
22
vendor/symfony/console/Question/Question.php
vendored
22
vendor/symfony/console/Question/Question.php
vendored
@@ -29,6 +29,7 @@ class Question
|
||||
private $validator;
|
||||
private $default;
|
||||
private $normalizer;
|
||||
private $trimmable = true;
|
||||
|
||||
/**
|
||||
* @param string $question The question to ask to the user
|
||||
@@ -187,8 +188,6 @@ class Question
|
||||
/**
|
||||
* Sets a validator for the question.
|
||||
*
|
||||
* @param callable|null $validator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator(callable $validator = null)
|
||||
@@ -247,8 +246,6 @@ class Question
|
||||
*
|
||||
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @param callable $normalizer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNormalizer(callable $normalizer)
|
||||
@@ -263,7 +260,7 @@ class Question
|
||||
*
|
||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @return callable
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getNormalizer()
|
||||
{
|
||||
@@ -274,4 +271,19 @@ class Question
|
||||
{
|
||||
return (bool) \count(array_filter(array_keys($array), 'is_string'));
|
||||
}
|
||||
|
||||
public function isTrimmable(): bool
|
||||
{
|
||||
return $this->trimmable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTrimmable(bool $trimmable): self
|
||||
{
|
||||
$this->trimmable = $trimmable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ interface StyleInterface
|
||||
* Asks a choice question.
|
||||
*
|
||||
* @param string $question
|
||||
* @param array $choices
|
||||
* @param string|int|null $default
|
||||
*
|
||||
* @return mixed
|
||||
|
||||
68
vendor/symfony/console/Style/SymfonyStyle.php
vendored
68
vendor/symfony/console/Style/SymfonyStyle.php
vendored
@@ -11,12 +11,15 @@
|
||||
|
||||
namespace Symfony\Component\Console\Style;
|
||||
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Helper\Helper;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\TableCell;
|
||||
use Symfony\Component\Console\Helper\TableSeparator;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -190,6 +193,69 @@ class SymfonyStyle extends OutputStyle
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a horizontal table.
|
||||
*/
|
||||
public function horizontalTable(array $headers, array $rows)
|
||||
{
|
||||
$style = clone Table::getStyleDefinition('symfony-style-guide');
|
||||
$style->setCellHeaderFormat('<info>%s</info>');
|
||||
|
||||
$table = new Table($this);
|
||||
$table->setHeaders($headers);
|
||||
$table->setRows($rows);
|
||||
$table->setStyle($style);
|
||||
$table->setHorizontal(true);
|
||||
|
||||
$table->render();
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a list of key/value horizontally.
|
||||
*
|
||||
* Each row can be one of:
|
||||
* * 'A title'
|
||||
* * ['key' => 'value']
|
||||
* * new TableSeparator()
|
||||
*
|
||||
* @param string|array|TableSeparator ...$list
|
||||
*/
|
||||
public function definitionList(...$list)
|
||||
{
|
||||
$style = clone Table::getStyleDefinition('symfony-style-guide');
|
||||
$style->setCellHeaderFormat('<info>%s</info>');
|
||||
|
||||
$table = new Table($this);
|
||||
$headers = [];
|
||||
$row = [];
|
||||
foreach ($list as $value) {
|
||||
if ($value instanceof TableSeparator) {
|
||||
$headers[] = $value;
|
||||
$row[] = $value;
|
||||
continue;
|
||||
}
|
||||
if (\is_string($value)) {
|
||||
$headers[] = new TableCell($value, ['colspan' => 2]);
|
||||
$row[] = null;
|
||||
continue;
|
||||
}
|
||||
if (!\is_array($value)) {
|
||||
throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.');
|
||||
}
|
||||
$headers[] = key($value);
|
||||
$row[] = current($value);
|
||||
}
|
||||
|
||||
$table->setHeaders($headers);
|
||||
$table->setRows([$row]);
|
||||
$table->setHorizontal();
|
||||
$table->setStyle($style);
|
||||
|
||||
$table->render();
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -388,7 +454,7 @@ class SymfonyStyle extends OutputStyle
|
||||
$this->bufferedOutput->write(substr($message, -4), $newLine, $type);
|
||||
}
|
||||
|
||||
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false)
|
||||
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
|
||||
{
|
||||
$indentLength = 0;
|
||||
$prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
|
||||
|
||||
94
vendor/symfony/console/Terminal.php
vendored
94
vendor/symfony/console/Terminal.php
vendored
@@ -15,6 +15,7 @@ class Terminal
|
||||
{
|
||||
private static $width;
|
||||
private static $height;
|
||||
private static $stty;
|
||||
|
||||
/**
|
||||
* Gets the terminal width.
|
||||
@@ -54,6 +55,22 @@ class Terminal
|
||||
return self::$height ?: 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasSttyAvailable()
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
}
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
|
||||
private static function initDimensions()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
@@ -62,12 +79,34 @@ class Terminal
|
||||
// or [w, h] from "wxh"
|
||||
self::$width = (int) $matches[1];
|
||||
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
|
||||
} elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
|
||||
// only use stty on Windows if the terminal does not support vt100 (e.g. Windows 7 + git-bash)
|
||||
// testing for stty in a Windows 10 vt100-enabled console will implicitly disable vt100 support on STDOUT
|
||||
self::initDimensionsUsingStty();
|
||||
} elseif (null !== $dimensions = self::getConsoleMode()) {
|
||||
// extract [w, h] from "wxh"
|
||||
self::$width = (int) $dimensions[0];
|
||||
self::$height = (int) $dimensions[1];
|
||||
}
|
||||
} elseif ($sttyString = self::getSttyColumns()) {
|
||||
} else {
|
||||
self::initDimensionsUsingStty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether STDOUT has vt100 support (some Windows 10+ configurations).
|
||||
*/
|
||||
private static function hasVt100Support(): bool
|
||||
{
|
||||
return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes dimensions using the output of an stty columns line.
|
||||
*/
|
||||
private static function initDimensionsUsingStty()
|
||||
{
|
||||
if ($sttyString = self::getSttyColumns()) {
|
||||
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
|
||||
// extract [w, h] from "rows h; columns w;"
|
||||
self::$width = (int) $matches[2];
|
||||
@@ -85,38 +124,29 @@ class Terminal
|
||||
*
|
||||
* @return int[]|null An array composed of the width and the height or null if it could not be parsed
|
||||
*/
|
||||
private static function getConsoleMode()
|
||||
private static function getConsoleMode(): ?array
|
||||
{
|
||||
if (!\function_exists('proc_open')) {
|
||||
return;
|
||||
$info = self::readFromProcess('mode CON');
|
||||
|
||||
if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$descriptorspec = [
|
||||
1 => ['pipe', 'w'],
|
||||
2 => ['pipe', 'w'],
|
||||
];
|
||||
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
|
||||
if (\is_resource($process)) {
|
||||
$info = stream_get_contents($pipes[1]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
proc_close($process);
|
||||
|
||||
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
|
||||
return [(int) $matches[2], (int) $matches[1]];
|
||||
}
|
||||
}
|
||||
return [(int) $matches[2], (int) $matches[1]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs and parses stty -a if it's available, suppressing any error output.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private static function getSttyColumns()
|
||||
private static function getSttyColumns(): ?string
|
||||
{
|
||||
return self::readFromProcess('stty -a | grep columns');
|
||||
}
|
||||
|
||||
private static function readFromProcess(string $command): ?string
|
||||
{
|
||||
if (!\function_exists('proc_open')) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$descriptorspec = [
|
||||
@@ -124,14 +154,16 @@ class Terminal
|
||||
2 => ['pipe', 'w'],
|
||||
];
|
||||
|
||||
$process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
|
||||
if (\is_resource($process)) {
|
||||
$info = stream_get_contents($pipes[1]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
proc_close($process);
|
||||
|
||||
return $info;
|
||||
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
|
||||
if (!\is_resource($process)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$info = stream_get_contents($pipes[1]);
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
proc_close($process);
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ trait TesterTrait
|
||||
* @param array $inputs An array of strings representing each input
|
||||
* passed to the command input stream
|
||||
*
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputs(array $inputs)
|
||||
{
|
||||
@@ -162,6 +162,9 @@ trait TesterTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
private static function createStream(array $inputs)
|
||||
{
|
||||
$stream = fopen('php://memory', 'r+', false);
|
||||
|
||||
1836
vendor/symfony/console/Tests/ApplicationTest.php
vendored
1836
vendor/symfony/console/Tests/ApplicationTest.php
vendored
File diff suppressed because it is too large
Load Diff
436
vendor/symfony/console/Tests/Command/CommandTest.php
vendored
436
vendor/symfony/console/Tests/Command/CommandTest.php
vendored
@@ -1,436 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\FormatterHelper;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class CommandTest extends TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = __DIR__.'/../Fixtures/';
|
||||
require_once self::$fixturesPath.'/TestCommand.php';
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$command = new Command('foo:bar');
|
||||
$this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage The command defined in "Symfony\Component\Console\Command\Command" cannot have an empty name.
|
||||
*/
|
||||
public function testCommandNameCannotBeEmpty()
|
||||
{
|
||||
(new Application())->add(new Command());
|
||||
}
|
||||
|
||||
public function testSetApplication()
|
||||
{
|
||||
$application = new Application();
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($application);
|
||||
$this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application');
|
||||
$this->assertEquals($application->getHelperSet(), $command->getHelperSet());
|
||||
}
|
||||
|
||||
public function testSetApplicationNull()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(null);
|
||||
$this->assertNull($command->getHelperSet());
|
||||
}
|
||||
|
||||
public function testSetGetDefinition()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->setDefinition($definition = new InputDefinition());
|
||||
$this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface');
|
||||
$this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance');
|
||||
$command->setDefinition([new InputArgument('foo'), new InputOption('bar')]);
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
|
||||
$this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument');
|
||||
$command->setDefinition(new InputDefinition());
|
||||
}
|
||||
|
||||
public function testAddArgument()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->addArgument('foo');
|
||||
$this->assertEquals($command, $ret, '->addArgument() implements a fluent interface');
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command');
|
||||
}
|
||||
|
||||
public function testAddOption()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->addOption('foo');
|
||||
$this->assertEquals($command, $ret, '->addOption() implements a fluent interface');
|
||||
$this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command');
|
||||
}
|
||||
|
||||
public function testSetHidden()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setHidden(true);
|
||||
$this->assertTrue($command->isHidden());
|
||||
}
|
||||
|
||||
public function testGetNamespaceGetNameSetName()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name');
|
||||
$command->setName('foo');
|
||||
$this->assertEquals('foo', $command->getName(), '->setName() sets the command name');
|
||||
|
||||
$ret = $command->setName('foobar:bar');
|
||||
$this->assertEquals($command, $ret, '->setName() implements a fluent interface');
|
||||
$this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidCommandNames
|
||||
*/
|
||||
public function testInvalidCommandNames($name)
|
||||
{
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessage(sprintf('Command name "%s" is invalid.', $name));
|
||||
} else {
|
||||
$this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name));
|
||||
}
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setName($name);
|
||||
}
|
||||
|
||||
public function provideInvalidCommandNames()
|
||||
{
|
||||
return [
|
||||
[''],
|
||||
['foo:'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetSetDescription()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description');
|
||||
$ret = $command->setDescription('description1');
|
||||
$this->assertEquals($command, $ret, '->setDescription() implements a fluent interface');
|
||||
$this->assertEquals('description1', $command->getDescription(), '->setDescription() sets the description');
|
||||
}
|
||||
|
||||
public function testGetSetHelp()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals('help', $command->getHelp(), '->getHelp() returns the help');
|
||||
$ret = $command->setHelp('help1');
|
||||
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
|
||||
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
|
||||
$command->setHelp('');
|
||||
$this->assertEquals('', $command->getHelp(), '->getHelp() does not fall back to the description');
|
||||
}
|
||||
|
||||
public function testGetProcessedHelp()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
|
||||
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly');
|
||||
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%');
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setHelp('');
|
||||
$this->assertContains('description', $command->getProcessedHelp(), '->getProcessedHelp() falls back to the description');
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setHelp('The %command.name% command does... Example: php %command.full_name%.');
|
||||
$application = new Application();
|
||||
$application->add($command);
|
||||
$application->setDefaultCommand('namespace:name', true);
|
||||
$this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly in single command applications');
|
||||
$this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name% in single command applications');
|
||||
}
|
||||
|
||||
public function testGetSetAliases()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->assertEquals(['name'], $command->getAliases(), '->getAliases() returns the aliases');
|
||||
$ret = $command->setAliases(['name1']);
|
||||
$this->assertEquals($command, $ret, '->setAliases() implements a fluent interface');
|
||||
$this->assertEquals(['name1'], $command->getAliases(), '->setAliases() sets the aliases');
|
||||
}
|
||||
|
||||
public function testSetAliasesNull()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$command->setAliases(null);
|
||||
}
|
||||
|
||||
public function testGetSynopsis()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->addOption('foo');
|
||||
$command->addArgument('bar');
|
||||
$this->assertEquals('namespace:name [--foo] [--] [<bar>]', $command->getSynopsis(), '->getSynopsis() returns the synopsis');
|
||||
}
|
||||
|
||||
public function testAddGetUsages()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->addUsage('foo1');
|
||||
$command->addUsage('foo2');
|
||||
$this->assertContains('namespace:name foo1', $command->getUsages());
|
||||
$this->assertContains('namespace:name foo2', $command->getUsages());
|
||||
}
|
||||
|
||||
public function testGetHelper()
|
||||
{
|
||||
$application = new Application();
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($application);
|
||||
$formatterHelper = new FormatterHelper();
|
||||
$this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage Cannot retrieve helper "formatter" because there is no HelperSet defined.
|
||||
*/
|
||||
public function testGetHelperWithoutHelperSet()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->getHelper('formatter');
|
||||
}
|
||||
|
||||
public function testMergeApplicationDefinition()
|
||||
{
|
||||
$application1 = new Application();
|
||||
$application1->getDefinition()->addArguments([new InputArgument('foo')]);
|
||||
$application1->getDefinition()->addOptions([new InputOption('bar')]);
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($application1);
|
||||
$command->setDefinition($definition = new InputDefinition([new InputArgument('bar'), new InputOption('foo')]));
|
||||
|
||||
$r = new \ReflectionObject($command);
|
||||
$m = $r->getMethod('mergeApplicationDefinition');
|
||||
$m->setAccessible(true);
|
||||
$m->invoke($command);
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments');
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments');
|
||||
$this->assertTrue($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options');
|
||||
$this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options');
|
||||
|
||||
$m->invoke($command);
|
||||
$this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options');
|
||||
}
|
||||
|
||||
public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs()
|
||||
{
|
||||
$application1 = new Application();
|
||||
$application1->getDefinition()->addArguments([new InputArgument('foo')]);
|
||||
$application1->getDefinition()->addOptions([new InputOption('bar')]);
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication($application1);
|
||||
$command->setDefinition($definition = new InputDefinition([]));
|
||||
|
||||
$r = new \ReflectionObject($command);
|
||||
$m = $r->getMethod('mergeApplicationDefinition');
|
||||
$m->setAccessible(true);
|
||||
$m->invoke($command, false);
|
||||
$this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the command options');
|
||||
$this->assertFalse($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments');
|
||||
|
||||
$m->invoke($command, true);
|
||||
$this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments');
|
||||
|
||||
$m->invoke($command);
|
||||
$this->assertEquals(2, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments');
|
||||
}
|
||||
|
||||
public function testRunInteractive()
|
||||
{
|
||||
$tester = new CommandTester(new \TestCommand());
|
||||
|
||||
$tester->execute([], ['interactive' => true]);
|
||||
|
||||
$this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive');
|
||||
}
|
||||
|
||||
public function testRunNonInteractive()
|
||||
{
|
||||
$tester = new CommandTester(new \TestCommand());
|
||||
|
||||
$tester->execute([], ['interactive' => false]);
|
||||
|
||||
$this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage You must override the execute() method in the concrete command class.
|
||||
*/
|
||||
public function testExecuteMethodNeedsToBeOverridden()
|
||||
{
|
||||
$command = new Command('foo');
|
||||
$command->run(new StringInput(''), new NullOutput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\InvalidOptionException
|
||||
* @expectedExceptionMessage The "--bar" option does not exist.
|
||||
*/
|
||||
public function testRunWithInvalidOption()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(['--bar' => true]);
|
||||
}
|
||||
|
||||
public function testRunReturnsIntegerExitCode()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
$this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)');
|
||||
|
||||
$command = $this->getMockBuilder('TestCommand')->setMethods(['execute'])->getMock();
|
||||
$command->expects($this->once())
|
||||
->method('execute')
|
||||
->willReturn('2.3');
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
$this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)');
|
||||
}
|
||||
|
||||
public function testRunWithApplication()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$exitCode = $command->run(new StringInput(''), new NullOutput());
|
||||
|
||||
$this->assertSame(0, $exitCode, '->run() returns an integer exit code');
|
||||
}
|
||||
|
||||
public function testRunReturnsAlwaysInteger()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
|
||||
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
|
||||
}
|
||||
|
||||
public function testRunWithProcessTitle()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$command->setProcessTitle('foo');
|
||||
$this->assertSame(0, $command->run(new StringInput(''), new NullOutput()));
|
||||
if (\function_exists('cli_set_process_title')) {
|
||||
if (null === @cli_get_process_title() && 'Darwin' === PHP_OS) {
|
||||
$this->markTestSkipped('Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.');
|
||||
}
|
||||
$this->assertEquals('foo', cli_get_process_title());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetCode()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->setCode(function (InputInterface $input, OutputInterface $output) {
|
||||
$output->writeln('from the code...');
|
||||
});
|
||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute([]);
|
||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function getSetCodeBindToClosureTests()
|
||||
{
|
||||
return [
|
||||
[true, 'not bound to the command'],
|
||||
[false, 'bound to the command'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSetCodeBindToClosureTests
|
||||
*/
|
||||
public function testSetCodeBindToClosure($previouslyBound, $expected)
|
||||
{
|
||||
$code = createClosure();
|
||||
if ($previouslyBound) {
|
||||
$code = $code->bindTo($this);
|
||||
}
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setCode($code);
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute([]);
|
||||
$this->assertEquals('interact called'.PHP_EOL.$expected.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testSetCodeWithStaticClosure()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$command->setCode(self::createClosure());
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute([]);
|
||||
|
||||
$this->assertEquals('interact called'.PHP_EOL.'bound'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
private static function createClosure()
|
||||
{
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output->writeln(isset($this) ? 'bound' : 'not bound');
|
||||
};
|
||||
}
|
||||
|
||||
public function testSetCodeWithNonClosureCallable()
|
||||
{
|
||||
$command = new \TestCommand();
|
||||
$ret = $command->setCode([$this, 'callableMethodCommand']);
|
||||
$this->assertEquals($command, $ret, '->setCode() implements a fluent interface');
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute([]);
|
||||
$this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function callableMethodCommand(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('from the code...');
|
||||
}
|
||||
}
|
||||
|
||||
// In order to get an unbound closure, we should create it outside a class
|
||||
// scope.
|
||||
function createClosure()
|
||||
{
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output->writeln($this instanceof Command ? 'bound to the command' : 'not bound to the command');
|
||||
};
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\HelpCommand;
|
||||
use Symfony\Component\Console\Command\ListCommand;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class HelpCommandTest extends TestCase
|
||||
{
|
||||
public function testExecuteForCommandAlias()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$command->setApplication(new Application());
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(['command_name' => 'li'], ['decorated' => false]);
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias');
|
||||
}
|
||||
|
||||
public function testExecuteForCommand()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$commandTester = new CommandTester($command);
|
||||
$command->setCommand(new ListCommand());
|
||||
$commandTester->execute([], ['decorated' => false]);
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
}
|
||||
|
||||
public function testExecuteForCommandWithXmlOption()
|
||||
{
|
||||
$command = new HelpCommand();
|
||||
$commandTester = new CommandTester($command);
|
||||
$command->setCommand(new ListCommand());
|
||||
$commandTester->execute(['--format' => 'xml']);
|
||||
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed');
|
||||
}
|
||||
|
||||
public function testExecuteForApplicationCommand()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($application->get('help'));
|
||||
$commandTester->execute(['command_name' => 'list']);
|
||||
$this->assertContains('list [options] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('format=FORMAT', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('raw', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
}
|
||||
|
||||
public function testExecuteForApplicationCommandWithXmlOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($application->get('help'));
|
||||
$commandTester->execute(['command_name' => 'list', '--format' => 'xml']);
|
||||
$this->assertContains('list [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
|
||||
$this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class ListCommandTest extends TestCase
|
||||
{
|
||||
public function testExecuteListsCommands()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName()], ['decorated' => false]);
|
||||
|
||||
$this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithXmlOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName(), '--format' => 'xml']);
|
||||
$this->assertRegExp('/<command id="list" name="list" hidden="0">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithRawOption()
|
||||
{
|
||||
$application = new Application();
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName(), '--raw' => true]);
|
||||
$output = <<<'EOF'
|
||||
help Displays help for a command
|
||||
list Lists commands
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, $commandTester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsWithNamespaceArgument()
|
||||
{
|
||||
require_once realpath(__DIR__.'/../Fixtures/FooCommand.php');
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName(), 'namespace' => 'foo', '--raw' => true]);
|
||||
$output = <<<'EOF'
|
||||
foo:bar The foo:bar command
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, $commandTester->getDisplay(true));
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsOrder()
|
||||
{
|
||||
require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php');
|
||||
$application = new Application();
|
||||
$application->add(new \Foo6Command());
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName()], ['decorated' => false]);
|
||||
$output = <<<'EOF'
|
||||
Console Tool
|
||||
|
||||
Usage:
|
||||
command [options] [arguments]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help message
|
||||
-q, --quiet Do not output any message
|
||||
-V, --version Display this application version
|
||||
--ansi Force ANSI output
|
||||
--no-ansi Disable ANSI output
|
||||
-n, --no-interaction Do not ask any interactive question
|
||||
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||
|
||||
Available commands:
|
||||
help Displays help for a command
|
||||
list Lists commands
|
||||
0foo
|
||||
0foo:bar 0foo:bar command
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, trim($commandTester->getDisplay(true)));
|
||||
}
|
||||
|
||||
public function testExecuteListsCommandsOrderRaw()
|
||||
{
|
||||
require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php');
|
||||
$application = new Application();
|
||||
$application->add(new \Foo6Command());
|
||||
$commandTester = new CommandTester($command = $application->get('list'));
|
||||
$commandTester->execute(['command' => $command->getName(), '--raw' => true]);
|
||||
$output = <<<'EOF'
|
||||
help Displays help for a command
|
||||
list Lists commands
|
||||
0foo:bar 0foo:bar command
|
||||
EOF;
|
||||
|
||||
$this->assertEquals($output, trim($commandTester->getDisplay(true)));
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Lock\Factory;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
class LockableTraitTest extends TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = __DIR__.'/../Fixtures/';
|
||||
require_once self::$fixturesPath.'/FooLockCommand.php';
|
||||
require_once self::$fixturesPath.'/FooLock2Command.php';
|
||||
}
|
||||
|
||||
public function testLockIsReleased()
|
||||
{
|
||||
$command = new \FooLockCommand();
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$this->assertSame(2, $tester->execute([]));
|
||||
$this->assertSame(2, $tester->execute([]));
|
||||
}
|
||||
|
||||
public function testLockReturnsFalseIfAlreadyLockedByAnotherCommand()
|
||||
{
|
||||
$command = new \FooLockCommand();
|
||||
|
||||
if (SemaphoreStore::isSupported()) {
|
||||
$store = new SemaphoreStore();
|
||||
} else {
|
||||
$store = new FlockStore();
|
||||
}
|
||||
|
||||
$lock = (new Factory($store))->createLock($command->getName());
|
||||
$lock->acquire();
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$this->assertSame(1, $tester->execute([]));
|
||||
|
||||
$lock->release();
|
||||
$this->assertSame(2, $tester->execute([]));
|
||||
}
|
||||
|
||||
public function testMultipleLockCallsThrowLogicException()
|
||||
{
|
||||
$command = new \FooLock2Command();
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$this->assertSame(1, $tester->execute([]));
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\CommandLoader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
|
||||
use Symfony\Component\DependencyInjection\ServiceLocator;
|
||||
|
||||
class ContainerCommandLoaderTest extends TestCase
|
||||
{
|
||||
public function testHas()
|
||||
{
|
||||
$loader = new ContainerCommandLoader(new ServiceLocator([
|
||||
'foo-service' => function () { return new Command('foo'); },
|
||||
'bar-service' => function () { return new Command('bar'); },
|
||||
]), ['foo' => 'foo-service', 'bar' => 'bar-service']);
|
||||
|
||||
$this->assertTrue($loader->has('foo'));
|
||||
$this->assertTrue($loader->has('bar'));
|
||||
$this->assertFalse($loader->has('baz'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$loader = new ContainerCommandLoader(new ServiceLocator([
|
||||
'foo-service' => function () { return new Command('foo'); },
|
||||
'bar-service' => function () { return new Command('bar'); },
|
||||
]), ['foo' => 'foo-service', 'bar' => 'bar-service']);
|
||||
|
||||
$this->assertInstanceOf(Command::class, $loader->get('foo'));
|
||||
$this->assertInstanceOf(Command::class, $loader->get('bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
|
||||
*/
|
||||
public function testGetUnknownCommandThrows()
|
||||
{
|
||||
(new ContainerCommandLoader(new ServiceLocator([]), []))->get('unknown');
|
||||
}
|
||||
|
||||
public function testGetCommandNames()
|
||||
{
|
||||
$loader = new ContainerCommandLoader(new ServiceLocator([
|
||||
'foo-service' => function () { return new Command('foo'); },
|
||||
'bar-service' => function () { return new Command('bar'); },
|
||||
]), ['foo' => 'foo-service', 'bar' => 'bar-service']);
|
||||
|
||||
$this->assertSame(['foo', 'bar'], $loader->getNames());
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\CommandLoader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
|
||||
|
||||
class FactoryCommandLoaderTest extends TestCase
|
||||
{
|
||||
public function testHas()
|
||||
{
|
||||
$loader = new FactoryCommandLoader([
|
||||
'foo' => function () { return new Command('foo'); },
|
||||
'bar' => function () { return new Command('bar'); },
|
||||
]);
|
||||
|
||||
$this->assertTrue($loader->has('foo'));
|
||||
$this->assertTrue($loader->has('bar'));
|
||||
$this->assertFalse($loader->has('baz'));
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$loader = new FactoryCommandLoader([
|
||||
'foo' => function () { return new Command('foo'); },
|
||||
'bar' => function () { return new Command('bar'); },
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(Command::class, $loader->get('foo'));
|
||||
$this->assertInstanceOf(Command::class, $loader->get('bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\CommandNotFoundException
|
||||
*/
|
||||
public function testGetUnknownCommandThrows()
|
||||
{
|
||||
(new FactoryCommandLoader([]))->get('unknown');
|
||||
}
|
||||
|
||||
public function testGetCommandNames()
|
||||
{
|
||||
$loader = new FactoryCommandLoader([
|
||||
'foo' => function () { return new Command('foo'); },
|
||||
'bar' => function () { return new Command('bar'); },
|
||||
]);
|
||||
|
||||
$this->assertSame(['foo', 'bar'], $loader->getNames());
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
|
||||
use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\TypedReference;
|
||||
|
||||
class AddConsoleCommandPassTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider visibilityProvider
|
||||
*/
|
||||
public function testProcess($public)
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$container->setParameter('my-command.class', 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand');
|
||||
|
||||
$id = 'my-command';
|
||||
$definition = new Definition('%my-command.class%');
|
||||
$definition->setPublic($public);
|
||||
$definition->addTag('console.command');
|
||||
$container->setDefinition($id, $definition);
|
||||
|
||||
$container->compile();
|
||||
|
||||
$alias = 'console.command.public_alias.my-command';
|
||||
|
||||
if ($public) {
|
||||
$this->assertFalse($container->hasAlias($alias));
|
||||
} else {
|
||||
// The alias is replaced by a Definition by the ReplaceAliasByActualDefinitionPass
|
||||
// in case the original service is private
|
||||
$this->assertFalse($container->hasDefinition($id));
|
||||
$this->assertTrue($container->hasDefinition($alias));
|
||||
}
|
||||
|
||||
$this->assertTrue($container->hasParameter('console.command.ids'));
|
||||
$this->assertSame([$public ? $id : $alias], $container->getParameter('console.command.ids'));
|
||||
}
|
||||
|
||||
public function testProcessRegistersLazyCommands()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$command = $container
|
||||
->register('my-command', MyCommand::class)
|
||||
->setPublic(false)
|
||||
->addTag('console.command', ['command' => 'my:command'])
|
||||
->addTag('console.command', ['command' => 'my:alias'])
|
||||
;
|
||||
|
||||
(new AddConsoleCommandPass())->process($container);
|
||||
|
||||
$commandLoader = $container->getDefinition('console.command_loader');
|
||||
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
|
||||
|
||||
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||
$this->assertSame(['my:command' => 'my-command', 'my:alias' => 'my-command'], $commandLoader->getArgument(1));
|
||||
$this->assertEquals([['my-command' => new ServiceClosureArgument(new TypedReference('my-command', MyCommand::class))]], $commandLocator->getArguments());
|
||||
$this->assertSame([], $container->getParameter('console.command.ids'));
|
||||
$this->assertSame([['setName', ['my:command']], ['setAliases', [['my:alias']]]], $command->getMethodCalls());
|
||||
}
|
||||
|
||||
public function testProcessFallsBackToDefaultName()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('with-default-name', NamedCommand::class)
|
||||
->setPublic(false)
|
||||
->addTag('console.command')
|
||||
;
|
||||
|
||||
$pass = new AddConsoleCommandPass();
|
||||
$pass->process($container);
|
||||
|
||||
$commandLoader = $container->getDefinition('console.command_loader');
|
||||
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
|
||||
|
||||
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||
$this->assertSame(['default' => 'with-default-name'], $commandLoader->getArgument(1));
|
||||
$this->assertEquals([['with-default-name' => new ServiceClosureArgument(new TypedReference('with-default-name', NamedCommand::class))]], $commandLocator->getArguments());
|
||||
$this->assertSame([], $container->getParameter('console.command.ids'));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('with-default-name', NamedCommand::class)
|
||||
->setPublic(false)
|
||||
->addTag('console.command', ['command' => 'new-name'])
|
||||
;
|
||||
|
||||
$pass->process($container);
|
||||
|
||||
$this->assertSame(['new-name' => 'with-default-name'], $container->getDefinition('console.command_loader')->getArgument(1));
|
||||
}
|
||||
|
||||
public function visibilityProvider()
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
|
||||
*/
|
||||
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
|
||||
$definition = new Definition('Symfony\Component\Console\Tests\DependencyInjection\MyCommand');
|
||||
$definition->addTag('console.command');
|
||||
$definition->setAbstract(true);
|
||||
$container->setDefinition('my-command', $definition);
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The service "my-command" tagged "console.command" must be a subclass of "Symfony\Component\Console\Command\Command".
|
||||
*/
|
||||
public function testProcessThrowAnExceptionIfTheServiceIsNotASubclassOfCommand()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setResourceTracking(false);
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
|
||||
$definition = new Definition('SplObjectStorage');
|
||||
$definition->addTag('console.command');
|
||||
$container->setDefinition('my-command', $definition);
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
|
||||
public function testProcessPrivateServicesWithSameCommand()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$className = 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand';
|
||||
|
||||
$definition1 = new Definition($className);
|
||||
$definition1->addTag('console.command')->setPublic(false);
|
||||
|
||||
$definition2 = new Definition($className);
|
||||
$definition2->addTag('console.command')->setPublic(false);
|
||||
|
||||
$container->setDefinition('my-command1', $definition1);
|
||||
$container->setDefinition('my-command2', $definition2);
|
||||
|
||||
(new AddConsoleCommandPass())->process($container);
|
||||
|
||||
$aliasPrefix = 'console.command.public_alias.';
|
||||
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command1'));
|
||||
$this->assertTrue($container->hasAlias($aliasPrefix.'my-command2'));
|
||||
}
|
||||
|
||||
public function testProcessOnChildDefinitionWithClass()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$className = 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand';
|
||||
|
||||
$parentId = 'my-parent-command';
|
||||
$childId = 'my-child-command';
|
||||
|
||||
$parentDefinition = new Definition(/* no class */);
|
||||
$parentDefinition->setAbstract(true)->setPublic(false);
|
||||
|
||||
$childDefinition = new ChildDefinition($parentId);
|
||||
$childDefinition->addTag('console.command')->setPublic(true);
|
||||
$childDefinition->setClass($className);
|
||||
|
||||
$container->setDefinition($parentId, $parentDefinition);
|
||||
$container->setDefinition($childId, $childDefinition);
|
||||
|
||||
$container->compile();
|
||||
$command = $container->get($childId);
|
||||
|
||||
$this->assertInstanceOf($className, $command);
|
||||
}
|
||||
|
||||
public function testProcessOnChildDefinitionWithParentClass()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$className = 'Symfony\Component\Console\Tests\DependencyInjection\MyCommand';
|
||||
|
||||
$parentId = 'my-parent-command';
|
||||
$childId = 'my-child-command';
|
||||
|
||||
$parentDefinition = new Definition($className);
|
||||
$parentDefinition->setAbstract(true)->setPublic(false);
|
||||
|
||||
$childDefinition = new ChildDefinition($parentId);
|
||||
$childDefinition->addTag('console.command')->setPublic(true);
|
||||
|
||||
$container->setDefinition($parentId, $parentDefinition);
|
||||
$container->setDefinition($childId, $childDefinition);
|
||||
|
||||
$container->compile();
|
||||
$command = $container->get($childId);
|
||||
|
||||
$this->assertInstanceOf($className, $command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage The definition for "my-child-command" has no class.
|
||||
*/
|
||||
public function testProcessOnChildDefinitionWithoutClass()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->addCompilerPass(new AddConsoleCommandPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
|
||||
$parentId = 'my-parent-command';
|
||||
$childId = 'my-child-command';
|
||||
|
||||
$parentDefinition = new Definition();
|
||||
$parentDefinition->setAbstract(true)->setPublic(false);
|
||||
|
||||
$childDefinition = new ChildDefinition($parentId);
|
||||
$childDefinition->addTag('console.command')->setPublic(true);
|
||||
|
||||
$container->setDefinition($parentId, $parentDefinition);
|
||||
$container->setDefinition($childId, $childDefinition);
|
||||
|
||||
$container->compile();
|
||||
}
|
||||
}
|
||||
|
||||
class MyCommand extends Command
|
||||
{
|
||||
}
|
||||
|
||||
class NamedCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'default';
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
abstract class AbstractDescriptorTest extends TestCase
|
||||
{
|
||||
/** @dataProvider getDescribeInputArgumentTestData */
|
||||
public function testDescribeInputArgument(InputArgument $argument, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $argument);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeInputOptionTestData */
|
||||
public function testDescribeInputOption(InputOption $option, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $option);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeInputDefinitionTestData */
|
||||
public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $definition);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeCommandTestData */
|
||||
public function testDescribeCommand(Command $command, $expectedDescription)
|
||||
{
|
||||
$this->assertDescription($expectedDescription, $command);
|
||||
}
|
||||
|
||||
/** @dataProvider getDescribeApplicationTestData */
|
||||
public function testDescribeApplication(Application $application, $expectedDescription)
|
||||
{
|
||||
// Replaces the dynamic placeholders of the command help text with a static version.
|
||||
// The placeholder %command.full_name% includes the script path that is not predictable
|
||||
// and can not be tested against.
|
||||
foreach ($application->all() as $command) {
|
||||
$command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
|
||||
}
|
||||
|
||||
$this->assertDescription($expectedDescription, $application);
|
||||
}
|
||||
|
||||
public function getDescribeInputArgumentTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputArguments());
|
||||
}
|
||||
|
||||
public function getDescribeInputOptionTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputOptions());
|
||||
}
|
||||
|
||||
public function getDescribeInputDefinitionTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions());
|
||||
}
|
||||
|
||||
public function getDescribeCommandTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getCommands());
|
||||
}
|
||||
|
||||
public function getDescribeApplicationTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(ObjectsProvider::getApplications());
|
||||
}
|
||||
|
||||
abstract protected function getDescriptor();
|
||||
|
||||
abstract protected function getFormat();
|
||||
|
||||
protected function getDescriptionTestData(array $objects)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($objects as $name => $object) {
|
||||
$description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat()));
|
||||
$data[] = [$object, $description];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function assertDescription($expectedDescription, $describedObject, array $options = [])
|
||||
{
|
||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\JsonDescriptor;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class JsonDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new JsonDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'json';
|
||||
}
|
||||
|
||||
protected function assertDescription($expectedDescription, $describedObject, array $options = [])
|
||||
{
|
||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||
$this->getDescriptor()->describe($output, $describedObject, $options + ['raw_output' => true]);
|
||||
$this->assertEquals(json_decode(trim($expectedDescription), true), json_decode(trim(str_replace(PHP_EOL, "\n", $output->fetch())), true));
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString;
|
||||
|
||||
class MarkdownDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
public function getDescribeCommandTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(array_merge(
|
||||
ObjectsProvider::getCommands(),
|
||||
['command_mbstring' => new DescriptorCommandMbString()]
|
||||
));
|
||||
}
|
||||
|
||||
public function getDescribeApplicationTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(array_merge(
|
||||
ObjectsProvider::getApplications(),
|
||||
['application_mbstring' => new DescriptorApplicationMbString()]
|
||||
));
|
||||
}
|
||||
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new MarkdownDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'md';
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication1;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand1;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand2;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <contact@jfsimon.fr>
|
||||
*/
|
||||
class ObjectsProvider
|
||||
{
|
||||
public static function getInputArguments()
|
||||
{
|
||||
return [
|
||||
'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED),
|
||||
'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'),
|
||||
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
||||
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
||||
'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', '<comment>style</>'),
|
||||
'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getInputOptions()
|
||||
{
|
||||
return [
|
||||
'input_option_1' => new InputOption('option_name', 'o', InputOption::VALUE_NONE),
|
||||
'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'),
|
||||
'input_option_3' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description'),
|
||||
'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', []),
|
||||
'input_option_5' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, "multiline\noption description"),
|
||||
'input_option_6' => new InputOption('option_name', ['o', 'O'], InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
|
||||
'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', '<comment>style</>'),
|
||||
'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', ['<comment>Hello</comment>', '<info>world</info>']),
|
||||
'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getInputDefinitions()
|
||||
{
|
||||
return [
|
||||
'input_definition_1' => new InputDefinition(),
|
||||
'input_definition_2' => new InputDefinition([new InputArgument('argument_name', InputArgument::REQUIRED)]),
|
||||
'input_definition_3' => new InputDefinition([new InputOption('option_name', 'o', InputOption::VALUE_NONE)]),
|
||||
'input_definition_4' => new InputDefinition([
|
||||
new InputArgument('argument_name', InputArgument::REQUIRED),
|
||||
new InputOption('option_name', 'o', InputOption::VALUE_NONE),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCommands()
|
||||
{
|
||||
return [
|
||||
'command_1' => new DescriptorCommand1(),
|
||||
'command_2' => new DescriptorCommand2(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getApplications()
|
||||
{
|
||||
return [
|
||||
'application_1' => new DescriptorApplication1(),
|
||||
'application_2' => new DescriptorApplication2(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorApplicationMbString;
|
||||
use Symfony\Component\Console\Tests\Fixtures\DescriptorCommandMbString;
|
||||
|
||||
class TextDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
public function getDescribeCommandTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(array_merge(
|
||||
ObjectsProvider::getCommands(),
|
||||
['command_mbstring' => new DescriptorCommandMbString()]
|
||||
));
|
||||
}
|
||||
|
||||
public function getDescribeApplicationTestData()
|
||||
{
|
||||
return $this->getDescriptionTestData(array_merge(
|
||||
ObjectsProvider::getApplications(),
|
||||
['application_mbstring' => new DescriptorApplicationMbString()]
|
||||
));
|
||||
}
|
||||
|
||||
public function testDescribeApplicationWithFilteredNamespace()
|
||||
{
|
||||
$application = new DescriptorApplication2();
|
||||
|
||||
$this->assertDescription(file_get_contents(__DIR__.'/../Fixtures/application_filtered_namespace.txt'), $application, ['namespace' => 'command4']);
|
||||
}
|
||||
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new TextDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'txt';
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor;
|
||||
|
||||
class XmlDescriptorTest extends AbstractDescriptorTest
|
||||
{
|
||||
protected function getDescriptor()
|
||||
{
|
||||
return new XmlDescriptor();
|
||||
}
|
||||
|
||||
protected function getFormat()
|
||||
{
|
||||
return 'xml';
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\EventListener;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Event\ConsoleErrorEvent;
|
||||
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
|
||||
use Symfony\Component\Console\EventListener\ErrorListener;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\Input;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ErrorListenerTest extends TestCase
|
||||
{
|
||||
public function testOnConsoleError()
|
||||
{
|
||||
$error = new \TypeError('An error occurred');
|
||||
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error')
|
||||
->with('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => 'test:run --foo=baz buzz', 'message' => 'An error occurred'])
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleError(new ConsoleErrorEvent(new ArgvInput(['console.php', 'test:run', '--foo=baz', 'buzz']), $this->getOutput(), $error, new Command('test:run')));
|
||||
}
|
||||
|
||||
public function testOnConsoleErrorWithNoCommandAndNoInputString()
|
||||
{
|
||||
$error = new \RuntimeException('An error occurred');
|
||||
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('error')
|
||||
->with('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => 'An error occurred'])
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleError(new ConsoleErrorEvent(new NonStringInput(), $this->getOutput(), $error));
|
||||
}
|
||||
|
||||
public function testOnConsoleTerminateForNonZeroExitCodeWritesToLog()
|
||||
{
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('debug')
|
||||
->with('Command "{command}" exited with code "{code}"', ['command' => 'test:run', 'code' => 255])
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent(new ArgvInput(['console.php', 'test:run']), 255));
|
||||
}
|
||||
|
||||
public function testOnConsoleTerminateForZeroExitCodeDoesNotWriteToLog()
|
||||
{
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->never())
|
||||
->method('debug')
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent(new ArgvInput(['console.php', 'test:run']), 0));
|
||||
}
|
||||
|
||||
public function testGetSubscribedEvents()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[
|
||||
'console.error' => ['onConsoleError', -128],
|
||||
'console.terminate' => ['onConsoleTerminate', -128],
|
||||
],
|
||||
ErrorListener::getSubscribedEvents()
|
||||
);
|
||||
}
|
||||
|
||||
public function testAllKindsOfInputCanBeLogged()
|
||||
{
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->exactly(3))
|
||||
->method('debug')
|
||||
->with('Command "{command}" exited with code "{code}"', ['command' => 'test:run --foo=bar', 'code' => 255])
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent(new ArgvInput(['console.php', 'test:run', '--foo=bar']), 255));
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent(new ArrayInput(['name' => 'test:run', '--foo' => 'bar']), 255));
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent(new StringInput('test:run --foo=bar'), 255));
|
||||
}
|
||||
|
||||
public function testCommandNameIsDisplayedForNonStringableInput()
|
||||
{
|
||||
$logger = $this->getLogger();
|
||||
$logger
|
||||
->expects($this->once())
|
||||
->method('debug')
|
||||
->with('Command "{command}" exited with code "{code}"', ['command' => 'test:run', 'code' => 255])
|
||||
;
|
||||
|
||||
$listener = new ErrorListener($logger);
|
||||
$listener->onConsoleTerminate($this->getConsoleTerminateEvent($this->getMockBuilder(InputInterface::class)->getMock(), 255));
|
||||
}
|
||||
|
||||
private function getLogger()
|
||||
{
|
||||
return $this->getMockForAbstractClass(LoggerInterface::class);
|
||||
}
|
||||
|
||||
private function getConsoleTerminateEvent(InputInterface $input, $exitCode)
|
||||
{
|
||||
return new ConsoleTerminateEvent(new Command('test:run'), $input, $this->getOutput(), $exitCode);
|
||||
}
|
||||
|
||||
private function getOutput()
|
||||
{
|
||||
return $this->getMockBuilder(OutputInterface::class)->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
class NonStringInput extends Input
|
||||
{
|
||||
public function getFirstArgument()
|
||||
{
|
||||
}
|
||||
|
||||
public function hasParameterOption($values, $onlyParams = false)
|
||||
{
|
||||
}
|
||||
|
||||
public function getParameterOption($values, $default = false, $onlyParams = false)
|
||||
{
|
||||
}
|
||||
|
||||
public function parse()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class BarBucCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('bar:buc');
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
class DescriptorApplication1 extends Application
|
||||
{
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
class DescriptorApplication2 extends Application
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('My Symfony application', 'v1.0');
|
||||
$this->add(new DescriptorCommand1());
|
||||
$this->add(new DescriptorCommand2());
|
||||
$this->add(new DescriptorCommand3());
|
||||
$this->add(new DescriptorCommand4());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
|
||||
class DescriptorApplicationMbString extends Application
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('MbString åpplicätion');
|
||||
|
||||
$this->add(new DescriptorCommandMbString());
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class DescriptorCommand1 extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('descriptor:command1')
|
||||
->setAliases(['alias1', 'alias2'])
|
||||
->setDescription('command 1 description')
|
||||
->setHelp('command 1 help')
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class DescriptorCommand2 extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('descriptor:command2')
|
||||
->setDescription('command 2 description')
|
||||
->setHelp('command 2 help')
|
||||
->addUsage('-o|--option_name <argument_name>')
|
||||
->addUsage('<argument_name>')
|
||||
->addArgument('argument_name', InputArgument::REQUIRED)
|
||||
->addOption('option_name', 'o', InputOption::VALUE_NONE)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class DescriptorCommand3 extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('descriptor:command3')
|
||||
->setDescription('command 3 description')
|
||||
->setHelp('command 3 help')
|
||||
->setHidden(true)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class DescriptorCommand4 extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('descriptor:command4')
|
||||
->setAliases(['descriptor:alias_command4', 'command4:descriptor'])
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class DescriptorCommandMbString extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('descriptor:åèä')
|
||||
->setDescription('command åèä description')
|
||||
->setHelp('command åèä help')
|
||||
->addUsage('-o|--option_name <argument_name>')
|
||||
->addUsage('<argument_name>')
|
||||
->addArgument('argument_åèä', InputArgument::REQUIRED)
|
||||
->addOption('option_åèä', 'o', InputOption::VALUE_NONE)
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
/**
|
||||
* Dummy output.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class DummyOutput extends BufferedOutput
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLogs()
|
||||
{
|
||||
$logs = [];
|
||||
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) {
|
||||
preg_match('/^\[(.*)\] (.*)/', $message, $matches);
|
||||
$logs[] = sprintf('%s %s', $matches[1], $matches[2]);
|
||||
}
|
||||
|
||||
return $logs;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Foo1Command extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo:bar1')
|
||||
->setDescription('The foo:bar1 command')
|
||||
->setAliases(['afoobar1'])
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Foo2Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo1:bar')
|
||||
->setDescription('The foo1:bar command')
|
||||
->setAliases(['afoobar2'])
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Foo3Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo3:bar')
|
||||
->setDescription('The foo3:bar command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
try {
|
||||
try {
|
||||
throw new \Exception('First exception <p>this is html</p>');
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Second exception <comment>comment</comment>', 0, $e);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Third exception <fg=blue;bg=red>comment</>', 404, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class Foo4Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo3:bar:toh');
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class Foo5Command extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class Foo6Command extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('0foo:bar')->setDescription('0foo:bar command');
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooCommand extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo:bar')
|
||||
->setDescription('The foo:bar command')
|
||||
->setAliases(['afoobar'])
|
||||
;
|
||||
}
|
||||
|
||||
protected function interact(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('interact called');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
$output->writeln('called');
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\LockableTrait;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooLock2Command extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo:lock2');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
try {
|
||||
$this->lock();
|
||||
$this->lock();
|
||||
} catch (LogicException $e) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\LockableTrait;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooLockCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo:lock');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (!$this->lock()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->release();
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooOptCommand extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo:bar')
|
||||
->setDescription('The foo:bar command')
|
||||
->setAliases(['afoobar'])
|
||||
->addOption('fooopt', 'fo', InputOption::VALUE_OPTIONAL, 'fooopt description')
|
||||
;
|
||||
}
|
||||
|
||||
protected function interact(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('interact called');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
|
||||
$output->writeln('called');
|
||||
$output->writeln($this->input->getOption('fooopt'));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class FooSameCaseLowercaseCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo:bar')->setDescription('foo:bar command');
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
class FooSameCaseUppercaseCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('foo:BAR')->setDescription('foo:BAR command');
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooSubnamespaced1Command extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo:bar:baz')
|
||||
->setDescription('The foo:bar:baz command')
|
||||
->setAliases(['foobarbaz'])
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooSubnamespaced2Command extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo:go:bret')
|
||||
->setDescription('The foo:bar:go command')
|
||||
->setAliases(['foobargo'])
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FooWithoutAliasCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foo')
|
||||
->setDescription('The foo command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('called');
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class FoobarCommand extends Command
|
||||
{
|
||||
public $input;
|
||||
public $output;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->setName('foobar:foo')
|
||||
->setDescription('The foobar:foo command')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure has single blank line at start when using block element
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->caution('Lorem ipsum dolor sit amet');
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure has single blank line between titles and blocks
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->title('Title');
|
||||
$output->warning('Lorem ipsum dolor sit amet');
|
||||
$output->title('Title');
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure that all lines are aligned to the begin of the first line in a very long line block
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->block(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
||||
'CUSTOM',
|
||||
'fg=white;bg=green',
|
||||
'X ',
|
||||
true
|
||||
);
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure long words are properly wrapped in blocks
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon';
|
||||
$sfStyle = new SymfonyStyle($input, $output);
|
||||
$sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false);
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure that all lines are aligned to the begin of the first one and start with '//' in a very long line comment
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->comment(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
||||
);
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure that nested tags have no effect on the color of the '//' prefix
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output->setDecorated(true);
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->comment(
|
||||
'Lorem ipsum dolor sit <comment>amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</comment> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
|
||||
);
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure that block() behaves properly with a prefix and without type
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->block(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
||||
null,
|
||||
null,
|
||||
'$ ',
|
||||
true
|
||||
);
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure that block() behaves properly with a type and without prefix
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->block(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
||||
'TEST'
|
||||
);
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
// ensure that block() output is properly formatted (even padding lines)
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output->setDecorated(true);
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->success(
|
||||
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
|
||||
'TEST'
|
||||
);
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure symfony style helper methods handle trailing backslashes properly when decorating user texts
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
|
||||
$output->title('Title ending with \\');
|
||||
$output->section('Section ending with \\');
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure has single blank line between blocks
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->warning('Warning');
|
||||
$output->caution('Caution');
|
||||
$output->error('Error');
|
||||
$output->success('Success');
|
||||
$output->note('Note');
|
||||
$output->block('Custom block', 'CUSTOM', 'fg=white;bg=green', 'X ', true);
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
//Ensure has single blank line between two titles
|
||||
return function (InputInterface $input, OutputInterface $output) {
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$output->title('First title');
|
||||
$output->title('Second title');
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user