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,7 +135,7 @@ class Table extends AbstractElement
public function countColumns() public function countColumns()
{ {
$columnCount = 0; $columnCount = 0;
if (is_array($this->rows)) {
$rowCount = count($this->rows); $rowCount = count($this->rows);
for ($i = 0; $i < $rowCount; $i++) { for ($i = 0; $i < $rowCount; $i++) {
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */ /** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
@ -145,7 +145,6 @@ class Table extends AbstractElement
$columnCount = $cellCount; $columnCount = $cellCount;
} }
} }
}
return $columnCount; return $columnCount;
} }
@ -158,7 +157,7 @@ class Table extends AbstractElement
public function findFirstDefinedCellWidths() public function findFirstDefinedCellWidths()
{ {
$cellWidths = array(); $cellWidths = array();
if (is_array($this->rows)) {
foreach ($this->rows as $row) { foreach ($this->rows as $row) {
$cells = $row->getCells(); $cells = $row->getCells();
if (count($cells) <= count($cellWidths)) { if (count($cells) <= count($cellWidths)) {
@ -169,7 +168,6 @@ class Table extends AbstractElement
$cellWidths[] = $cell->getWidth(); $cellWidths[] = $cell->getWidth();
} }
} }
}
return $cellWidths; return $cellWidths;
} }

View File

@ -239,6 +239,7 @@ class Content extends AbstractPart
$style->setStyleName('fr' . $element->getMediaIndex()); $style->setStyleName('fr' . $element->getMediaIndex());
$this->autoStyles['Image'][] = $style; $this->autoStyles['Image'][] = $style;
} elseif ($element instanceof Table) { } elseif ($element instanceof Table) {
/** @var \PhpOffice\PhpWord\Style\Table $style */
$style = $element->getStyle(); $style = $element->getStyle();
if ($style === null) { if ($style === null) {
$style = new TableStyle(); $style = new TableStyle();

View File

@ -47,8 +47,9 @@ class Table extends AbstractStyle
$xmlWriter->endElement(); // style:style $xmlWriter->endElement(); // style:style
$cellWidths = $style->getColumnWidths(); $cellWidths = $style->getColumnWidths();
$countCellWidths = count($cellWidths);
for ($i = 0; $i < count($cellWidths); $i++) { for ($i = 0; $i < $countCellWidths; $i++) {
$width = $cellWidths[$i]; $width = $cellWidths[$i];
$xmlWriter->startElement('style:style'); $xmlWriter->startElement('style:style');
$xmlWriter->writeAttribute('style:name', $style->getStyleName() . '.' . $i); $xmlWriter->writeAttribute('style:name', $style->getStyleName() . '.' . $i);