comparison vendor/symfony/console/Output/StreamOutput.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children 129ea1e6d783
comparison
equal deleted inserted replaced
15:e200cb7efeb3 16:c2387f117808
81 /** 81 /**
82 * Returns true if the stream supports colorization. 82 * Returns true if the stream supports colorization.
83 * 83 *
84 * Colorization is disabled if not supported by the stream: 84 * Colorization is disabled if not supported by the stream:
85 * 85 *
86 * - the stream is redirected (eg php file.php >log) 86 * This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo
87 * - Windows without VT100 support, Ansicon, ConEmu, Mintty 87 * terminals via named pipes, so we can only check the environment.
88 * - non tty consoles 88 *
89 * Reference: Composer\XdebugHandler\Process::supportsColor
90 * https://github.com/composer/xdebug-handler
89 * 91 *
90 * @return bool true if the stream supports colorization, false otherwise 92 * @return bool true if the stream supports colorization, false otherwise
91 */ 93 */
92 protected function hasColorSupport() 94 protected function hasColorSupport()
93 { 95 {
94 if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) {
95 return false;
96 }
97 if (DIRECTORY_SEPARATOR === '\\') { 96 if (DIRECTORY_SEPARATOR === '\\') {
98 if (function_exists('sapi_windows_vt100_support')) { 97 return (function_exists('sapi_windows_vt100_support')
99 $vt100Enabled = @sapi_windows_vt100_support($this->stream); 98 && @sapi_windows_vt100_support($this->stream))
100 } else {
101 $vt100Enabled = '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD;
102 }
103
104 return
105 $vt100Enabled
106 || false !== getenv('ANSICON') 99 || false !== getenv('ANSICON')
107 || 'ON' === getenv('ConEmuANSI') 100 || 'ON' === getenv('ConEmuANSI')
108 || 'xterm' === getenv('TERM'); 101 || 'xterm' === getenv('TERM');
109 } 102 }
110 103
111 return function_exists('posix_isatty') && @posix_isatty($this->stream); 104 if (function_exists('stream_isatty')) {
105 return @stream_isatty($this->stream);
106 }
107
108 if (function_exists('posix_isatty')) {
109 return @posix_isatty($this->stream);
110 }
111
112 $stat = @fstat($this->stream);
113 // Check if formatted mode is S_IFCHR
114 return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
112 } 115 }
113 } 116 }