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 {
/**
* @param array $data
* @param array<mixed> $data
* @param string $key
* @param mixed $default
* @return mixed

View file

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

View file

@ -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];

View file

@ -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;

View file

@ -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'];
}

View file

@ -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
{