Skip to content

Commit 6b099f3

Browse files
Merge branch '6.4' into 7.0
* 6.4: [DependencyInjection] Fix computing error messages involving service locators [Serializer] Fix unknown types normalization type when know type [ErrorHandler] Fix parsing messages that contain anonymous classes on PHP >= 8.3.3 [AssetMapper] Fix enquoted string pattern [Validator] Review Romanian (ro) translations [Console] Fix display of Table on Windows OS [FrameworkBundle] Fix config builder with extensions extended in `build()` [Translation] Fix extracting qualified t() function calls Fix vertical table on windows Fix the `command -v` exception when the command option with a dash prefix [WebProfilerBundle] disable turbo in web profiler toolbar to avoid link prefetching explicitly cast boolean SSL stream options return the unchanged text if preg_replace_callback() fails the 'use_notify' option is on the factory, not on the postgres connection class review translations
2 parents b95e86a + 0d9e4eb commit 6b099f3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Helper/Table.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ public function render(): void
361361
for ($i = 0; $i < $maxRows; ++$i) {
362362
$cell = (string) ($row[$i] ?? '');
363363

364-
$parts = explode("\n", $cell);
364+
$eol = str_contains($cell, "\r\n") ? "\r\n" : "\n";
365+
$parts = explode($eol, $cell);
365366
foreach ($parts as $idx => $part) {
366367
if ($headers && !$containsColspan) {
367368
if (0 === $idx) {
@@ -632,9 +633,10 @@ private function buildTableRows(array $rows): TableRows
632633
if (!str_contains($cell ?? '', "\n")) {
633634
continue;
634635
}
635-
$escaped = implode("\n", array_map(OutputFormatter::escapeTrailingBackslash(...), explode("\n", $cell)));
636+
$eol = str_contains($cell ?? '', "\r\n") ? "\r\n" : "\n";
637+
$escaped = implode($eol, array_map(OutputFormatter::escapeTrailingBackslash(...), explode($eol, $cell)));
636638
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
637-
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default></>\n", $cell));
639+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell));
638640
foreach ($lines as $lineKey => $line) {
639641
if ($colspan > 1) {
640642
$line = new TableCell($line, ['colspan' => $colspan]);
@@ -696,8 +698,9 @@ private function fillNextRows(array $rows, int $line): array
696698
$nbLines = $cell->getRowspan() - 1;
697699
$lines = [$cell];
698700
if (str_contains($cell, "\n")) {
699-
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
700-
$nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
701+
$eol = str_contains($cell, "\r\n") ? "\r\n" : "\n";
702+
$lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell));
703+
$nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines;
701704

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

0 commit comments

Comments
 (0)