chore: Аннотации к типам

This commit is contained in:
origami11@yandex.ru 2025-10-28 12:26:00 +03:00
parent 89913de4fe
commit 386a927254
6 changed files with 63 additions and 27 deletions

View file

@ -5,7 +5,7 @@ namespace ctiso;
class Arr { class Arr {
/** /**
* @param array $data * @param array<mixed> $data
* @param string $key * @param string $key
* @param mixed $default * @param mixed $default
* @return mixed * @return mixed

View file

@ -8,9 +8,11 @@ use XMLWriter,
Exception; Exception;
class Document { class Document {
/** @var string */
static $ns = "urn:schemas-microsoft-com:office:spreadsheet"; static $ns = "urn:schemas-microsoft-com:office:spreadsheet";
/** @var list<Table|callable> */ /** @var list<Table|callable> */
private $table = []; private $table = [];
/** @var array<string, array> */
protected $styles = []; protected $styles = [];
/** /**

View file

@ -10,7 +10,9 @@ use XMLWriter,
class TableCell class TableCell
{ {
/** @var string|false */
public $style = false; public $style = false;
/** @var string */
public $value; public $value;
public $merge = false; public $merge = false;
@ -25,17 +27,19 @@ class TableCell
*/ */
class TableRow class TableRow
{ {
/** @var string|false */
public $style = false; public $style = false;
/** @var TableCell[] */ /** @var TableCell[] */
public $cells = []; public $cells = [];
/** @var int|false */
public $height = false; public $height = false;
function setCell($y, $value) function setCell($y, $value): void
{ {
$this->cells[$y] = new TableCell($value); $this->cells[$y] = new TableCell($value);
} }
function setCellStyle($y, $name) function setCellStyle($y, $name): void
{ {
$this->cells[$y]->style = $name; $this->cells[$y]->style = $name;
} }
@ -283,7 +287,7 @@ class Table
} }
if ($this->rows[$i]->height) { 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 */ /** @var TableRow $nrow */
$nrow = $this->rows[$i]; $nrow = $this->rows[$i];

View file

@ -21,9 +21,13 @@ class ViewState // extends Collection
$this->values[$name] = $value; $this->values[$name] = $value;
} }
function get($_rest) /**
* Возвращает значение
* @param string ...$args
* @return mixed
*/
function get(...$args)
{ {
$args = func_get_args();
$result = $this->values; $result = $this->values;
foreach ($args as $name) { foreach ($args as $name) {
if (!isset($result[$name])) { if (!isset($result[$name])) {
@ -34,16 +38,28 @@ class ViewState // extends Collection
return $result; return $result;
} }
/**
* Сохраняет состояние
* @return string
*/
function saveState(): string function saveState(): string
{ {
return base64_encode(serialize($this->values)); return base64_encode(serialize($this->values));
} }
function restoreState($value) /**
* Восстанавливает состояние
* @param string $value
*/
function restoreState($value): void
{ {
$this->values = unserialize(base64_decode($value)); $this->values = unserialize(base64_decode($value));
} }
/**
* Возвращает состояние
* @return array
*/
function export() function export()
{ {
return $this->values; return $this->values;

View file

@ -62,8 +62,12 @@ class partial {
$this->params = $params; $this->params = $params;
} }
function apply() { /**
$params = func_get_args(); * Применение функции
* @param mixed ...$params
* @return mixed
*/
function apply(...$params) {
$result = []; $result = [];
$count = count($this->params); $count = count($this->params);
for($i = 0, $j = 0; $i < $count; $i++) { for($i = 0, $j = 0; $i < $count; $i++) {
@ -87,8 +91,12 @@ class compose {
$this->fns = array_reverse($list); $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); $result = call_user_func_array($this->fns[0], $params);
$count = count($this->fns); $count = count($this->fns);
for ($i = 1; $i < $count; $i++) { for ($i = 1; $i < $count; $i++) {
@ -100,39 +108,44 @@ class compose {
class Functions { 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']; return [$closure, 'apply'];
} }
/** /**
* Композиция функций * Композиция функций
* @param array $_rest * @param mixed ...$args
* @return mixed * @return mixed
*/ */
static function compose($_rest) { static function compose(...$args) {
$closure = new compose(func_get_args()); $closure = new compose($args);
return [$closure, 'apply']; return [$closure, 'apply'];
} }
/** /**
* Карирование справа * Карирование справа
* * @param mixed ...$args
* @return mixed * @return mixed
*/ */
static function rcurry($_rest) { static function rcurry(...$args) {
$closure = new right(func_get_args ()); $closure = new right($args);
return [$closure, 'apply']; return [$closure, 'apply'];
} }
/** /**
* Карирование слева * Карирование слева
* * @param mixed ...$args
* @return mixed * @return mixed
*/ */
static function lcurry($_rest) { static function lcurry(...$args) {
$closure = new left(func_get_args ()); $closure = new left($args);
return [$closure, 'apply']; return [$closure, 'apply'];
} }

View file

@ -4,13 +4,14 @@
* Неверный запрос * Неверный запрос
*/ */
namespace ctiso; namespace ctiso;
use Exception,
ArrayAccess, use Exception;
ctiso\Collection, use ArrayAccess;
ctiso\Session; use ctiso\Collection;
use ctiso\Session;
/** /**
* @template T * @template T=mixed
*/ */
class HttpRequest extends Collection class HttpRequest extends Collection
{ {