chore: Проверки к типам
This commit is contained in:
parent
8786e84568
commit
18cc1cad01
8 changed files with 34 additions and 28 deletions
|
|
@ -118,7 +118,7 @@ class Table
|
|||
/**
|
||||
* Устанавливает высоту ряда
|
||||
* @param int $row Номер ряда
|
||||
* @param numeric $value Высота ряда
|
||||
* @param int $value Высота ряда
|
||||
*/
|
||||
function setRowHeight (int $row, $value): void
|
||||
{
|
||||
|
|
@ -187,8 +187,9 @@ class Table
|
|||
*/
|
||||
function getRows()
|
||||
{
|
||||
// Высчитываем максимальный индекс, массив может быть разрежен поэтому используем array_keys
|
||||
$keys = array_keys($this->rows);
|
||||
return max($keys);
|
||||
return $keys === [] ? 0 : max($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,7 +200,7 @@ class Table
|
|||
function getRowCells(TableRow $row)
|
||||
{
|
||||
$keys = array_keys($row->cells);
|
||||
return max($keys);
|
||||
return $keys === [] ? 0 :max($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,7 +226,8 @@ class Table
|
|||
* @return int
|
||||
*/
|
||||
function getColumns() {
|
||||
return max(array_map([$this, 'getRowCells'], $this->rows));
|
||||
$columns = array_map($this->getRowCells(...), $this->rows);
|
||||
return $columns === [] ? 0 : max($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue