Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Console] SymfonyStyle : EOL consistency #14741

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
Jun 8, 2015
Merged
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
21 changes: 16 additions & 5 deletions 21 src/Symfony/Component/Console/Style/SymfonyStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function block($messages, $type = null, $style = null, $prefix = ' ', $pa
// wrap and add newlines for each element
foreach ($messages as $key => $message) {
$message = OutputFormatter::escape($message);
$lines = array_merge($lines, explode("\n", wordwrap($message, $this->lineLength - Helper::strlen($prefix))));
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL)));

if (count($messages) > 1 && $key < count($messages) - 1) {
$lines[] = '';
Expand All @@ -92,23 +92,33 @@ public function block($messages, $type = null, $style = null, $prefix = ' ', $pa
}
}

$this->writeln(implode("\n", $lines)."\n");
$this->writeln($lines);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use array_push here instead $lines[] = ''; ?

$this->writeln(array_push($lines, ''));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aitboudad : array_push returns the new number of elements in the array. So we will not be able to inline those statements using array_push.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But this would be possible:

$this->writeln(array_merge($lines, (array) ''));
//or
$this->writeln(array_merge($lines, array('')));

Copy link
Contributor

Choose a reason for hiding this comment

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

leave it as it is :)

$this->newLine();
}

/**
* {@inheritdoc}
*/
public function title($message)
{
$this->writeln(sprintf("\n<comment>%s</>\n<comment>%s</>\n", $message, str_repeat('=', strlen($message))));
$this->newLine();
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('=', strlen($message))),
));
$this->newLine();
}

/**
* {@inheritdoc}
*/
public function section($message)
{
$this->writeln(sprintf("<comment>%s</>\n<comment>%s</>\n", $message, str_repeat('-', strlen($message))));
$this->writeln(array(
sprintf('<comment>%s</>', $message),
sprintf('<comment>%s</>', str_repeat('-', strlen($message))),
));
$this->newLine();
}

/**
Expand All @@ -122,7 +132,8 @@ public function listing(array $elements)
$elements
);

$this->writeln(implode("\n", $elements)."\n");
$this->writeln($elements);
$this->newLine();
}

/**
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.