8000 [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments by chalasr · Pull Request #18889 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments #18889

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
May 30, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
*/
protected function describeContainerAlias(Alias $alias, array $options = array())
{
$options['output']->comment(sprintf("This service is an alias for the service <info>%s</info>\n", (string) $alias));
$options['output']->comment(sprintf('This service is an alias for the service <info>%s</info>', (string) $alias));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// This service is an alias for the service service_1

// This service is an alias for the service service_1

Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// This service is an alias for the service service_2

// This service is an alias for the service service_2

12 changes: 7 additions & 5 deletions src/Symfony/Component/Console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,18 @@ public function text($message)
}

/**
* {@inheritdoc}
* Formats a command comment.
*
* @param string|array $message
*/
public function comment($message)
{
$this->autoPrependText();

$messages = is_array($message) ? array_values($message) : array($message);
foreach ($messages as $message) {
$this->writeln(sprintf(' // %s', $message));
foreach ($messages as &$message) {
$message = $this->getFormatter()->format($message);
}

$this->block($messages, null, null, ' // ');
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;

//Ensure that all lines are aligned to the begin of the first one and start with '//' in a very long line comment
return function (InputInterface $input, OutputInterface $output) {
$output = new SymfonyStyleWithForcedLineLength($input, $output);
$output->comment(
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
// aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
// Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
// sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ Lorem ipsum dolor sit amet
consectetur adipiscing elit

Lorem ipsum dolor sit amet
// Lorem ipsum dolor sit amet
// consectetur adipiscing elit

// Lorem ipsum dolor sit amet
//
// consectetur adipiscing elit

0