8000 Logic fixes · symfony/symfony@a61d607 · GitHub
[go: up one dir, main page]

Skip to content

Commit a61d607

Browse files
committed
Logic fixes
Check for that implements StreamableInputInterface Rollback E_USER_DEPRECATED notice in getInputStream Remove legacy tests to avoid KO because of deprecations Add missing use
1 parent 64ac56b commit a61d607

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Helper\ProcessHelper;
1717
use Symfony\Component\Console\Helper\QuestionHelper;
1818
use Symfony\Component\Console\Input\InputInterface;
19+
use Symfony\Component\Console\Input\StreamableInputInterface;
1920
use Symfony\Component\Console\Input\ArgvInput;
2021
use Symfony\Component\Console\Input\ArrayInput;
2122
use Symfony\Component\Console\Input\InputDefinition;
@@ -770,12 +771,17 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
770771
if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) {
771772
$input->setInteractive(false);
772773
} elseif (function_exists('posix_isatty')) {
773-
$inputStream = $input->getStream();
774-
774+
$inputStream = null;
775+
// Ensure that calling QuestionHelper::setInputStream will works.
776+
// To be removed in the same time as getInputStream/setInputStream methods
775777
if ($this->getHelperSet()->has('question')) {
776778
$inputStream = $this->getHelperSet()->get('question')->getInputStream() ?: $inputStream;
777779
}
778780

781+
if (!$inputStream && $input instanceof StreamableInputInterface) {
782+
$inputStream = $input->getStream();
783+
}
784+
779785
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
780786
$input->setInteractive(false);
781787
}

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Console\Exception\InvalidArgumentException;
1515
use Symfony\Component\Console\Exception\RuntimeException;
1616
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Input\StreamableInputInterface;
1718
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1819
use Symfony\Component\Console\Output\OutputInterface;
1920
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
@@ -78,7 +79,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu
7879
*/
7980
public function setInputStream($stream)
8081
{
81-
@trigger_error(sprintf('The setInputStream() method is deprecated since version 3.1 and will be removed in 4.0. Use %s:setStream() instead.', InputInterface::class), E_USER_DEPRECATED);
82+
@trigger_error(sprintf('The setInputStream() method is deprecated since version 3.1 and will be removed in 4.0. Use %s:setStream() instead.', StreamableInputInterface::class), E_USER_DEPRECATED);
8283

8384
if (!is_resource($stream)) {
8485
throw new InvalidArgumentException('Input stream must be a valid resource.');
@@ -90,12 +91,12 @@ public function setInputStream($stream)
9091
/**
9192
* Returns the helper's input stream.
9293
*
94+
* @deprecated Will be removed in 4.0, use StreamableInputInterface::getStream() instead
95+
*
9396
* @return resource
9497
*/
9598
public function getInputStream()
9699
{
97-
@trigger_error(sprintf('The getInputStream() method is deprecated since version 3.1 and will be removed in 4.0. Use %s:getStream() instead.', InputInterface::class), E_USER_DEPRECATED);
98-
99100
return $this->inputStream;
100101
}
101102

0 commit comments

Comments
 (0)
0