Skip to content

Commit 8fb48a5

Browse files
feature symfony#57777 [VarDumper] Add support for FORCE_COLOR environment variable (artshade)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [VarDumper] Add support for `FORCE_COLOR` environment variable | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT Commits ------- 5b54524 [PhpUnitBridge][Console][VarDumper] Add support for `FORCE_COLOR` environment variable
2 parents 9ad708b + 5b54524 commit 8fb48a5

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ private static function hasColorSupport(): bool
411411
return false;
412412
}
413413

414+
// Follow https://force-color.org/
415+
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
416+
return true;
417+
}
418+
414419
// Detect msysgit/mingw and assume this is a tty because detection
415420
// does not work correctly, see https://github.com/composer/composer/issues/9690
416421
if (!@stream_isatty(\STDOUT) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {

src/Symfony/Component/Console/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Add support for `FORCE_COLOR` environment variable
8+
49
7.1
510
---
611

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ protected function hasColorSupport(): bool
9494
return false;
9595
}
9696

97+
// Follow https://force-color.org/
98+
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
99+
return true;
100+
}
101+
97102
// Detect msysgit/mingw and assume this is a tty because detection
98103
// does not work correctly, see https://github.com/composer/composer/issues/9690
99104
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {

src/Symfony/Component/VarDumper/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Add support for `FORCE_COLOR` environment variable
8+
49
7.1
510
---
611

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,11 @@ private function hasColorSupport(mixed $stream): bool
591591
return false;
592592
}
593593

594+
// Follow https://force-color.org/
595+
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
596+
return true;
597+
}
598+
594599
// Detect msysgit/mingw and assume this is a tty because detection
595600
// does not work correctly, see https://github.com/composer/composer/issues/9690
596601
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {

0 commit comments

Comments
 (0)