Windows 10 version check in just one line
This commit is contained in:
parent
01fb26b4d2
commit
5f5a71770b
@ -160,7 +160,11 @@ class DeprecationErrorHandler
|
||||
private static function hasColorSupport()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
|
||||
return
|
||||
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM');
|
||||
}
|
||||
|
||||
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
|
||||
|
@ -58,8 +58,8 @@ class CliDumper extends AbstractDumper
|
||||
{
|
||||
parent::__construct($output, $charset);
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && false !== @getenv('ANSICON')) {
|
||||
// Use only the base 16 xterm colors when using ANSICON
|
||||
if ('\\' === DIRECTORY_SEPARATOR && 'ON' !== @getenv('ConEmuANSI') && 'xterm' !== @getenv('TERM')) {
|
||||
// Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI
|
||||
$this->setStyles(array(
|
||||
'default' => '31',
|
||||
'num' => '1;34',
|
||||
@ -448,7 +448,12 @@ class CliDumper extends AbstractDumper
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
static::$defaultColors = @(false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'));
|
||||
static::$defaultColors = @(
|
||||
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM')
|
||||
);
|
||||
} elseif (function_exists('posix_isatty')) {
|
||||
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);
|
||||
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'wb') : $this->outputStream;
|
||||
|
Reference in New Issue
Block a user