From 7f35020eb723a626cd055f33b4a33ec8ebce8dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Mon, 7 Oct 2019 22:32:49 +0200 Subject: [PATCH] [Console] Consider STDIN interactive --- src/Symfony/Component/Console/Application.php | 13 --------- .../phpt/uses_stdin_as_interactive_input.phpt | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 9010fcae866e7..6272214f139cc 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -36,7 +36,6 @@ use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\StreamableInputInterface; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -864,18 +863,6 @@ protected function configureIO(InputInterface $input, OutputInterface $output) if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) { $input->setInteractive(false); - } else { - $inputStream = null; - - if ($input instanceof StreamableInputInterface) { - $inputStream = $input->getStream(); - } - - $inputStream = !$inputStream && \defined('STDIN') ? STDIN : $inputStream; - - if ((!$inputStream || !stream_isatty($inputStream)) && false === getenv('SHELL_INTERACTIVE')) { - $input->setInteractive(false); - } } switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) { diff --git a/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt b/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt new file mode 100644 index 0000000000000..db1bb4ce436e2 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/phpt/uses_stdin_as_interactive_input.phpt @@ -0,0 +1,28 @@ +--STDIN-- +Hello World +--FILE-- +register('app') + ->setCode(function(InputInterface $input, OutputInterface $output) { + $output->writeln((new QuestionHelper())->ask($input, $output, new Question('Foo?'))); + }) + ->getApplication() + ->setDefaultCommand('app', true) + ->run() +; +--EXPECT-- +Foo?Hello World