From c1b0a8e956e86bf86913c481b7a169ebd04a77b1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 6 Nov 2019 11:22:37 +0100 Subject: [PATCH] Add support for NO_COLOR env var --- src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php | 5 +++++ src/Symfony/Component/Console/CHANGELOG.md | 1 + src/Symfony/Component/Console/Output/StreamOutput.php | 5 +++++ src/Symfony/Component/VarDumper/CHANGELOG.md | 1 + src/Symfony/Component/VarDumper/Dumper/CliDumper.php | 5 +++++ 5 files changed, 17 insertions(+) diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 304ad0c21c23a..1519fb2bbf184 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -357,6 +357,11 @@ private static function hasColorSupport() return false; } + // Follow https://no-color.org/ + if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { + return false; + } + if ('Hyper' === getenv('TERM_PROGRAM')) { return true; } diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index d722a6d5a554f..482c8cd362423 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG * deprecated returning `null` from `Command::execute()`, return `0` instead * Deprecated the `Application::renderException()` and `Application::doRenderException()` methods, use `renderThrowable()` and `doRenderThrowable()` instead. + * added support for the `NO_COLOR` env var (https://no-color.org/) 4.3.0 ----- diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 43f7a2f2340e6..312621086542e 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -97,6 +97,11 @@ protected function doWrite($message, $newline) */ protected function hasColorSupport() { + // Follow https://no-color.org/ + if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { + return false; + } + if ('Hyper' === getenv('TERM_PROGRAM')) { return true; } diff --git a/src/Symfony/Component/VarDumper/CHANGELOG.md b/src/Symfony/Component/VarDumper/CHANGELOG.md index a4eb962fd364b..94b1c17d1d538 100644 --- a/src/Symfony/Component/VarDumper/CHANGELOG.md +++ b/src/Symfony/Component/VarDumper/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG * added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data * added `UuidCaster` * made all casters final + * added support for the `NO_COLOR` env var (https://no-color.org/) 4.3.0 ----- diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 7662cc8000a57..b146fc8e6e797 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -582,6 +582,11 @@ private function hasColorSupport($stream): bool return false; } + // Follow https://no-color.org/ + if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { + return false; + } + if ('Hyper' === getenv('TERM_PROGRAM')) { return true; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy