chore: Аннотация типов
This commit is contained in:
parent
f964472e62
commit
cf0bc435ce
19 changed files with 96 additions and 37 deletions
|
|
@ -48,6 +48,7 @@ class Collection implements \ArrayAccess
|
|||
* Read stored "request data" by referencing a key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
|
|
|
|||
|
|
@ -31,27 +31,26 @@ class Action implements ActionInterface
|
|||
|
||||
public string $viewPathPrefix = ''; // Путь к шаблонам контроллера
|
||||
|
||||
/**
|
||||
* Соединение с базой данных
|
||||
*/
|
||||
/** Соединение с базой данных */
|
||||
public Database $db;
|
||||
|
||||
// Фильтры
|
||||
/** @var ?\ctiso\Filter\ActionAccess */
|
||||
public $access = null; // Обьект хранит параметры доступа
|
||||
/** @var ?\ctiso\Filter\ActionLogger */
|
||||
public $logger = null; // Обьект для ведения лога
|
||||
|
||||
/** @var ?\ctiso\Filter\ActionAccess Обьект хранит параметры доступа */
|
||||
public $access = null;
|
||||
/** @var ?\ctiso\Filter\ActionLogger Обьект для ведения лога */
|
||||
public $logger = null;
|
||||
/** @var Factory Обьект для создания моделей */
|
||||
private $factory = null; // Ссылка на обьект создания модели
|
||||
private array $helpers = []; // Помошники для действий
|
||||
public $part = null; // Параметры для ссылки
|
||||
/** @var ?Url Параметры для ссылки */
|
||||
public $part = null;
|
||||
|
||||
/** @var \ctiso\Registry */
|
||||
public $config; // Ссылка на настройки
|
||||
/** @var \ctiso\Role\User */
|
||||
public $user; // Обьект пользователя
|
||||
/** @var \ctiso\Registry Ссылка на настройки */
|
||||
public $config;
|
||||
/** @var \ctiso\Role\User Обьект пользователя */
|
||||
public $user;
|
||||
|
||||
// Для Widgets
|
||||
/** @var \ctiso\View\View Для Widgets */
|
||||
public $view = null;
|
||||
|
||||
public array $childNodes = [];
|
||||
|
|
@ -307,6 +306,8 @@ class Action implements ActionInterface
|
|||
|
||||
/**
|
||||
* Вызов помошников контроллера
|
||||
* @param HttpRequest $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function callHelpers(HttpRequest $request)
|
||||
{
|
||||
|
|
@ -430,7 +431,7 @@ class Action implements ActionInterface
|
|||
|
||||
/**
|
||||
* Проверка идентификатора страницы
|
||||
* @param $page int Идентификатор страницы
|
||||
* @param int $page Идентификатор страницы
|
||||
* @return bool
|
||||
*/
|
||||
function checkPageId(HttpRequest $request, $page)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ interface ActionInterface {
|
|||
/**
|
||||
* @param string $name
|
||||
* @param class-string<\ctiso\View\View> $class
|
||||
* @return \ctiso\View\View
|
||||
*/
|
||||
function getView($name, $class);
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class Component
|
|||
*/
|
||||
public $site;
|
||||
|
||||
function before() {
|
||||
function before(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -308,9 +308,9 @@ class Component
|
|||
/**
|
||||
* Генерация интерфейса для выбора галлереи фотографии
|
||||
* @param Composite $view
|
||||
* @param \ctiso\Form\OptionsFactory $options
|
||||
* @param ?\ctiso\Form\OptionsFactory $options
|
||||
*/
|
||||
public function setParameters(Composite $view, $options = null)
|
||||
public function setParameters(Composite $view, $options = null): void
|
||||
{
|
||||
$form = new Form();
|
||||
|
||||
|
|
@ -322,6 +322,10 @@ class Component
|
|||
$view->component_title = $settings['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ctiso\Form\OptionsFactory $options
|
||||
* @return array
|
||||
*/
|
||||
public function getFields($options = null) {
|
||||
$form = new Form();
|
||||
$form->addFieldList($this->getInfo()['parameter'], $options);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ class Front extends Action
|
|||
/** @var array<string, Action> */
|
||||
protected $modules = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $default
|
||||
*/
|
||||
public function __construct(Database $db, Registry $config, User $user, $default) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Installer
|
|||
/** @var callable */
|
||||
protected $installPath;
|
||||
/** @var Settings */
|
||||
public $_registry;
|
||||
public $_registry;
|
||||
|
||||
public function __construct(Settings $_registry)
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ class Installer
|
|||
* @param Manager $db_manager
|
||||
* @param callable $installPath
|
||||
*/
|
||||
public function setUp($db_manager, $installPath)
|
||||
public function setUp($db_manager, $installPath): void
|
||||
{
|
||||
$this->db_manager = $db_manager;
|
||||
$this->installPath = $installPath;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
namespace {
|
||||
if (!function_exists('sqliteLower')) {
|
||||
/**
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function sqliteLower($str)
|
||||
{
|
||||
return mb_strtolower($str, 'UTF-8');
|
||||
|
|
@ -183,7 +187,7 @@ namespace ctiso {
|
|||
* @param array $values - значения
|
||||
* @param bool $return_id - возвращать id
|
||||
* @param string $index - индекс
|
||||
* @return int|mixed
|
||||
* @return int|null
|
||||
*/
|
||||
function insertQuery($table, array $values, $return_id = false, $index = null)
|
||||
{
|
||||
|
|
@ -208,6 +212,7 @@ namespace ctiso {
|
|||
return $result['lastid'];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function first() {
|
||||
if ($this->cursorPos !== 0) { $this->seek(0); }
|
||||
return $this->next();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use PDO;
|
|||
|
||||
class StatementIterator implements \Iterator
|
||||
{
|
||||
|
||||
/** @var PDOStatement */
|
||||
private $result;
|
||||
/** @var int */
|
||||
|
|
@ -44,6 +43,9 @@ class StatementIterator implements \Iterator
|
|||
$this->pos++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
*/
|
||||
function seek($index): void {
|
||||
$this->pos = $index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ class Table
|
|||
|
||||
/**
|
||||
* Записать значение в клетку с заданными координатами
|
||||
* @param int $x Номер ряда
|
||||
* @param int $y Номер столбца
|
||||
* @param string $value Значение клетки
|
||||
*/
|
||||
function setCell(int $x, int $y, $value): void
|
||||
{
|
||||
|
|
@ -137,16 +140,15 @@ class Table
|
|||
|
||||
/**
|
||||
* Обьединяет клетки в строке
|
||||
* @param $row Номер ряда
|
||||
* @param $cell Номер столбца
|
||||
* @param $merge Количество клеток для обьединения
|
||||
* @param int $x Номер ряда
|
||||
* @param int $cell Номер столбца
|
||||
* @param int $merge Количество клеток для обьединения
|
||||
*/
|
||||
function setCellMerge(int $x, int $cell, $merge): void
|
||||
{
|
||||
assert($x > 0);
|
||||
assert($cell > 0);
|
||||
|
||||
/** @var TableRow $row */
|
||||
$row = $this->rows[$x];
|
||||
$row->cells[$cell]->merge = $merge;
|
||||
}
|
||||
|
|
@ -157,7 +159,7 @@ class Table
|
|||
* @param int $y Номер столбца
|
||||
* @param string $name Имя стиля
|
||||
*/
|
||||
function setCellStyle ($row, $y, $name)
|
||||
function setCellStyle ($row, $y, $name): void
|
||||
{
|
||||
if (isset($this->rows[$row])) {
|
||||
$this->rows[$row]->setCellStyle($y, $name);
|
||||
|
|
@ -166,6 +168,7 @@ class Table
|
|||
|
||||
/**
|
||||
* Добавляет строку к таблице
|
||||
* @return int Номер добавленной строки
|
||||
*/
|
||||
function addRow(int $index = 1, array $data = [""])
|
||||
{
|
||||
|
|
@ -243,7 +246,7 @@ class Table
|
|||
* @param mixed $value Значение клетки
|
||||
* @param bool $setIndex Устанавливать индекс клетки в атрибут ss:Index
|
||||
*/
|
||||
function createCell (TableCell $ncell, XMLWriter $doc, $j, mixed $value, $setIndex) {
|
||||
function createCell (TableCell $ncell, XMLWriter $doc, $j, mixed $value, $setIndex): void {
|
||||
$doc->startElement("Cell");
|
||||
|
||||
if ($ncell->style) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
namespace ctiso\Form;
|
||||
|
||||
use ctiso\Form\OptionsFactory;
|
||||
|
||||
class Field
|
||||
{
|
||||
/** @var bool */
|
||||
|
|
@ -25,18 +27,26 @@ class Field
|
|||
public $error = false;
|
||||
/** @var bool */
|
||||
public $require = false;
|
||||
/** @var ?string */
|
||||
public $hint = null;
|
||||
/** @var ?int */
|
||||
public $maxlength = null;
|
||||
/** @var ?string */
|
||||
public $fieldset = null;
|
||||
// Блоки (Убрать в отдельный класс!!!)
|
||||
/** @var array */
|
||||
public $_title = [];
|
||||
/** @var string */
|
||||
public $description = "";
|
||||
/** @var array */
|
||||
public $alias = [];
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
|
||||
/**
|
||||
* @param array $input
|
||||
* @param OptionsFactory|null $factory
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
public function __construct ($input = [], $factory = null)
|
||||
{
|
||||
$this->default = null;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use ctiso\HttpRequest;
|
|||
* Форма для ввода
|
||||
*/
|
||||
class Form {
|
||||
/** @var array */
|
||||
/** @var array<Field> */
|
||||
public $field = []; //Поля формы
|
||||
/** @var array */
|
||||
public $fieldsets = []; //Группы полей (fieldset). Некоторые поля могут не принадлежать никаким группам
|
||||
|
|
@ -137,6 +137,7 @@ class Form {
|
|||
/**
|
||||
* Добавляет список полей для формы
|
||||
* @param array $list
|
||||
* @param OptionsFactory|null $factory
|
||||
*/
|
||||
public function addFieldList(array $list, $factory = null): void
|
||||
{
|
||||
|
|
@ -191,6 +192,10 @@ class Form {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function set($name, $value): void
|
||||
{
|
||||
$this->field[$name]->setValue($value);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,12 @@ class partial {
|
|||
* Композиция функций
|
||||
*/
|
||||
class compose {
|
||||
/** @var array<callable> */
|
||||
protected $fns;
|
||||
|
||||
/**
|
||||
* @param array<callable> $list
|
||||
*/
|
||||
function __construct($list) {
|
||||
$this->fns = array_reverse($list);
|
||||
}
|
||||
|
|
@ -275,6 +280,7 @@ class Functions {
|
|||
/**
|
||||
* @param string $key
|
||||
* @param list<object>|\ArrayIterator $array
|
||||
* @return array<mixed>
|
||||
*/
|
||||
static function key_values_object($key, $array) {
|
||||
$result = [];
|
||||
|
|
@ -415,6 +421,7 @@ class Functions {
|
|||
* Поиск элемента в массиве
|
||||
* @param callable $cb сравнение с элементом массива
|
||||
* @param array $hs массив в котором ищется значение
|
||||
* @param bool $strict
|
||||
*
|
||||
* @return int|string|null ключ найденого элемента в массиве
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ class Numbers
|
|||
return $i;
|
||||
}
|
||||
|
||||
static function prefix(callable $prefix, array $array, $key = false)
|
||||
/**
|
||||
* @param array $array
|
||||
*/
|
||||
static function prefix(callable $prefix, array $array)
|
||||
{
|
||||
$result = [];
|
||||
$count = count($array);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ class Primitive {
|
|||
return ((int) $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function from_int($value): string
|
||||
{
|
||||
return ((string) $value);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ interface UserInterface {
|
|||
function getUserByQuery(Statement $stmt);
|
||||
function getUserByLogin(string $login);
|
||||
function getUserById(int $id);
|
||||
function getName();
|
||||
function getName(): string;
|
||||
function setSID(string $random, $result);
|
||||
}
|
||||
|
|
@ -212,6 +212,7 @@ class Settings
|
|||
/**
|
||||
* Получение значения ключа
|
||||
* @param string $key Ключ
|
||||
* @param mixed $default Значение по умолчанию
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class FakeZipArchive {
|
|||
/** @var string */
|
||||
public $base;
|
||||
|
||||
function open(string $path) {
|
||||
function open(string $path): void {
|
||||
$this->base = $path;
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +95,9 @@ class Setup
|
|||
$this->context[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
function replaceFn(array $matches) {
|
||||
if (isset($this->context[$matches[2]])) {
|
||||
$v = $this->context[$matches[2]];
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ class View extends \stdClass
|
|||
/** @var string[] */
|
||||
public array $suggestions = []; //подсказки
|
||||
|
||||
/** @var string[] $alias */
|
||||
/** @var array<string, string|array<string, string>> */
|
||||
public array $alias = [];
|
||||
public $codeGenerator = null;
|
||||
// public $codeGenerator = null;
|
||||
/** @var View|null */
|
||||
public $parent_view = null;
|
||||
|
||||
|
|
@ -52,6 +52,9 @@ class View extends \stdClass
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
*/
|
||||
public function assignValues($values): void
|
||||
{
|
||||
$this->_values = $values;
|
||||
|
|
@ -146,6 +149,9 @@ class View extends \stdClass
|
|||
return $title !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string|array<string, string>> $alias
|
||||
*/
|
||||
function setAlias($alias): void
|
||||
{
|
||||
$this->alias = $alias;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue