From 704e4e0bd50e87e3c4a25a8d545c017bc652942a Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Tue, 28 Oct 2025 20:09:21 +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/Controller/Component.php | 12 ++++++++++++ src/Database.php | 6 +++--- src/Database/JsonInstall.php | 2 ++ src/Database/Manager.php | 34 ++++++++++++++++++++++++++++++++-- src/Excel/Number.php | 3 +++ src/Excel/Table.php | 10 ++++++++++ src/Filter/ActionAccess.php | 2 ++ src/Form/Form.php | 5 +++-- src/Functions.php | 8 +++++--- src/View/Pages.php | 2 +- 10 files changed, 73 insertions(+), 11 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 5ebffc2..a639ac4 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -104,6 +104,14 @@ class Component $callback, $text); } + /** + * Выполняет запрос компонента и возвращает результат + * Результат может быть строкой или View для обычных компонентов, или массивом для использования в сервисах + * + * @param HttpRequest $request + * @param bool $has_id + * @return mixed + */ function execute(HttpRequest $request, $has_id = true) { $crequest = new ComponentRequest($this->component_id, $request); @@ -125,6 +133,7 @@ class Component /** * Получить имя шаблона * @param Registry $_registry + * @return string */ public function getTemplateName($_registry) { return (isset($_COOKIE['with_template']) && preg_match('/^[\w\d-]{3,20}$/', $_COOKIE['with_template'])) @@ -486,7 +495,10 @@ class Component /** * @param ComponentRequest $request + * @return mixed */ function actionIndex($request) { + return null; } + } diff --git a/src/Database.php b/src/Database.php index 35a56e9..194d3b4 100644 --- a/src/Database.php +++ b/src/Database.php @@ -100,7 +100,7 @@ namespace ctiso { /** * Выполняет запрос к базе данных * @param string $query - запрос - * @param array $values - значения + * @param ?array $values - значения */ public function executeQuery($query, $values = null): PDOStatement|bool { @@ -124,7 +124,7 @@ namespace ctiso { /** * Извлекает из базы все элементы по запросу (Для совместимости со старым представлением баз данных CIS) * @param string $query - запрос - * @param array $values - значения + * @param ?array $values - значения * @return list> */ public function fetchAllArray($query, $values = null) @@ -138,7 +138,7 @@ namespace ctiso { /** * Извлекает из базы первый элемент по запросу * @param string $query - запрос - * @param array $values - значения + * @param ?array $values - значения * @return array|false */ public function fetchOneArray($query, $values = null) diff --git a/src/Database/JsonInstall.php b/src/Database/JsonInstall.php index 5dcfbd1..f7842fb 100644 --- a/src/Database/JsonInstall.php +++ b/src/Database/JsonInstall.php @@ -18,6 +18,7 @@ class JsonInstall { * Установить базу данных * @param string $dbinit_path * @param ?string $dbfill_path + * @return int */ function install($dbinit_path, $dbfill_path = null) { $dbinit_file = file_get_contents($dbinit_path); @@ -37,6 +38,7 @@ class JsonInstall { $this->fillDataBase($dbfill_path); } $this->makeConstraints($initActions); + return 1; } /** diff --git a/src/Database/Manager.php b/src/Database/Manager.php index 91c6f64..0ea3547 100644 --- a/src/Database/Manager.php +++ b/src/Database/Manager.php @@ -7,6 +7,36 @@ use ctiso\Tools\SQLStatementExtractor; use ctiso\Path; use Exception; +/** + * @phpstan-type Action array{ + * type:string, + * table_name:string, + * table:string, + * fields:array, + * field: ColumnProps, + * constraints:?array, + * references:?array, + * source:string, + * pgsql?:string, + * old_name?:string, + * new_name?:string, + * column?:string, + * column_name?:string, + * refTable?:string, + * refColumn?:string, + * values:array, + * view:string, + * select:string + * } + * + * @phpstan-type ColumnProps array{ + * name:string, + * type:string, + * not_null:bool, + * default:?string, + * references:?array{refTable:string,refColumn:string} + * } + */ class Manager { /** @var Database */ @@ -19,7 +49,7 @@ class Manager /** * Выполняет действие - * @param array $action + * @param Action $action * @param string $db_file * @throws Exception */ @@ -180,7 +210,7 @@ class Manager /** * Возвращает определение столбца * @param string $name - * @param array $data + * @param ColumnProps $data * @param bool $pg * @return string */ diff --git a/src/Excel/Number.php b/src/Excel/Number.php index 080fb74..3df78bb 100644 --- a/src/Excel/Number.php +++ b/src/Excel/Number.php @@ -7,6 +7,9 @@ class Number /** @var int */ public $value; + /** + * @param int|float $value + */ function __construct($value) { $this->value = (int)($value); diff --git a/src/Excel/Table.php b/src/Excel/Table.php index 41ff2b2..3009c64 100644 --- a/src/Excel/Table.php +++ b/src/Excel/Table.php @@ -34,11 +34,21 @@ class TableRow /** @var int|false */ public $height = false; + /** + * Устанавливает значение для клетки + * @param int $y Номер столбца + * @param string $value Значение клетки + */ function setCell($y, $value): void { $this->cells[$y] = new TableCell($value); } + /** + * Устанавливает стиль для клетки + * @param int $y Номер столбца + * @param string $name Имя стиля + */ function setCellStyle($y, $name): void { $this->cells[$y]->style = $name; diff --git a/src/Filter/ActionAccess.php b/src/Filter/ActionAccess.php index 89f7326..db82044 100644 --- a/src/Filter/ActionAccess.php +++ b/src/Filter/ActionAccess.php @@ -10,7 +10,9 @@ use ctiso\Filter\UserAccess, class ActionAccess { + /** @var array */ public $access = []; + /** @var FilterInterface */ public $processor; /** @var User */ public $user; diff --git a/src/Form/Form.php b/src/Form/Form.php index 153f831..d072288 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -31,7 +31,7 @@ class Form { protected $replace; protected $before; - /** @var array */ + /** @var array */ public $_title = []; /** @var array */ public $alias = []; @@ -47,7 +47,6 @@ class Form { 'input' => Input::class, // input с проверкой на заполненность 'inputreq' => Input::class, - 'date' => Date::class, 'datereq' => Date::class, 'datetime' => DateTime::class, @@ -93,6 +92,8 @@ class Form { /** * Добавляет одно поле ввода на форму + * @param array{ type: string, name: string, hint?: string } $init + * @param OptionsFactory|null $factory */ public function addField(array $init, $factory = null): Field { diff --git a/src/Functions.php b/src/Functions.php index cb38f96..6921de5 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -277,7 +277,7 @@ class Functions { /** * @param string $key * @param string $value - * @param array|\ArrayIterator $array + * @param list>|\ArrayIterator $array */ static function assoc_key_values($key, $value, $array) { $result = []; @@ -289,7 +289,7 @@ class Functions { /** * @param string $key - * @param array|\ArrayIterator $array + * @param list>|\ArrayIterator $array */ static function assoc_key($key, $array) { $result = []; @@ -334,7 +334,7 @@ class Functions { /** * Логическа операция && ко всем элементам массива - * @param array $array Массив + * @param array $array Массив * @param callable $callback Функция * @return bool */ @@ -349,6 +349,8 @@ class Functions { /** * Логическа операция || ко всем элементам массива + * @param array $array Массив + * @param callable $callback Функция * @return mixed */ static function some(array $array, callable $callback) { diff --git a/src/View/Pages.php b/src/View/Pages.php index a5f2170..a64873d 100644 --- a/src/View/Pages.php +++ b/src/View/Pages.php @@ -14,7 +14,7 @@ class Pages * @param int $onpage количество страниц на странице * @param int $count количество всех страниц * @param string $prefix префикс - * @return array{'all': bool, 'list': array, 'first': string, 'last': string, 'next': string, 'prev': string} + * @return array{'all': bool, 'list': array, 'first': string, 'last': string, 'next': string|false, 'prev': string|false} */ static function getPages($page, $onpage, $count, $prefix = '?') {