8000 minor #53856 [PhpUnitBridge][VarDumper] fix color detection (xabbuh) · symfony/symfony@0b75c96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b75c96

Browse files
minor #53856 [PhpUnitBridge][VarDumper] fix color detection (xabbuh)
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
2 parents 9afa8a8 + 3a09f2f commit 0b75c96

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines 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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ 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 (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
99101
return false;
100102
}
101103

@@ -118,21 +120,4 @@ protected function hasColorSupport()
118120
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
119121
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
120122
}
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-
}
138123
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ private function hasColorSupport($stream): bool
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
615615
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
616-
return true;
616+
return false;
617617
}
618618

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

0 commit comments

Comments
 (0)
0