Skip to content

Commit d8111ac

Browse files
committed
[Console] Fix null handling in formatAndWrap()
1 parent 5caf5d8 commit d8111ac

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Formatter/OutputFormatter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public function format(?string $message)
140140
*/
141141
public function formatAndWrap(?string $message, int $width)
142142
{
143+
if (null === $message) {
144+
return '';
145+
}
146+
143147
$offset = 0;
144148
$output = '';
145149
$openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';

Tests/Formatter/OutputFormatterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ public function testFormatAndWrap()
343343
$this->assertSame("pre\nfoo\nbar\nbaz\npos\nt", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 3));
344344
$this->assertSame("pre \nfoo \nbar \nbaz \npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 4));
345345
$this->assertSame("pre f\noo ba\nr baz\npost", $formatter->formatAndWrap('pre <error>foo bar baz</error> post', 5));
346+
$this->assertSame('', $formatter->formatAndWrap(null, 5));
346347
}
347348
}
348349

0 commit comments

Comments
 (0)