Skip to content

Commit 7f78892

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Add PHPDbg support to HTTP components bumped Symfony version to 2.7.45 updated VERSION for 2.7.44 update CONTRIBUTORS for 2.7.44 updated CHANGELOG for 2.7.44 Fix check of color support on Windows
2 parents 390fa48 + 505b038 commit 7f78892

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Output/StreamOutput.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,26 @@ protected function doWrite($message, $newline)
8383
*
8484
* Colorization is disabled if not supported by the stream:
8585
*
86-
* - Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
86+
* - the stream is redirected (eg php file.php >log)
87+
* - Windows without VT100 support, Ansicon, ConEmu, Mintty
8788
* - non tty consoles
8889
*
8990
* @return bool true if the stream supports colorization, false otherwise
9091
*/
9192
protected function hasColorSupport()
9293
{
94+
if (function_exists('stream_isatty') && !@stream_isatty($this->stream)) {
95+
return false;
96+
}
9397
if (DIRECTORY_SEPARATOR === '\\') {
98+
if (function_exists('sapi_windows_vt100_support')) {
99+
$vt100Enabled = @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+
94104
return
95-
function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($this->stream)
96-
|| '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
105+
$vt100Enabled
97106
|| false !== getenv('ANSICON')
98107
|| 'ON' === getenv('ConEmuANSI')
99108
|| 'xterm' === getenv('TERM');

0 commit comments

Comments
 (0)