From 49b7764b137617afd3d9aee72f1040eaa6f35be7 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Wed, 24 Jul 2024 10:06:13 +0200 Subject: [PATCH] [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling --- DeprecationErrorHandler.php | 2 +- bin/simple-phpunit.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DeprecationErrorHandler.php b/DeprecationErrorHandler.php index 2821d92..c2c0cbb 100644 --- a/DeprecationErrorHandler.php +++ b/DeprecationErrorHandler.php @@ -410,7 +410,7 @@ private static function hasColorSupport() } // Follow https://no-color.org/ - if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { + if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) { return false; } diff --git a/bin/simple-phpunit.php b/bin/simple-phpunit.php index 816e8d9..c409cd2 100644 --- a/bin/simple-phpunit.php +++ b/bin/simple-phpunit.php @@ -368,7 +368,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla } } -$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), false === $getEnvVar('NO_COLOR') ? 'always' : 'never'); +$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), '' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never'); $cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s'; if ('\\' === \DIRECTORY_SEPARATOR) { @@ -458,7 +458,7 @@ class SymfonyExcludeListSimplePhpunit { } } - array_splice($argv, 1, 0, ['--colors='.(false === $getEnvVar('NO_COLOR') ? 'always' : 'never')]); + array_splice($argv, 1, 0, ['--colors='.('' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never')]); $_SERVER['argv'] = $argv; $_SERVER['argc'] = ++$argc; include "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit";