Skip to content

Commit d30cb85

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Fix for issue #37681 Revert changes to Table->fillCells() [Console] Table: support cells with newlines after a cell with colspan >= 2 Fix redis connect with empty password [Validator] Add BC layer for notInRangeMessage when min and max are set
2 parents 57adf18 + 8b40d65 commit d30cb85

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

Helper/Table.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ private function buildTableRows(array $rows): TableRows
562562
if (0 === $lineKey) {
563563
$rows[$rowKey][$column] = $line;
564564
} else {
565+
if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) {
566+
$unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey);
567+
}
565568
$unmergedRows[$rowKey][$lineKey][$column] = $line;
566569
}
567570
}
@@ -573,8 +576,8 @@ private function buildTableRows(array $rows): TableRows
573576
yield $this->fillCells($row);
574577

575578
if (isset($unmergedRows[$rowKey])) {
576-
foreach ($unmergedRows[$rowKey] as $row) {
577-
yield $row;
579+
foreach ($unmergedRows[$rowKey] as $unmergedRow) {
580+
yield $this->fillCells($unmergedRow);
578581
}
579582
}
580583
}
@@ -658,6 +661,7 @@ private function fillNextRows(array $rows, int $line): array
658661
private function fillCells($row)
659662
{
660663
$newRow = [];
664+
661665
foreach ($row as $column => $cell) {
662666
$newRow[] = $cell;
663667
if ($cell instanceof TableCell && $cell->getColspan() > 1) {

Tests/Helper/TableTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,45 @@ public function renderProvider()
333333
| Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil! |
334334
+-------------------------------+-------------------------------+-----------------------------+
335335

336+
TABLE
337+
],
338+
'Cell after colspan contains new line break' => [
339+
['Foo', 'Bar', 'Baz'],
340+
[
341+
[
342+
new TableCell("foo\nbar", ['colspan' => 2]),
343+
"baz\nqux",
344+
],
345+
],
346+
'default',
347+
<<<'TABLE'
348+
+-----+-----+-----+
349+
| Foo | Bar | Baz |
350+
+-----+-----+-----+
351+
| foo | baz |
352+
| bar | qux |
353+
+-----+-----+-----+
354+
355+
TABLE
356+
],
357+
'Cell after colspan contains multiple new lines' => [
358+
['Foo', 'Bar', 'Baz'],
359+
[
360+
[
361+
new TableCell("foo\nbar", ['colspan' => 2]),
362+
"baz\nqux\nquux",
363+
],
364+
],
365+
'default',
366+
<<<'TABLE'
367+
+-----+-----+------+
368+
| Foo | Bar | Baz |
369+
+-----+-----+------+
370+
| foo | baz |
371+
| bar | qux |
372+
| | quux |
373+
+-----+-----+------+
374+
336375
TABLE
337376
],
338377
'Cell with rowspan' => [

0 commit comments

Comments
 (0)