Address scrutinizer issues
This commit is contained in:
parent
d9ddc162a3
commit
da43a880e3
|
|
@ -135,15 +135,14 @@ class Table extends AbstractElement
|
|||
public function countColumns()
|
||||
{
|
||||
$columnCount = 0;
|
||||
if (is_array($this->rows)) {
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
$columnCount = $cellCount;
|
||||
}
|
||||
|
||||
$rowCount = count($this->rows);
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
$row = $this->rows[$i];
|
||||
$cellCount = count($row->getCells());
|
||||
if ($columnCount < $cellCount) {
|
||||
$columnCount = $cellCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,16 +157,15 @@ class Table extends AbstractElement
|
|||
public function findFirstDefinedCellWidths()
|
||||
{
|
||||
$cellWidths = array();
|
||||
if (is_array($this->rows)) {
|
||||
foreach ($this->rows as $row) {
|
||||
$cells = $row->getCells();
|
||||
if (count($cells) <= count($cellWidths)) {
|
||||
continue;
|
||||
}
|
||||
$cellWidths = array();
|
||||
foreach ($cells as $cell) {
|
||||
$cellWidths[] = $cell->getWidth();
|
||||
}
|
||||
|
||||
foreach ($this->rows as $row) {
|
||||
$cells = $row->getCells();
|
||||
if (count($cells) <= count($cellWidths)) {
|
||||
continue;
|
||||
}
|
||||
$cellWidths = array();
|
||||
foreach ($cells as $cell) {
|
||||
$cellWidths[] = $cell->getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ class Content extends AbstractPart
|
|||
$style->setStyleName('fr' . $element->getMediaIndex());
|
||||
$this->autoStyles['Image'][] = $style;
|
||||
} elseif ($element instanceof Table) {
|
||||
/** @var \PhpOffice\PhpWord\Style\Table $style */
|
||||
$style = $element->getStyle();
|
||||
if ($style === null) {
|
||||
$style = new TableStyle();
|
||||
|
|
|
|||
|
|
@ -47,8 +47,9 @@ class Table extends AbstractStyle
|
|||
$xmlWriter->endElement(); // style:style
|
||||
|
||||
$cellWidths = $style->getColumnWidths();
|
||||
$countCellWidths = count($cellWidths);
|
||||
|
||||
for ($i = 0; $i < count($cellWidths); $i++) {
|
||||
for ($i = 0; $i < $countCellWidths; $i++) {
|
||||
$width = $cellWidths[$i];
|
||||
$xmlWriter->startElement('style:style');
|
||||
$xmlWriter->writeAttribute('style:name', $style->getStyleName() . '.' . $i);
|
||||
|
|
|
|||
Loading…
Reference in New Issue