Cell indexes not being respected when rendering row

Fixes #682
When calling `Row::setCellIndex`, it's possible to create a Row with holes.
Instead of iterating over existing cells of a Row, we should instead use the cell indexes (from 0 to max cell index).
This commit is contained in:
Adrien Loison authored and Adrien Loison committed 2019-09-28 14:02:23 +00:00
1 parent 2d297e954b
commit 16a2f91a22
6 files changed
+65 -41

No files matched your search

+8 -2
View File
@@ -70,7 +70,7 @@ class Row
*/
public function getCellAtIndex($cellIndex)
{
return isset($this->cells[$cellIndex]) ? $this->cells[$cellIndex] : null;
return $this->cells[$cellIndex] ?? null;
}
/**
@@ -89,7 +89,13 @@ class Row
*/
public function getNumCells()
{
return count($this->cells);
// When using "setCellAtIndex", it's possible to
// have "$this->cells" contain holes.
if (empty($this->cells)) {
return 0;
}
return max(array_keys($this->cells)) + 1;
}
/**