Skip to content

[Console][PhpUnitBridge][VarDumper] Add support for FORCE_COLOR environment variable #57777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
private $configuration;

/**
* @var DeprecationGroup[]

Check failure on line 39 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedDocblockClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:39:13: UndefinedDocblockClass: Docblock-defined class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/200)
*/
private $deprecationGroups = [];

Check failure on line 41 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedDocblockClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:41:5: UndefinedDocblockClass: Docblock-defined class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/200)

private static $isRegistered = false;
private static $errorHandler;
Expand Down Expand Up @@ -238,12 +238,12 @@
private function resetDeprecationGroups()
{
$this->deprecationGroups = [
'unsilenced' => new DeprecationGroup(),

Check failure on line 241 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:241:33: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'self' => new DeprecationGroup(),

Check failure on line 242 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:242:27: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'direct' => new DeprecationGroup(),

Check failure on line 243 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:243:29: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'indirect' => new DeprecationGroup(),

Check failure on line 244 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:244:31: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'legacy' => new DeprecationGroup(),

Check failure on line 245 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:245:29: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'other' => new DeprecationGroup(),

Check failure on line 246 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:246:28: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
];
}

Expand Down Expand Up @@ -411,6 +411,11 @@
return false;
}

// Follow https://force-color.org/
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {

Check failure on line 415 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArrayAccess

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:415:21: InvalidArrayAccess: Cannot access array value on non-array variable of type false (see https://psalm.dev/005)
return true;
}

// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty(\STDOUT) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Console/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.2
---

* Add support for `FORCE_COLOR` environment variable

7.1
---

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Console/Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
return false;
}

// Follow https://force-color.org/
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {

Check failure on line 98 in src/Symfony/Component/Console/Output/StreamOutput.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArrayAccess

src/Symfony/Component/Console/Output/StreamOutput.php:98:21: InvalidArrayAccess: Cannot access array value on non-array variable of type false (see https://psalm.dev/005)
return true;
}

// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/VarDumper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.2
---

* Add support for `FORCE_COLOR` environment variable

7.1
---

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/VarDumper/Dumper/CliDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ private function hasColorSupport(mixed $stream): bool
return false;
}

// Follow https://force-color.org/
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
return true;
}

// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
Expand Down
Loading