From 386a9272545ba67050bb11e5e0045bf89ed599b1 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Tue, 28 Oct 2025 12:26:00 +0300 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=90=D0=BD=D0=BD=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BA=20=D1=82=D0=B8=D0=BF=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Arr.php | 2 +- src/Excel/Document.php | 2 ++ src/Excel/Table.php | 10 +++++++--- src/Form/ViewState.php | 22 ++++++++++++++++++--- src/Functions.php | 43 +++++++++++++++++++++++++++--------------- src/HttpRequest.php | 11 ++++++----- 6 files changed, 63 insertions(+), 27 deletions(-) diff --git a/src/Arr.php b/src/Arr.php index 5d63ef8..99ac0ba 100644 --- a/src/Arr.php +++ b/src/Arr.php @@ -5,7 +5,7 @@ namespace ctiso; class Arr { /** - * @param array $data + * @param array $data * @param string $key * @param mixed $default * @return mixed diff --git a/src/Excel/Document.php b/src/Excel/Document.php index 3086f56..4a9480c 100644 --- a/src/Excel/Document.php +++ b/src/Excel/Document.php @@ -8,9 +8,11 @@ use XMLWriter, Exception; class Document { + /** @var string */ static $ns = "urn:schemas-microsoft-com:office:spreadsheet"; /** @var list */ private $table = []; + /** @var array */ protected $styles = []; /** diff --git a/src/Excel/Table.php b/src/Excel/Table.php index 95ab5db..41ff2b2 100644 --- a/src/Excel/Table.php +++ b/src/Excel/Table.php @@ -10,7 +10,9 @@ use XMLWriter, class TableCell { + /** @var string|false */ public $style = false; + /** @var string */ public $value; public $merge = false; @@ -25,17 +27,19 @@ class TableCell */ class TableRow { + /** @var string|false */ public $style = false; /** @var TableCell[] */ public $cells = []; + /** @var int|false */ public $height = false; - function setCell($y, $value) + function setCell($y, $value): void { $this->cells[$y] = new TableCell($value); } - function setCellStyle($y, $name) + function setCellStyle($y, $name): void { $this->cells[$y]->style = $name; } @@ -283,7 +287,7 @@ class Table } if ($this->rows[$i]->height) { - $doc->writeAttribute('ss:Height', $this->rows[$i]->height); + $doc->writeAttribute('ss:Height', (string)$this->rows[$i]->height); } /** @var TableRow $nrow */ $nrow = $this->rows[$i]; diff --git a/src/Form/ViewState.php b/src/Form/ViewState.php index f22545d..b315e6d 100644 --- a/src/Form/ViewState.php +++ b/src/Form/ViewState.php @@ -21,9 +21,13 @@ class ViewState // extends Collection $this->values[$name] = $value; } - function get($_rest) + /** + * Возвращает значение + * @param string ...$args + * @return mixed + */ + function get(...$args) { - $args = func_get_args(); $result = $this->values; foreach ($args as $name) { if (!isset($result[$name])) { @@ -34,16 +38,28 @@ class ViewState // extends Collection return $result; } + /** + * Сохраняет состояние + * @return string + */ function saveState(): string { return base64_encode(serialize($this->values)); } - function restoreState($value) + /** + * Восстанавливает состояние + * @param string $value + */ + function restoreState($value): void { $this->values = unserialize(base64_decode($value)); } + /** + * Возвращает состояние + * @return array + */ function export() { return $this->values; diff --git a/src/Functions.php b/src/Functions.php index 83b370b..700f893 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -62,8 +62,12 @@ class partial { $this->params = $params; } - function apply() { - $params = func_get_args(); + /** + * Применение функции + * @param mixed ...$params + * @return mixed + */ + function apply(...$params) { $result = []; $count = count($this->params); for($i = 0, $j = 0; $i < $count; $i++) { @@ -87,8 +91,12 @@ class compose { $this->fns = array_reverse($list); } - function apply () { - $params = func_get_args (); + /** + * Применение функций + * @param mixed ...$params + * @return mixed + */ + function apply (...$params) { $result = call_user_func_array($this->fns[0], $params); $count = count($this->fns); for ($i = 1; $i < $count; $i++) { @@ -100,39 +108,44 @@ class compose { class Functions { - static function partial($_rest) { - $closure = new partial(func_get_args()); + /** + * Частичное применение функции + * @param mixed ...$args + * @return mixed + */ + static function partial(...$args) { + $closure = new partial($args); return [$closure, 'apply']; } /** * Композиция функций - * @param array $_rest + * @param mixed ...$args * @return mixed */ - static function compose($_rest) { - $closure = new compose(func_get_args()); + static function compose(...$args) { + $closure = new compose($args); return [$closure, 'apply']; } /** * Карирование справа - * + * @param mixed ...$args * @return mixed */ - static function rcurry($_rest) { - $closure = new right(func_get_args ()); + static function rcurry(...$args) { + $closure = new right($args); return [$closure, 'apply']; } /** * Карирование слева - * + * @param mixed ...$args * @return mixed */ - static function lcurry($_rest) { - $closure = new left(func_get_args ()); + static function lcurry(...$args) { + $closure = new left($args); return [$closure, 'apply']; } diff --git a/src/HttpRequest.php b/src/HttpRequest.php index 21ea3d2..3df3b05 100644 --- a/src/HttpRequest.php +++ b/src/HttpRequest.php @@ -4,13 +4,14 @@ * Неверный запрос */ namespace ctiso; -use Exception, - ArrayAccess, - ctiso\Collection, - ctiso\Session; + +use Exception; +use ArrayAccess; +use ctiso\Collection; +use ctiso\Session; /** - * @template T + * @template T=mixed */ class HttpRequest extends Collection {