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 dc130be

Browse filesBrowse files
committed
[Console] Fix for block() padding formatting after #19189
Prevent future regression
1 parent e0f1476 commit dc130be
Copy full SHA for dc130be

File tree

3 files changed

+31
-6
lines changed
Filter options

3 files changed

+31
-6
lines changed

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,16 @@ private function createBlock($messages, $type = null, $style = null, $prefix = '
410410
}
411411
}
412412

413+
$firstLineIndex = 0;
414+
if ($padding && $this->isDecorated()) {
415+
$firstLineIndex = 1;
416+
array_unshift($lines, '');
417+
$lines[] = '';
418+
}
419+
413420
foreach ($lines as $i => &$line) {
414421
if (null !== $type) {
415-
$line = 0 === $i ? $type.$line : $lineIndentation.$line;
422+
$line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
416423
}
417424

418425
$line = $prefix.$line;
@@ -423,11 +430,6 @@ private function createBlock($messages, $type = null, $style = null, $prefix = '
423430
}
424431
}
425432

426-
if ($padding && $this->isDecorated()) {
427-
array_unshift($lines, '');
428-
$lines[] = '';
429-
}
430-
431433
return $lines;
432434
}
433435
}
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
6+
7+
// ensure that block() output is properly formatted (even padding lines)
8+
return function (InputInterface $input, OutputInterface $output) {
9+
$output->setDecorated(true);
10+
$output = new SymfonyStyleWithForcedLineLength($input, $output);
11+
$output->success(
12+
'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',
13+
'TEST'
14+
);
15+
};
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
 
3+
 [OK] Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
4+
 magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 
5+
 consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
6+
 Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum 
7+
 
8+

0 commit comments

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