src/System.php
public static function isColorsSupported($stream = STDOUT): bool
    {
        if ('Hyper' === getenv('TERM_PROGRAM')) {
            return true;
        }

        try {
            if (\DIRECTORY_SEPARATOR === '\\') {
                return (
                        function_exists('sapi_windows_vt100_support')
                        && @sapi_windows_vt100_support($stream)
                    ) || getenv('ANSICON') !== false
                    || getenv('ConEmuANSI') == 'ON'
                    || getenv('TERM') == 'xterm';
            }

            if (\function_exists('stream_isatty')) {
                return @stream_isatty($stream);
            }

            if (\function_exists('posix_isatty')) {
                return @posix_isatty($stream);
            }

            $stat = @fstat($stream);

            // Check if formatted mode is S_IFCHR
            return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
        } catch (\Throwable $e) {
            return false;
        }
    }
public static function isColorsSupported($stream = STDOUT): bool
    {
        if ('Hyper' === getenv('TERM_PROGRAM')) {
            return true;
        }

        try {
            if (\DIRECTORY_SEPARATOR === '\\') {
                return (
                        function_exists('sapi_windows_vt100_support')
                        && @sapi_windows_vt100_support($stream)
                    ) || getenv('ANSICON') !== false
                    || getenv('ConEmuANSI') == 'ON'
                    || getenv('TERM') == 'xterm';
            }

            if (\function_exists('stream_isatty')) {
                return @stream_isatty($stream);
            }

            if (\function_exists('posix_isatty')) {
                return @posix_isatty($stream);
            }

            $stat = @fstat($stream);

            // Check if formatted mode is S_IFCHR
            return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
        } catch (\Throwable $e) {
            return false;
        }
    }
public static function isColorsSupported ( $ stream = STDOUT ) : bool { if ( 'Hyper' === getenv ( 'TERM_PROGRAM' ) ) { return true ; } try { if ( \ DIRECTORY_SEPARATOR === '\\' ) { return ( function_exists ( 'sapi_windows_vt100_support' ) && @ sapi_windows_vt100_support ( $ stream ) ) || getenv ( 'ANSICON' ) !== false || getenv ( 'ConEmuANSI' ) == 'ON' || getenv ( 'TERM' ) == 'xterm' ; } if ( \ function_exists ( 'stream_isatty' ) ) { return @ stream_isatty ( $ stream ) ; } if ( \ function_exists ( 'posix_isatty' ) ) { return @ posix_isatty ( $ stream ) ; } $ stat = @ fstat ( $ stream ) ; // Check if formatted mode is S_IFCHR return $ stat ? 0020000 === ( $ stat [ 'mode' ] & 0170000 ) : false ; } catch ( \ Throwable $ e ) { return false ; } }
Returns true if the STDOUT supports colorization.

@codeCoverageIgnore
@link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L94
@param mixed $stream
@return bool
Returns true if the STDOUT supports colorization .