@@ -99,10 +99,7 @@ protected function hasColorSupport()
9999 return false ;
100100 }
101101
102- if (\DIRECTORY_SEPARATOR === '\\'
103- && \function_exists ('sapi_windows_vt100_support ' )
104- && @sapi_windows_vt100_support ($ this ->stream )
105- ) {
102+ if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support ($ this ->stream )) {
106103 return true ;
107104 }
108105
@@ -114,14 +111,12 @@ protected function hasColorSupport()
114111 return true ;
115112 }
116113
117- $ term = (string ) getenv ('TERM ' );
118-
119- if ('dumb ' === $ term ) {
114+ if ('dumb ' === $ term = (string ) getenv ('TERM ' )) {
120115 return false ;
121116 }
122117
123118 // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
124- return 1 === @ preg_match ('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/ ' , $ term );
119+ return preg_match ('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/ ' , $ term );
125120 }
126121
127122 /**
@@ -138,19 +133,6 @@ private function isTty(): bool
138133 return true ;
139134 }
140135
141- // Modern cross-platform function, includes the fstat fallback so if it is present we trust it
142- if (\function_exists ('stream_isatty ' )) {
143- return stream_isatty ($ this ->stream );
144- }
145-
146- // Only trusting this if it is positive, otherwise prefer fstat fallback.
147- if (\function_exists ('posix_isatty ' ) && posix_isatty ($ this ->stream )) {
148- return true ;
149- }
150-
151- $ stat = @fstat ($ this ->stream );
152-
153- // Check if formatted mode is S_IFCHR
154- return $ stat ? 0020000 === ($ stat ['mode ' ] & 0170000 ) : false ;
136+ return @stream_isatty ($ this ->stream );
155137 }
156138}
0 commit comments