Skip to content

Symfony Console Style tweaks #15964

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

Closed
wants to merge 8 commits into from
Closed
Prev Previous commit
Next Next commit
Calculate the length of the strings using the Helper methods
  • Loading branch information
javiereguiluz committed Sep 28, 2015
commit bbcbddbd77aa3e4ec8df1d2e354e5bb2c72c24d4
8 changes: 2 additions & 6 deletions src/Symfony/Component/Console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function title($message)
$this->autoPrependBlock();
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('=', strlen($message))),
sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($message))),
Copy link
Member

Choose a reason for hiding this comment

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

You should pass the return value of $this->getFormatter() as the first argument to Helper::strlenWithoutDecoration() (same below).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

));
$this->newLine();
}
Expand All @@ -120,14 +120,10 @@ public function title($message)
*/
public function section($message)
{
// don't take into account the style tags to compute the message length
// otherwise, the underline displayed after the section title is too long
$messageLength = strlen(preg_replace('/<.*>/U', '', $message));

$this->autoPrependBlock();
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('-', $messageLength)),
sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($message))),
));
$this->newLine();
}
Expand Down