From 260702eae8dd5a32cdc29d916d8acc409b163d48 Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Sun, 24 May 2015 19:59:51 +0200 Subject: [PATCH] [Console] SymfonyStyle : Improve EOL consistency by relying on output instance --- .../Component/Console/Style/SymfonyStyle.php | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 6d69eca54a..6f0bacd670 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -71,7 +71,7 @@ class SymfonyStyle extends OutputStyle // 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[] = ''; @@ -92,7 +92,8 @@ class SymfonyStyle extends OutputStyle } } - $this->writeln(implode("\n", $lines)."\n"); + $this->writeln($lines); + $this->newLine(); } /** @@ -100,7 +101,12 @@ class SymfonyStyle extends OutputStyle */ public function title($message) { - $this->writeln(sprintf("\n%s\n%s\n", $message, str_repeat('=', strlen($message)))); + $this->newLine(); + $this->writeln(array( + sprintf('%s', $message), + sprintf('%s', str_repeat('=', strlen($message))), + )); + $this->newLine(); } /** @@ -108,7 +114,11 @@ class SymfonyStyle extends OutputStyle */ public function section($message) { - $this->writeln(sprintf("%s\n%s\n", $message, str_repeat('-', strlen($message)))); + $this->writeln(array( + sprintf('%s', $message), + sprintf('%s', str_repeat('-', strlen($message))), + )); + $this->newLine(); } /** @@ -122,7 +132,8 @@ class SymfonyStyle extends OutputStyle $elements ); - $this->writeln(implode("\n", $elements)."\n"); + $this->writeln($elements); + $this->newLine(); } /**