Replace posix_isatty with cross-platform, always available stream_isatty
This commit is contained in:
parent
8375c6be4b
commit
c9b8b046a7
|
@ -864,14 +864,16 @@ class Application implements ResetInterface
|
|||
|
||||
if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
|
||||
$input->setInteractive(false);
|
||||
} elseif (\function_exists('posix_isatty')) {
|
||||
} else {
|
||||
$inputStream = null;
|
||||
|
||||
if ($input instanceof StreamableInputInterface) {
|
||||
$inputStream = $input->getStream();
|
||||
}
|
||||
|
||||
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
|
||||
$inputStream = !$inputStream && \defined('STDIN') ? STDIN : $inputStream;
|
||||
|
||||
if ((!$inputStream || !stream_isatty($inputStream)) && false === getenv('SHELL_INTERACTIVE')) {
|
||||
$input->setInteractive(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,16 +109,6 @@ class StreamOutput extends Output
|
|||
|| 'xterm' === getenv('TERM');
|
||||
}
|
||||
|
||||
if (\function_exists('stream_isatty')) {
|
||||
return @stream_isatty($this->stream);
|
||||
}
|
||||
|
||||
if (\function_exists('posix_isatty')) {
|
||||
return @posix_isatty($this->stream);
|
||||
}
|
||||
|
||||
$stat = @fstat($this->stream);
|
||||
// Check if formatted mode is S_IFCHR
|
||||
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
|
||||
return stream_isatty($this->stream);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -587,17 +587,7 @@ class CliDumper extends AbstractDumper
|
|||
|| 'xterm' === getenv('TERM');
|
||||
}
|
||||
|
||||
if (\function_exists('stream_isatty')) {
|
||||
return @stream_isatty($stream);
|
||||
}
|
||||
|
||||
if (\function_exists('posix_isatty')) {
|
||||
return @posix_isatty($stream);
|
||||
}
|
||||
|
||||
$stat = @fstat($stream);
|
||||
// Check if formatted mode is S_IFCHR
|
||||
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
|
||||
return stream_isatty($stream);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in New Issue