feature #21664 [Console] simplify the implementation of SymfonyStyle::comment() (fabpot)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[Console] simplify the implementation of SymfonyStyle::comment()

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes-ish
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

2321491d3f [Console] simplify the implementation of SymfonyStyle::comment()
This commit is contained in:
Fabien Potencier 2017-02-19 06:39:30 -08:00
commit 64ec5c5faf

View File

@ -63,13 +63,14 @@ class SymfonyStyle extends OutputStyle
* @param string|null $style The style to apply to the whole block
* @param string $prefix The prefix for the block
* @param bool $padding Whether to add vertical padding
* @param bool $escape Whether to escape the message
*/
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = true)
{
$messages = is_array($messages) ? array_values($messages) : array($messages);
$this->autoPrependBlock();
$this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
$this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
$this->newLine();
}
@ -133,11 +134,7 @@ class SymfonyStyle extends OutputStyle
*/
public function comment($message)
{
$messages = is_array($message) ? array_values($message) : array($message);
$this->autoPrependBlock();
$this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
$this->newLine();
$this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
}
/**