diff --git a/Output/StreamOutput.php b/Output/StreamOutput.php index 155066ea0..b390ac941 100644 --- a/Output/StreamOutput.php +++ b/Output/StreamOutput.php @@ -96,18 +96,17 @@ protected function hasColorSupport(): bool return false; } - if ('Hyper' === getenv('TERM_PROGRAM')) { + if (\DIRECTORY_SEPARATOR === '\\' + && \function_exists('sapi_windows_vt100_support') + && @sapi_windows_vt100_support($this->stream) + ) { return true; } - if (\DIRECTORY_SEPARATOR === '\\') { - return (\function_exists('sapi_windows_vt100_support') - && @sapi_windows_vt100_support($this->stream)) - || false !== getenv('ANSICON') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM'); - } - - return stream_isatty($this->stream); + return 'Hyper' === getenv('TERM_PROGRAM') + || false !== getenv('ANSICON') + || 'ON' === getenv('ConEmuANSI') + || str_starts_with((string) getenv('TERM'), 'xterm') + || stream_isatty($this->stream); } }