Skip to content

Commit 78f25bc

Browse files
Merge branch '2.7' into 2.8
* 2.7: [VarDumper] Remove decoration from actual output in tests [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage
2 parents a110b32 + 6542484 commit 78f25bc

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

DeprecationErrorHandler.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,38 @@ public static function register($mode = 0)
212212
}
213213
}
214214

215+
/**
216+
* Returns true if STDOUT is defined and supports colorization.
217+
*
218+
* Reference: Composer\XdebugHandler\Process::supportsColor
219+
* https://github.com/composer/xdebug-handler
220+
*
221+
* @return bool
222+
*/
215223
private static function hasColorSupport()
216224
{
217-
if ('\\' === DIRECTORY_SEPARATOR) {
218-
return
219-
defined('STDOUT') && function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)
220-
|| '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
225+
if (!defined('STDOUT')) {
226+
return false;
227+
}
228+
229+
if (DIRECTORY_SEPARATOR === '\\') {
230+
return (function_exists('sapi_windows_vt100_support')
231+
&& sapi_windows_vt100_support(STDOUT))
221232
|| false !== getenv('ANSICON')
222233
|| 'ON' === getenv('ConEmuANSI')
223234
|| 'xterm' === getenv('TERM');
224235
}
225236

226-
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
237+
if (function_exists('stream_isatty')) {
238+
return stream_isatty(STDOUT);
239+
}
240+
241+
if (function_exists('posix_isatty')) {
242+
return posix_isatty(STDOUT);
243+
}
244+
245+
$stat = fstat(STDOUT);
246+
// Check if formatted mode is S_IFCHR
247+
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
227248
}
228249
}

0 commit comments

Comments
 (0)