fix: Определения типов
This commit is contained in:
parent
9f6fd74b17
commit
dd74a97894
28 changed files with 334 additions and 249 deletions
|
|
@ -61,25 +61,26 @@ class Table
|
|||
/**
|
||||
* Записать значение в клетку с заданными координатами
|
||||
*/
|
||||
function setCell($x, $y, $value)
|
||||
function setCell(int $x, int $y, $value)
|
||||
{
|
||||
assert(is_numeric($x) && $x > 0);
|
||||
assert(is_numeric($y) && $y > 0);
|
||||
assert($x > 0);
|
||||
assert($y > 0);
|
||||
|
||||
if(! isset($this->rows[$x])) {
|
||||
$this->rows[$x] = new TableRow();
|
||||
}
|
||||
$row/*: TableRow*/ = $this->rows[$x];
|
||||
/** @var TableRow $row */
|
||||
$row = $this->rows[$x];
|
||||
$row->setCell($y, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Заполняет ряд начиная с указанного столбца значениями из массива
|
||||
*/
|
||||
function setRow($row, $index, array $data)
|
||||
function setRow(int $row, int $index, array $data)
|
||||
{
|
||||
assert(is_numeric($index) && $index > 0);
|
||||
assert(is_numeric($row) && $row > 0);
|
||||
assert($index > 0);
|
||||
assert($row > 0);
|
||||
|
||||
reset($data);
|
||||
for ($i = $index; $i < $index + count($data); $i++) {
|
||||
|
|
@ -90,20 +91,20 @@ class Table
|
|||
|
||||
/**
|
||||
* Устанавливает высоту ряда
|
||||
* @param $row integer Номер ряда
|
||||
* @parma $value real Высота ряда
|
||||
* @param int $row Номер ряда
|
||||
* @param number $value Высота ряда
|
||||
*/
|
||||
function setRowHeight ($row, $value)
|
||||
function setRowHeight (int $row, $value)
|
||||
{
|
||||
assert(is_numeric($row) && $row > 0);
|
||||
assert($row > 0);
|
||||
|
||||
$this->rows[$row]->height = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает стиль ряда
|
||||
* @param $row integer Номер ряда
|
||||
* @parma $name string Имя стиля
|
||||
* @param int $row Номер ряда
|
||||
* @param string $name Имя стиля
|
||||
*/
|
||||
function setRowStyle ($row, $name)
|
||||
{
|
||||
|
|
@ -118,12 +119,13 @@ class Table
|
|||
* @param $cell Номер столбца
|
||||
* @param $merge Количество клеток для обьединения
|
||||
*/
|
||||
function setCellMerge($x, $cell, $merge)
|
||||
function setCellMerge(int $x, int $cell, $merge)
|
||||
{
|
||||
assert(is_numeric($x) && $x > 0);
|
||||
assert(is_numeric($cell) && $cell > 0);
|
||||
assert($x > 0);
|
||||
assert($cell > 0);
|
||||
|
||||
$row/*: TableRow*/ = $this->rows[$x];
|
||||
/** @var TableRow $row */
|
||||
$row = $this->rows[$x];
|
||||
$row->cells[$cell]->merge = $merge;
|
||||
}
|
||||
|
||||
|
|
@ -135,14 +137,15 @@ class Table
|
|||
*/
|
||||
function setCellStyle ($row, $y, $name)
|
||||
{
|
||||
if (isset($this->rows[$row]))
|
||||
if (isset($this->rows[$row])) {
|
||||
$this->rows[$row]->setCellStyle($y, $name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляет строку к таблице
|
||||
*/
|
||||
function addRow($index = 1, array $data = [""])
|
||||
function addRow(int $index = 1, array $data = [""])
|
||||
{
|
||||
assert(is_numeric($index) && $index > 0);
|
||||
$offset = $this->getRows() + 1;
|
||||
|
|
@ -158,7 +161,7 @@ class Table
|
|||
*/
|
||||
function getRows()
|
||||
{
|
||||
$keys/*: array*/ = array_keys($this->rows);
|
||||
$keys = array_keys($this->rows);
|
||||
return max($keys);
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +172,7 @@ class Table
|
|||
*/
|
||||
function getRowCells(TableRow $row)
|
||||
{
|
||||
$keys/*: array*/ = array_keys($row->cells);
|
||||
$keys = array_keys($row->cells);
|
||||
return max($keys);
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +210,7 @@ class Table
|
|||
/**
|
||||
* Генерация клетки таблицы (Переработать)
|
||||
*/
|
||||
function createCell (TableCell $ncell, XMLWriter $doc, $j, $value/*: any*/, $setIndex) {
|
||||
function createCell (TableCell $ncell, XMLWriter $doc, $j, mixed $value, $setIndex) {
|
||||
$doc->startElement("Cell");
|
||||
|
||||
if ($ncell->style) {
|
||||
|
|
@ -266,8 +269,8 @@ class Table
|
|||
if ($this->rows[$i]->height) {
|
||||
$doc->writeAttribute('ss:Height', $this->rows[$i]->height);
|
||||
}
|
||||
|
||||
$nrow/*: TableRow*/ = $this->rows[$i];
|
||||
/** @var TableRow $nrow */
|
||||
$nrow = $this->rows[$i];
|
||||
// Флаг индикатор подстановки номера столбца
|
||||
$setIndex = false;
|
||||
for ($j = 1; $j <= $columns; $j++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue