mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Update composer packages
This commit is contained in:
parent
58cc098058
commit
415aed8b31
59 changed files with 3352 additions and 2347 deletions
7
vendor/symfony/console/Application.php
vendored
7
vendor/symfony/console/Application.php
vendored
|
@ -199,6 +199,13 @@ class Application
|
|||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
|
||||
$input->bind($this->getDefinition());
|
||||
} catch (ExceptionInterface $e) {
|
||||
// Errors must be ignored, full binding/validation happens later when the command is known.
|
||||
}
|
||||
|
||||
$name = $this->getCommandName($input);
|
||||
if (true === $input->hasParameterOption(['--help', '-h'], true)) {
|
||||
if (!$name) {
|
||||
|
|
13
vendor/symfony/console/Helper/ProgressBar.php
vendored
13
vendor/symfony/console/Helper/ProgressBar.php
vendored
|
@ -381,20 +381,17 @@ final class ProgressBar
|
|||
$lines = floor(Helper::strlen($message) / $this->terminal->getWidth()) + $this->formatLineCount + 1;
|
||||
$this->output->clear($lines);
|
||||
} else {
|
||||
// Move the cursor to the beginning of the line
|
||||
$this->output->write("\x0D");
|
||||
|
||||
// Erase the line
|
||||
$this->output->write("\x1B[2K");
|
||||
|
||||
// Erase previous lines
|
||||
if ($this->formatLineCount > 0) {
|
||||
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
|
||||
$message = str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount).$message;
|
||||
}
|
||||
|
||||
// Move the cursor to the beginning of the line and erase the line
|
||||
$message = "\x0D\x1B[2K$message";
|
||||
}
|
||||
}
|
||||
} elseif ($this->step > 0) {
|
||||
$this->output->writeln('');
|
||||
$message = PHP_EOL.$message;
|
||||
}
|
||||
|
||||
$this->firstRun = false;
|
||||
|
|
14
vendor/symfony/console/Helper/QuestionHelper.php
vendored
14
vendor/symfony/console/Helper/QuestionHelper.php
vendored
|
@ -126,7 +126,7 @@ class QuestionHelper extends Helper
|
|||
if (false === $ret) {
|
||||
$ret = fgets($inputStream, 4096);
|
||||
if (false === $ret) {
|
||||
throw new RuntimeException('Aborted');
|
||||
throw new RuntimeException('Aborted.');
|
||||
}
|
||||
$ret = trim($ret);
|
||||
}
|
||||
|
@ -213,8 +213,10 @@ class QuestionHelper extends Helper
|
|||
while (!feof($inputStream)) {
|
||||
$c = fread($inputStream, 1);
|
||||
|
||||
// Backspace Character
|
||||
if ("\177" === $c) {
|
||||
// as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false.
|
||||
if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
|
||||
throw new RuntimeException('Aborted.');
|
||||
} elseif ("\177" === $c) { // Backspace Character
|
||||
if (0 === $numMatches && 0 !== $i) {
|
||||
--$i;
|
||||
// Move cursor backwards
|
||||
|
@ -267,6 +269,10 @@ class QuestionHelper extends Helper
|
|||
|
||||
continue;
|
||||
} else {
|
||||
if ("\x80" <= $c) {
|
||||
$c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
|
||||
}
|
||||
|
||||
$output->write($c);
|
||||
$ret .= $c;
|
||||
++$i;
|
||||
|
@ -339,7 +345,7 @@ class QuestionHelper extends Helper
|
|||
shell_exec(sprintf('stty %s', $sttyMode));
|
||||
|
||||
if (false === $value) {
|
||||
throw new RuntimeException('Aborted');
|
||||
throw new RuntimeException('Aborted.');
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
|
|
21
vendor/symfony/console/Input/ArgvInput.php
vendored
21
vendor/symfony/console/Input/ArgvInput.php
vendored
|
@ -257,8 +257,27 @@ class ArgvInput extends Input
|
|||
*/
|
||||
public function getFirstArgument()
|
||||
{
|
||||
foreach ($this->tokens as $token) {
|
||||
$isOption = false;
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
if ($token && '-' === $token[0]) {
|
||||
if (false !== strpos($token, '=') || !isset($this->tokens[$i + 1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a long option, consider that everything after "--" is the option name.
|
||||
// Otherwise, use the last char (if it's a short option set, only the last one can take a value with space separator)
|
||||
$name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
|
||||
if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
|
||||
// noop
|
||||
} elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
|
||||
$isOption = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($isOption) {
|
||||
$isOption = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
2
vendor/symfony/console/Input/ArrayInput.php
vendored
2
vendor/symfony/console/Input/ArrayInput.php
vendored
|
@ -19,7 +19,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException;
|
|||
*
|
||||
* Usage:
|
||||
*
|
||||
* $input = new ArrayInput(['name' => 'foo', '--bar' => 'foobar']);
|
||||
* $input = new ArrayInput(['command' => 'foo:bar', 'foo' => 'bar', '--bar' => 'foobar']);
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
|
|
4
vendor/symfony/console/Input/Input.php
vendored
4
vendor/symfony/console/Input/Input.php
vendored
|
@ -69,7 +69,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
|||
$givenArguments = $this->arguments;
|
||||
|
||||
$missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
|
||||
return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
|
||||
return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
|
||||
});
|
||||
|
||||
if (\count($missingArguments) > 0) {
|
||||
|
@ -150,7 +150,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
|||
throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
|
||||
}
|
||||
|
||||
return array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
|
||||
return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -338,8 +338,10 @@ class InputDefinition
|
|||
* @return string The InputOption name
|
||||
*
|
||||
* @throws InvalidArgumentException When option given does not exist
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
private function shortcutToName($shortcut)
|
||||
public function shortcutToName($shortcut)
|
||||
{
|
||||
if (!isset($this->shortcuts[$shortcut])) {
|
||||
throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
|
|
|
@ -60,9 +60,8 @@ class CommandTester
|
|||
}
|
||||
|
||||
$this->input = new ArrayInput($input);
|
||||
if ($this->inputs) {
|
||||
$this->input->setStream(self::createStream($this->inputs));
|
||||
}
|
||||
// Use an in-memory input stream even if no inputs are set so that QuestionHelper::ask() does not rely on the blocking STDIN.
|
||||
$this->input->setStream(self::createStream($this->inputs));
|
||||
|
||||
if (isset($options['interactive'])) {
|
||||
$this->input->setInteractive($options['interactive']);
|
||||
|
|
|
@ -126,7 +126,7 @@ trait TesterTrait
|
|||
*/
|
||||
private function initOutput(array $options)
|
||||
{
|
||||
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
$this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
if (isset($options['decorated'])) {
|
||||
|
|
13
vendor/symfony/console/Tests/ApplicationTest.php
vendored
13
vendor/symfony/console/Tests/ApplicationTest.php
vendored
|
@ -968,6 +968,19 @@ class ApplicationTest extends TestCase
|
|||
$this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed');
|
||||
}
|
||||
|
||||
public function testRunWithGlobalOptionAndNoCommand()
|
||||
{
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$application->getDefinition()->addOption(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL));
|
||||
|
||||
$output = new StreamOutput(fopen('php://memory', 'w', false));
|
||||
$input = new ArgvInput(['cli.php', '--foo', 'bar']);
|
||||
|
||||
$this->assertSame(0, $application->run($input, $output));
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue #9285.
|
||||
*
|
||||
|
|
|
@ -237,6 +237,43 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
|||
$this->assertSame('b', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
public function getInputs()
|
||||
{
|
||||
return [
|
||||
['$'], // 1 byte character
|
||||
['¢'], // 2 bytes character
|
||||
['€'], // 3 bytes character
|
||||
['𐍈'], // 4 bytes character
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInputs
|
||||
*/
|
||||
public function testAskWithAutocompleteWithMultiByteCharacter($character)
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
$inputStream = $this->getInputStream("$character\n");
|
||||
|
||||
$possibleChoices = [
|
||||
'$' => '1 byte character',
|
||||
'¢' => '2 bytes character',
|
||||
'€' => '3 bytes character',
|
||||
'𐍈' => '4 bytes character',
|
||||
];
|
||||
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->setHelperSet(new HelperSet([new FormatterHelper()]));
|
||||
|
||||
$question = new ChoiceQuestion('Please select a character', $possibleChoices);
|
||||
$question->setMaxAttempts(1);
|
||||
|
||||
$this->assertSame($character, $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
|
||||
}
|
||||
|
||||
public function testAutocompleteWithTrailingBackslash()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
|
@ -549,7 +586,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Aborted
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testAskThrowsExceptionOnMissingInput()
|
||||
{
|
||||
|
@ -559,7 +596,17 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Aborted
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testAskThrowsExceptionOnMissingInputForChoiceQuestion()
|
||||
{
|
||||
$dialog = new QuestionHelper();
|
||||
$dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream('')), $this->createOutputInterface(), new ChoiceQuestion('Choice', ['a', 'b']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testAskThrowsExceptionOnMissingInputWithValidator()
|
||||
{
|
||||
|
|
|
@ -124,7 +124,7 @@ class SymfonyQuestionHelperTest extends AbstractQuestionHelperTest
|
|||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Console\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Aborted
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testAskThrowsExceptionOnMissingInput()
|
||||
{
|
||||
|
|
|
@ -312,6 +312,14 @@ class ArgvInputTest extends TestCase
|
|||
|
||||
$input = new ArgvInput(['cli.php', '-fbbar', 'foo']);
|
||||
$this->assertEquals('foo', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input');
|
||||
|
||||
$input = new ArgvInput(['cli.php', '--foo', 'fooval', 'bar']);
|
||||
$input->bind(new InputDefinition([new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
|
||||
$this->assertSame('bar', $input->getFirstArgument());
|
||||
|
||||
$input = new ArgvInput(['cli.php', '-bf', 'fooval', 'argval']);
|
||||
$input->bind(new InputDefinition([new InputOption('bar', 'b', InputOption::VALUE_NONE), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputArgument('arg')]));
|
||||
$this->assertSame('argval', $input->getFirstArgument());
|
||||
}
|
||||
|
||||
public function testHasParameterOption()
|
||||
|
|
|
@ -17,6 +17,7 @@ use Symfony\Component\Console\Command\Command;
|
|||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
@ -139,7 +140,7 @@ class CommandTesterTest extends TestCase
|
|||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedMessage Aborted
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testCommandWithWrongInputsNumber()
|
||||
{
|
||||
|
@ -153,13 +154,40 @@ class CommandTesterTest extends TestCase
|
|||
$command->setHelperSet(new HelperSet([new QuestionHelper()]));
|
||||
$command->setCode(function ($input, $output) use ($questions, $command) {
|
||||
$helper = $command->getHelper('question');
|
||||
$helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b']));
|
||||
$helper->ask($input, $output, new Question($questions[0]));
|
||||
$helper->ask($input, $output, new Question($questions[1]));
|
||||
$helper->ask($input, $output, new Question($questions[2]));
|
||||
});
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$tester->setInputs(['a', 'Bobby', 'Fine']);
|
||||
$tester->execute([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage Aborted.
|
||||
*/
|
||||
public function testCommandWithQuestionsButNoInputs()
|
||||
{
|
||||
$questions = [
|
||||
'What\'s your name?',
|
||||
'How are you?',
|
||||
'Where do you come from?',
|
||||
];
|
||||
|
||||
$command = new Command('foo');
|
||||
$command->setHelperSet(new HelperSet([new QuestionHelper()]));
|
||||
$command->setCode(function ($input, $output) use ($questions, $command) {
|
||||
$helper = $command->getHelper('question');
|
||||
$helper->ask($input, $output, new ChoiceQuestion('choice', ['a', 'b']));
|
||||
$helper->ask($input, $output, new Question($questions[0]));
|
||||
$helper->ask($input, $output, new Question($questions[1]));
|
||||
$helper->ask($input, $output, new Question($questions[2]));
|
||||
});
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$tester->setInputs(['Bobby', 'Fine']);
|
||||
$tester->execute([]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue