Skip to content

Commit da43a88

Browse files
committed
Address scrutinizer issues
1 parent d9ddc16 commit da43a88

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/PhpWord/Element/Table.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ public function setWidth($width)
135135
public function countColumns()
136136
{
137137
$columnCount = 0;
138-
if (is_array($this->rows)) {
139-
$rowCount = count($this->rows);
140-
for ($i = 0; $i < $rowCount; $i++) {
141-
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
142-
$row = $this->rows[$i];
143-
$cellCount = count($row->getCells());
144-
if ($columnCount < $cellCount) {
145-
$columnCount = $cellCount;
146-
}
138+
139+
$rowCount = count($this->rows);
140+
for ($i = 0; $i < $rowCount; $i++) {
141+
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
142+
$row = $this->rows[$i];
143+
$cellCount = count($row->getCells());
144+
if ($columnCount < $cellCount) {
145+
$columnCount = $cellCount;
147146
}
148147
}
149148

@@ -158,16 +157,15 @@ public function countColumns()
158157
public function findFirstDefinedCellWidths()
159158
{
160159
$cellWidths = array();
161-
if (is_array($this->rows)) {
162-
foreach ($this->rows as $row) {
163-
$cells = $row->getCells();
164-
if (count($cells) <= count($cellWidths)) {
165-
continue;
166-
}
167-
$cellWidths = array();
168-
foreach ($cells as $cell) {
169-
$cellWidths[] = $cell->getWidth();
170-
}
160+
161+
foreach ($this->rows as $row) {
162+
$cells = $row->getCells();
163+
if (count($cells) <= count($cellWidths)) {
164+
continue;
165+
}
166+
$cellWidths = array();
167+
foreach ($cells as $cell) {
168+
$cellWidths[] = $cell->getWidth();
171169
}
172170
}
173171

src/PhpWord/Writer/ODText/Part/Content.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyl
239239
$style->setStyleName('fr' . $element->getMediaIndex());
240240
$this->autoStyles['Image'][] = $style;
241241
} elseif ($element instanceof Table) {
242+
/** @var \PhpOffice\PhpWord\Style\Table $style */
242243
$style = $element->getStyle();
243244
if ($style === null) {
244245
$style = new TableStyle();

src/PhpWord/Writer/ODText/Style/Table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function write()
4747
$xmlWriter->endElement(); // style:style
4848

4949
$cellWidths = $style->getColumnWidths();
50+
$countCellWidths = count($cellWidths);
5051

51-
for ($i = 0; $i < count($cellWidths); $i++) {
52+
for ($i = 0; $i < $countCellWidths; $i++) {
5253
$width = $cellWidths[$i];
5354
$xmlWriter->startElement('style:style');
5455
$xmlWriter->writeAttribute('style:name', $style->getStyleName() . '.' . $i);

0 commit comments

Comments
 (0)