Skip to content

Commit

Permalink
[Console] Reset question validator attempts only for actual stdin (bis)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 15, 2020
1 parent 52612b1 commit 0aff5d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Symfony/Component/Console/Helper/QuestionHelper.php
Expand Up @@ -104,7 +104,7 @@ private function doAsk(OutputInterface $output, Question $question)
{
$this->writePrompt($output, $question);

$inputStream = $this->inputStream ?: STDIN;
$inputStream = $this->inputStream ?: fopen('php://stdin', 'r');
$autocomplete = $question->getAutocompleterCallback();

if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
Expand Down Expand Up @@ -509,16 +509,18 @@ private function getShell()

private function isTty(): bool
{
if (!\defined('STDIN')) {
$inputStream = $this->inputStream ?: fopen('php://stdin', 'r');

if ('php://stdin' !== (stream_get_meta_data($inputStream)['url'] ?? null)) {
return true;
}

if (\function_exists('stream_isatty')) {
return stream_isatty(fopen('php://input', 'r'));
return stream_isatty($inputStream);
}

if (\function_exists('posix_isatty')) {
return posix_isatty(fopen('php://input', 'r'));
return posix_isatty($inputStream);
}

return true;
Expand Down

0 comments on commit 0aff5d8

Please sign in to comment.