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

Commit 63994c6

Browse filesBrowse files
committed
Render all line breaks according to the exception message
1 parent 800f306 commit 63994c6
Copy full SHA for 63994c6

File tree

3 files changed

+32
-3
lines changed
Filter options

3 files changed

+32
-3
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,8 @@ private function splitStringByWidth($string, $width)
11331133
$lines[] = str_pad($line, $width);
11341134
$line = $char;
11351135
}
1136-
if ('' !== $line) {
1137-
$lines[] = count($lines) ? str_pad($line, $width) : $line;
1138-
}
1136+
1137+
$lines[] = count($lines) ? str_pad($line, $width) : $line;
11391138

11401139
mb_convert_variables($encoding, 'utf8', $lines);
11411140

‎src/Symfony/Component/Console/Tests/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,22 @@ public function testRenderExceptionEscapesLines()
608608
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_escapeslines.txt', $tester->getDisplay(true), '->renderException() escapes lines containing formatting');
609609
}
610610

611+
public function testRenderExceptionLineBreaks()
612+
{
613+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
614+
$application->setAutoExit(false);
615+
$application->expects($this->any())
616+
->method('getTerminalWidth')
617+
->will($this->returnValue(120));
618+
$application->register('foo')->setCode(function () {
619+
throw new \InvalidArgumentException("\n\nline 1 with extra spaces \nline 2\n\nline 4\n");
620+
});
621+
$tester = new ApplicationTester($application);
622+
623+
$tester->run(array('command' => 'foo'), array('decorated' => false));
624+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_linebreaks.txt', $tester->getDisplay(true), '->renderException() keep multiple line breaks');
625+
}
626+
611627
public function testRun()
612628
{
613629
$application = new Application();
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
[InvalidArgumentException]
4+
5+
6+
line 1 with extra spaces
7+
line 2
8+
9+
line 4
10+
11+
12+
13+
foo
14+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.