-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnitBridge][VarDumper] Fix color detection #53794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} | ||
|
||
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157 | ||
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be @\
? (not sure if the pcre
extension is declared in the composer.json
either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would it? preg_match doesn't trigger notices unless the regexp is badly formatted, which it isn't
about ext-pcre, we never list it as a requirement - it's one of the builtin extensions.
@@ -403,27 +403,58 @@ private static function hasColorSupport() | |||
return false; | |||
} | |||
|
|||
if ('Hyper' === getenv('TERM_PROGRAM')) { | |||
if (!self::isTty()) { | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is broken. For not a TTY, it should says false
if ('Hyper' === getenv('TERM_PROGRAM')) { | ||
// Detect msysgit/mingw and assume this is a tty because detection | ||
// does not work correctly, see https://github.com/composer/composer/issues/9690 | ||
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) { | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in this method does not match the logic in the console component. A stream that is not a TTY must not report supporting colors.
This PR was merged into the 5.4 branch. Discussion ---------- [PhpUnitBridge][VarDumper] fix color detection | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT reworks the logic changes from #53794 Commits ------- 3a09f2f [PhpUnitBridge][VarDumper] fix color detection
Porting #53707 to VarDumper and tweaking it a bit.
/cc @theofidry FYI