Skip to content

Commit 8031238

Browse files
feature #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 ------- 5b545240c6 [PhpUnitBridge][Console][VarDumper] Add support for `FORCE_COLOR` environment variable
2 parents c8f45ba + 9eaf17b commit 8031238

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

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)