Address scrutinizer issues

This commit is contained in:
troosan 2018-06-03 00:22:08 +02:00
parent d9ddc162a3
commit da43a880e3
3 changed files with 20 additions and 20 deletions

View File

@ -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();
}
}

View File

@ -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();

View File

@ -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);