Skip to content
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

fix: using multiple CLI::color() in CLI::write() outputs strings with wrong color #5893

Merged
merged 10 commits into from
Apr 18, 2022
Prev Previous commit
Next Next commit
refactor: vendor/bin/rector process
  • Loading branch information
kenjis committed Apr 13, 2022
commit f406f4aee220b3b85474219b3a4bf0397e914f48
8 changes: 2 additions & 6 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,7 @@ public static function color(string $text, string $foreground, ?string $backgrou

// No colored string found. Invalid strings with no `\033[0;??`.
if ($coloredStrings === []) {
$newText .= self::getColoredText($text, $foreground, $background, $format);

return $newText;
return $newText . self::getColoredText($text, $foreground, $background, $format);
}

$nonColoredText = preg_replace(
Expand Down Expand Up @@ -540,9 +538,7 @@ private static function getColoredText(string $text, string $foreground, ?string
$string .= "\033[4m";
}

$string .= $text . "\033[0m";

return $string;
return $string . ($text . "\033[0m");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the need for parenthesis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems rector added.
Removed.

}

/**
Expand Down