Skip to content

Commit 176d1de

Browse files
committed
bug symfony#50143 [Console] trim(): Argument #1 () must be of type string, bool given (danepowell)
This PR was merged into the 5.4 branch. Discussion ---------- [Console] trim(): Argument #1 () must be of type string, bool given | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? |no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? |no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> If you run a Symfony Console application in Git Bash, ANSICON is not set out of the box and results in this (suppressed) error: > trim(): Argument ($string) must be of type string, bool given AFAICT, this method is only called from Application::run() and errors are suppressed. So users will never actually see that error. Still, it could have side effects and breaks downstream projects: box-project/box#990 Commits ------- 324b160 trim(): Argument #1 () must be of type string, bool given
2 parents 30d5bd4 + 324b160 commit 176d1de

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Symfony/Component/Console/Terminal.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public static function hasSttyAvailable(): bool
7777
private static function initDimensions()
7878
{
7979
if ('\\' === \DIRECTORY_SEPARATOR) {
80-
if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
80+
$ansicon = getenv('ANSICON');
81+
if (false !== $ansicon && preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim($ansicon), $matches)) {
8182
// extract [w, H] from "wxh (WxH)"
8283
// or [w, h] from "wxh"
8384
self::$width = (int) $matches[1];

0 commit comments

Comments
 (0)