Skip to content

Commit

Permalink
Merge branch '4.4' into 5.1
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fabpot committed Aug 12, 2020
2 parents 57adf18 + 8b40d65 commit d30cb85
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Helper/Table.php
Expand Up @@ -562,6 +562,9 @@ private function buildTableRows(array $rows): TableRows
if (0 === $lineKey) {
$rows[$rowKey][$column] = $line;
} else {
if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) {
$unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey);
}
$unmergedRows[$rowKey][$lineKey][$column] = $line;
}
}
Expand All @@ -573,8 +576,8 @@ private function buildTableRows(array $rows): TableRows
yield $this->fillCells($row);

if (isset($unmergedRows[$rowKey])) {
foreach ($unmergedRows[$rowKey] as $row) {
yield $row;
foreach ($unmergedRows[$rowKey] as $unmergedRow) {
yield $this->fillCells($unmergedRow);
}
}
}
Expand Down Expand Up @@ -658,6 +661,7 @@ private function fillNextRows(array $rows, int $line): array
private function fillCells($row)
{
$newRow = [];

foreach ($row as $column => $cell) {
$newRow[] = $cell;
if ($cell instanceof TableCell && $cell->getColspan() > 1) {
Expand Down
39 changes: 39 additions & 0 deletions Tests/Helper/TableTest.php
Expand Up @@ -333,6 +333,45 @@ public function renderProvider()
| Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil! |
+-------------------------------+-------------------------------+-----------------------------+
TABLE
],
'Cell after colspan contains new line break' => [
['Foo', 'Bar', 'Baz'],
[
[
new TableCell("foo\nbar", ['colspan' => 2]),
"baz\nqux",
],
],
'default',
<<<'TABLE'
+-----+-----+-----+
| Foo | Bar | Baz |
+-----+-----+-----+
| foo | baz |
| bar | qux |
+-----+-----+-----+
TABLE
],
'Cell after colspan contains multiple new lines' => [
['Foo', 'Bar', 'Baz'],
[
[
new TableCell("foo\nbar", ['colspan' => 2]),
"baz\nqux\nquux",
],
],
'default',
<<<'TABLE'
+-----+-----+------+
| Foo | Bar | Baz |
+-----+-----+------+
| foo | baz |
| bar | qux |
| | quux |
+-----+-----+------+
TABLE
],
'Cell with rowspan' => [
Expand Down

0 comments on commit d30cb85

Please sign in to comment.