Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3b71a9

Browse filesBrowse files
committed
fix color detection
1 parent fa7531f commit a3b71a9
Copy full SHA for a3b71a9

File tree

Expand file treeCollapse file tree

3 files changed

+15
-25
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+15
-25
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,10 @@ private static function hasColorSupport()
404404
}
405405

406406
if (!self::isTty()) {
407-
return true;
407+
return false;
408408
}
409409

410-
if ('\\' === \DIRECTORY_SEPARATOR
411-
&& \function_exists('sapi_windows_vt100_support')
412-
&& @sapi_windows_vt100_support(\STDOUT)
413-
) {
410+
if ('\\' === \DIRECTORY_SEPARATOR && \function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(\STDOUT)) {
414411
return true;
415412
}
416413

‎src/Symfony/Component/Console/Output/StreamOutput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Output/StreamOutput.php
+7-18Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ protected function hasColorSupport()
9595
return false;
9696
}
9797

98-
if (!$this->isTty()) {
98+
// Detect msysgit/mingw and assume this is a tty because detection
99+
// does not work correctly, see https://github.com/composer/composer/issues/9690
100+
if (!\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
101+
return false;
102+
}
103+
104+
if (!@stream_isatty(\STDOUT)) {
99105
return false;
100106
}
101107

@@ -118,21 +124,4 @@ protected function hasColorSupport()
118124
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
119125
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
120126
}
121-
122-
/**
123-
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
124-
*
125-
* Reference: Composer\Util\Platform::isTty
126-
* https://github.com/composer/composer
127-
*/
128-
private function isTty(): bool
129-
{
130-
// Detect msysgit/mingw and assume this is a tty because detection
131-
// does not work correctly, see https://github.com/composer/composer/issues/9690
132-
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
133-
return true;
134-
}
135-
136-
return @stream_isatty($this->stream);
137-
}
138127
}

‎src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Dumper/CliDumper.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,12 @@ private function hasColorSupport($stream): bool
612612

613613
// Detect msysgit/mingw and assume this is a tty because detection
614614
// does not work correctly, see https://github.com/composer/composer/issues/9690
615-
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
616-
return true;
615+
if (!\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
616+
return false;
617+
}
618+
619+
if (!@stream_isatty(\STDOUT)) {
620+
return false;
617621
}
618622

619623
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($stream)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.