@@ -181,13 +181,36 @@ private function getRendererException($error, $code, $line, $offset, $source, $s
181181 private function hasColorSupport ()
182182 {
183183 // @codeCoverageIgnoreStart
184- return DIRECTORY_SEPARATOR === '\\'
185- ? false !== getenv ('ANSICON ' ) ||
186- 'ON ' === getenv ('ConEmuANSI ' ) ||
187- false !== getenv ('BABUN_HOME ' )
188- : (false !== getenv ('BABUN_HOME ' )) ||
189- function_exists ('posix_isatty ' ) &&
190- @posix_isatty (STDOUT );
184+ if ('Hyper ' === getenv ('TERM_PROGRAM ' ) || getenv ('BABUN_HOME ' ) !== false ) {
185+ return true ;
186+ }
187+
188+ if (DIRECTORY_SEPARATOR === '\\' ) {
189+ return (defined ('STDOUT ' )
190+ && function_exists ('sapi_windows_vt100_support ' )
191+ && @sapi_windows_vt100_support (STDOUT )
192+ )
193+ || getenv ('ANSICON ' ) !== false
194+ || getenv ('ConEmuANSI ' ) === 'ON '
195+ || getenv ('TERM ' ) === 'xterm ' ;
196+ }
197+
198+ if (!defined ('STDOUT ' )) {
199+ return false ;
200+ }
201+
202+ if (is_resource (STDOUT )) {
203+ // These functions require a descriptor that is a real resource, not a numeric ID of it
204+ if (function_exists ('stream_isatty ' ) && @stream_isatty (STDOUT )) {
205+ return true ;
206+ }
207+
208+ $ stat = @fstat (STDOUT );
209+ // Check if formatted mode is S_IFCHR
210+ return $ stat ? 0020000 === ($ stat ['mode ' ] & 0170000 ) : false ;
211+ }
212+
213+ return function_exists ('posix_isatty ' ) && @posix_isatty (STDOUT );
191214 // @codeCoverageIgnoreEnd
192215 }
193216
0 commit comments