Skip to content

Commit d6def97

Browse files
Fix
1 parent c34d5f6 commit d6def97

File tree

1 file changed

+8
-6
lines changed
  • src/Symfony/Component/Console/Helper

1 file changed

+8
-6
lines changed

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,13 @@ private function buildTableRows(array $rows): TableRows
618618
if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
619619
$cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
620620
}
621-
if (!strstr($cell ?? '', \PHP_EOL)) {
621+
if (!strstr($cell ?? '', "\n")) {
622622
continue;
623623
}
624-
$escaped = implode(\PHP_EOL, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode(\PHP_EOL, $cell)));
624+
$eol = strstr($cell ?? '', \PHP_EOL) ? \PHP_EOL : "\n";
625+
$escaped = implode($eol, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode($eol, $cell)));
625626
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
626-
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default></>'.\PHP_EOL, $cell));
627+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell));
627628
foreach ($lines as $lineKey => $line) {
628629
if ($colspan > 1) {
629630
$line = new TableCell($line, ['colspan' => $colspan]);
@@ -684,9 +685,10 @@ private function fillNextRows(array $rows, int $line): array
684685
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
685686
$nbLines = $cell->getRowspan() - 1;
686687
$lines = [$cell];
687-
if (strstr($cell, \PHP_EOL)) {
688-
$lines = explode(\PHP_EOL, str_replace(\PHP_EOL, '<fg=default;bg=default>'.\PHP_EOL.'</>', $cell));
689-
$nbLines = \count($lines) > $nbLines ? substr_count($cell, \PHP_EOL) : $nbLines;
688+
if (strstr($cell, "\n")) {
689+
$eol = strstr($cell, \PHP_EOL) ? \PHP_EOL : "\n";
690+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell));
691+
$nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines;
690692

691693
$rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
692694
unset($lines[0]);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy