diff --git a/src/Framework/Environment.php b/src/Framework/Environment.php index 93301082..3acc52f6 100644 --- a/src/Framework/Environment.php +++ b/src/Framework/Environment.php @@ -78,15 +78,12 @@ public static function setupColors(): void self::$useColors = getenv(self::COLORS) !== false ? (bool) getenv(self::COLORS) : (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') - && (!function_exists('stream_isatty') || stream_isatty(STDOUT)) // PHP >= 7.2 - && getenv('NO_COLOR') === false - && (defined('PHP_WINDOWS_VERSION_BUILD') - ? (function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)) - || getenv('ConEmuANSI') === 'ON' // ConEmu - || getenv('ANSICON') !== false // ANSICON - || getenv('term') === 'xterm' // MSYS - || getenv('term') === 'xterm-256color' // MSYS - : (!function_exists('posix_isatty') || posix_isatty(STDOUT))); // PHP < 7.2 + && getenv('NO_COLOR') === false // https://no-color.org + && (getenv('FORCE_COLOR') + || (function_exists('sapi_windows_vt100_support') + ? sapi_windows_vt100_support(STDOUT) + : @stream_isatty(STDOUT)) // @ may trigger error 'cannot cast a filtered stream on this system' + ); ob_start(function (string $s): string { return self::$useColors ? $s : Dumper::removeColors($s);