[Console] Reset question validator attempts only for actual stdin (bis)
This commit is contained in:
parent
52612b1541
commit
867642e337
@ -104,7 +104,7 @@ class QuestionHelper extends Helper
|
||||
{
|
||||
$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()) {
|
||||
@ -474,7 +474,7 @@ class QuestionHelper extends Helper
|
||||
} catch (\Exception $error) {
|
||||
}
|
||||
|
||||
$attempts = $attempts ?? -(int) $this->isTty();
|
||||
$attempts = $attempts ?? -(int) $this->askForever();
|
||||
}
|
||||
|
||||
throw $error;
|
||||
@ -507,18 +507,20 @@ class QuestionHelper extends Helper
|
||||
return self::$shell;
|
||||
}
|
||||
|
||||
private function isTty(): bool
|
||||
private function askForever(): 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;
|
||||
|
Reference in New Issue
Block a user