Skip to content

Commit d4c681c

Browse files
bug #57815 [Console][PhpUnitBridge][VarDumper] Fix NO_COLOR empty value handling (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | #57777 (comment) | License | MIT `NO_COLOR` must be non-empty in order to be considered enabled (https://no-color.org/): > when present and not an empty string (regardless of its value) Commits ------- 6a96ff9 [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling
2 parents 31e3abf + 6a96ff9 commit d4c681c

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private static function hasColorSupport()
410410
}
411411

412412
// Follow https://no-color.org/
413-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
413+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
414414
return false;
415415
}
416416

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
368368
}
369369
}
370370

371-
$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), false === $getEnvVar('NO_COLOR') ? 'always' : 'never');
371+
$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), '' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never');
372372
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
373373

374374
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -458,7 +458,7 @@ class SymfonyExcludeListSimplePhpunit
458458
{
459459
}
460460
}
461-
array_splice($argv, 1, 0, ['--colors='.(false === $getEnvVar('NO_COLOR') ? 'always' : 'never')]);
461+
array_splice($argv, 1, 0, ['--colors='.('' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never')]);
462462
$_SERVER['argv'] = $argv;
463463
$_SERVER['argc'] = ++$argc;
464464
include "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ protected function doWrite(string $message, bool $newline)
9191
protected function hasColorSupport()
9292
{
9393
// Follow https://no-color.org/
94-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
94+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
9595
return false;
9696
}
9797

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ private function hasColorSupport($stream): bool
606606
}
607607

608608
// Follow https://no-color.org/
609-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
609+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
610610
return false;
611611
}
612612

0 commit comments

Comments
 (0)
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