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() 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 */
$row = $this->rows[$i]; $row = $this->rows[$i];
$cellCount = count($row->getCells()); $cellCount = count($row->getCells());
if ($columnCount < $cellCount) { if ($columnCount < $cellCount) {
$columnCount = $cellCount; $columnCount = $cellCount;
}
} }
} }
@ -158,16 +157,15 @@ 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)) {
continue; continue;
} }
$cellWidths = array(); $cellWidths = array();
foreach ($cells as $cell) { foreach ($cells as $cell) {
$cellWidths[] = $cell->getWidth(); $cellWidths[] = $cell->getWidth();
}
} }
} }

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