chore: Добавлены аннотации к типам

This commit is contained in:
origami11@yandex.ru 2025-10-07 13:23:09 +03:00
parent 48269bd424
commit ad920f656c
14 changed files with 127 additions and 127 deletions

View file

@ -147,6 +147,7 @@ class Functions {
} }
/** /**
* @deprecated
* @param array $value * @param array $value
* @param string $name * @param string $name
* *
@ -156,11 +157,15 @@ class Functions {
return $value[$name]; return $value[$name];
} }
/**
* @deprecated
*/
static function identity($value) { static function identity($value) {
return $value; return $value;
} }
/** /**
* @deprecated
* @param array $a * @param array $a
* @param array $b * @param array $b
* @param $key * @param $key

View file

@ -4,7 +4,9 @@
* Класс для работы с почтой * Класс для работы с почтой
* http://en.wikipedia.org/wiki/MIME * http://en.wikipedia.org/wiki/MIME
*/ */
namespace ctiso; namespace ctiso;
use ctiso\Path, use ctiso\Path,
Exception; Exception;
@ -16,14 +18,15 @@ class Mail
public $content; public $content;
public $copy; public $copy;
private $encoding; private $encoding;
private $_notify = null; private $_notify = null;
protected $attachment = array (); protected $attachment = array();
protected $uniqid; protected $uniqid;
protected $type = "text/plain"; protected $type = "text/plain";
function __construct() { function __construct()
{
$this->setEncoding("UTF-8"); $this->setEncoding("UTF-8");
$this->uniqid = strtoupper(uniqid((string)time())); // Идентефикатор разделителя $this->uniqid = strtoupper(uniqid((string)time())); // Идентефикатор разделителя
} }
@ -31,32 +34,32 @@ class Mail
/** /**
* Установка отправителя * Установка отправителя
*/ */
function from($name) function from(string $name)
{ {
// filter_var($name, FILTER_VALIDATE_EMAIL);
$this->_from = $name; $this->_from = $name;
} }
/** /**
* Установка получателя * Установка получателя
*/ */
function to($name) // recipient function to(string $name) // recipient
{ {
$this->_to = $name; $this->_to = $name;
} }
function replyTo($name) // recipient function replyTo($name) // recipient
{ {}
}
/** /**
* Установка получателей копии * Установка получателей копии
*/ */
function copy($name) // recipient cc function copy(string $name) // recipient cc
{ {
$this->copy = $name; $this->copy = $name;
} }
function notify($notify) function notify(string $notify)
{ {
$this->_notify = $notify; $this->_notify = $notify;
} }
@ -64,23 +67,23 @@ class Mail
/** /**
* Тема письма * Тема письма
*/ */
function subject($subject) function subject(string $subject)
{ {
$this->_subject = $subject; $this->_subject = $subject;
} }
/** /**
* Текст письма * Текст письма
*/ */
function setContent($text) function setContent(string $text)
{ {
$this->content = $text; $this->content = $text;
} }
/** /**
* Кодировка текста в письме * Кодировка текста в письме
*/ */
function setEncoding($encoding) function setEncoding(string $encoding)
{ {
$this->encoding = $encoding; $this->encoding = $encoding;
} }
@ -88,15 +91,13 @@ class Mail
/** /**
* Добавление вложения из файла * Добавление вложения из файла
*/ */
function addAttachment($filename, $name = false) function addAttachment(string $filename, $name = false)
{ {
assert(is_string($filename)); if (file_exists($filename)) { // assert ??
if(file_exists($filename)) { // assert ??
$file = fopen($filename, "rb"); $file = fopen($filename, "rb");
if (is_resource($file)) { if (is_resource($file)) {
$data = fread($file, filesize($filename)); $data = fread($file, filesize($filename));
$this->attachment [] = ($name) ? [$data, $name] : [$data, basename($filename)]; $this->attachment[] = ($name) ? [$data, $name] : [$data, basename($filename)];
} }
} }
} }
@ -109,11 +110,9 @@ class Mail
/** /**
* Добавление вложения из строки с указанием имени файла * Добавление вложения из строки с указанием имени файла
*/ */
function addAttachmentRaw($data, $name) function addAttachmentRaw($data, string $name)
{ {
assert(is_string($name)); $this->attachment[] = [$data, $name];
$this->attachment [] = [$data, $name];
} }
function quote($var, $val) function quote($var, $val)
@ -127,33 +126,33 @@ class Mail
*/ */
function mimeTag($name, $value, array $args = []) function mimeTag($name, $value, array $args = [])
{ {
assert (is_string($name)); assert(is_string($name));
assert (is_string($value)); assert(is_string($value));
return $name . ": " . $value . implode("", array_map([$this, 'quote'], array_keys($args), array_values($args))) . PHP_EOL; return $name . ": " . $value . implode("", array_map([$this, 'quote'], array_keys($args), array_values($args))) . PHP_EOL;
} }
/** /**
* *
* @see http://tools.ietf.org/html/rfc2047 * @see http://tools.ietf.org/html/rfc2047
*/ */
function encodedWord($text, $encoding = 'B') function encodedWord(string $text, string $encoding = 'B')
{ {
return "=?{$this->encoding}?$encoding?".base64_encode($text)."?="; return "=?{$this->encoding}?$encoding?" . base64_encode($text) . "?=";
} }
/** /**
* Тело сообщения * Тело сообщения
*/ */
function getMessage() function getMessage(): string
{ {
$message = "--".$this->uniqid . PHP_EOL; $message = "--" . $this->uniqid . PHP_EOL;
$message .= $this->mimeTag("Content-Type", $this->type, ['charset' => $this->encoding]); $message .= $this->mimeTag("Content-Type", $this->type, ['charset' => $this->encoding]);
$message .= $this->mimeTag("Content-Transfer-Encoding", "8bit"); $message .= $this->mimeTag("Content-Transfer-Encoding", "8bit");
$message .= PHP_EOL . $this->content . PHP_EOL . PHP_EOL; $message .= PHP_EOL . $this->content . PHP_EOL . PHP_EOL;
/* /*
* Вложения * Вложения
* http://tools.ietf.org/html/rfc2046#section-5.1.3 * http://tools.ietf.org/html/rfc2046#section-5.1.3
*/ */
foreach ($this->attachment as $value) { foreach ($this->attachment as $value) {
@ -171,7 +170,7 @@ class Mail
/** /**
* Заголовок сообщения * Заголовок сообщения
*/ */
function getHeader() function getHeader(): string
{ {
$head = $this->mimeTag("MIME-Version", "1.0"); $head = $this->mimeTag("MIME-Version", "1.0");
$head .= $this->mimeTag("From", $this->_from); $head .= $this->mimeTag("From", $this->_from);
@ -188,7 +187,7 @@ class Mail
return $head; return $head;
} }
function getSubject() function getSubject(): string
{ {
return $this->encodedWord($this->_subject); return $this->encodedWord($this->_subject);
} }
@ -196,27 +195,28 @@ class Mail
/** /**
* Вывод строки для сохранения в формате .eml * Вывод строки для сохранения в формате .eml
*/ */
function eml() function eml(): string
{ {
return "To: " . $this->_to . PHP_EOL . "Subject: {$this->getSubject()}" . PHP_EOL . $this->getHeader() . $this->getMessage(); return "To: " . $this->_to . PHP_EOL . "Subject: {$this->getSubject()}" . PHP_EOL . $this->getHeader() . $this->getMessage();
} }
/** /**
* Отправка почты * Отправка почты
*/ */
function send() function send(): bool
{ {
$result = mail($this->_to, $this->getSubject(), $this->getMessage(), $this->getHeader()); $result = mail($this->_to, $this->getSubject(), $this->getMessage(), $this->getHeader());
if(! $result) { if (! $result) {
file_put_contents(Path::resolveFile("send.eml"), $this->eml()); file_put_contents(Path::resolveFile("send.eml"), $this->eml());
throw new Exception('Невозможно отправить почту'); throw new Exception('Невозможно отправить почту');
} }
return $result; return $result;
} }
function clear() { function clear(): void
{
foreach ($this->attachment as $key => &$value) { foreach ($this->attachment as $key => &$value) {
unset($this->attachment[$key]); unset($this->attachment[$key]);
} }
$this->attachment = []; $this->attachment = [];
} }

View file

@ -62,12 +62,12 @@ class MailAlt
* Текст письма * Текст письма
* @param string $text * @param string $text
*/ */
function setContent($text) function setContent(string $text)
{ {
$this->mailer->Body = $text; $this->mailer->Body = $text;
} }
function setType($text) function setType(string $text)
{ {
$this->mailer->isHTML($text == 'text/html'); $this->mailer->isHTML($text == 'text/html');
} }
@ -75,7 +75,7 @@ class MailAlt
/** /**
* Кодировка текста в письме * Кодировка текста в письме
*/ */
function setEncoding($encoding) function setEncoding(string $encoding)
{ {
$this->encoding = $encoding; $this->encoding = $encoding;
} }
@ -83,7 +83,7 @@ class MailAlt
/** /**
* Добавление вложения из файла * Добавление вложения из файла
*/ */
function addAttachment(string $filename, $name = null) function addAttachment(string $filename, ?string $name = null)
{ {
$this->mailer->addAttachment($filename, $name); $this->mailer->addAttachment($filename, $name);
} }

View file

@ -12,14 +12,13 @@ class Path
{ {
const SEPARATOR = "/"; const SEPARATOR = "/";
protected $path = array(); protected array $path = [];
protected $url = array(); protected array $url = [];
protected $absolute = false; protected bool $absolute = false;
public function __construct($path = '') public function __construct(string $path = '')
{ {
//assert(is_string($path)); $this->url = parse_url($path);
$this->url = parse_url($path ?? '');
if (isset($this->url['path'])) { if (isset($this->url['path'])) {
$path = $this->url['path']; $path = $this->url['path'];
@ -36,16 +35,16 @@ class Path
} }
} }
static function factory($path) { static function factory(string $path): Path {
return new Path($path); return new Path($path);
} }
public function getParts() public function getParts(): array
{ {
return $this->path; return $this->path;
} }
public static function normalize($pathName) public static function normalize(string $pathName): string
{ {
$path = new Path($pathName); $path = new Path($pathName);
return $path->__toString(); return $path->__toString();
@ -84,15 +83,9 @@ class Path
/** /**
* Полное имя файла без расширения * Полное имя файла без расширения
*
* @param string $fileName Имя файла
*
* @return string
*/ */
static function skipExtension($fileName) static function skipExtension(string $fileName): string
{ {
assert(is_string($fileName));
$path = pathinfo($fileName); $path = pathinfo($fileName);
if ($path['dirname'] === ".") { if ($path['dirname'] === ".") {
return $path['filename']; return $path['filename'];
@ -108,10 +101,8 @@ class Path
* *
* @return string * @return string
*/ */
static function getFileName($fileName) static function getFileName(string $fileName)
{ {
assert(is_string($fileName));
return pathinfo($fileName, PATHINFO_FILENAME); return pathinfo($fileName, PATHINFO_FILENAME);
} }
@ -121,15 +112,10 @@ class Path
* Преобразует строку пути в массив * Преобразует строку пути в массив
* *
* @param string $path Путь * @param string $path Путь
*
* @return array
*/ */
public static function listFromString($path) public static function listFromString(string $path): array
{ {
assert(is_string($path));
$list = preg_split('#\\\\|/#s', $path); $list = preg_split('#\\\\|/#s', $path);
return $list; return $list;
} }
@ -154,11 +140,10 @@ class Path
return $result; return $result;
} }
// Сравнение двух путей на равентство
/** /**
* @param Path $path * Сравнение двух путей на равентство
*/ */
public function equal($path) public function equal(Path $path): bool
{ {
$count = count($this->path); $count = count($this->path);
if ($count == count($path->path)) { if ($count == count($path->path)) {
@ -172,7 +157,7 @@ class Path
return false; return false;
} }
public static function makeUrl($path) public static function makeUrl($path): string
{ {
$slash = (isset($path['host']) && (strlen($path['path']) > 0) && ($path['path'][0] != '/')) ? '/' : ''; $slash = (isset($path['host']) && (strlen($path['path']) > 0) && ($path['path'][0] != '/')) ? '/' : '';
@ -189,10 +174,8 @@ class Path
/** /**
* Преобразует путь в строку * Преобразует путь в строку
*
* @return string
*/ */
public function __toString() public function __toString(): string
{ {
$result = (($this->absolute) ? '/' : '') . implode(self::SEPARATOR, $this->path); $result = (($this->absolute) ? '/' : '') . implode(self::SEPARATOR, $this->path);
$this->url['path'] = $result; $this->url['path'] = $result;
@ -203,10 +186,8 @@ class Path
* Проверяет является ли папка родительской для другой папки * Проверяет является ли папка родительской для другой папки
* *
* @param Path $path * @param Path $path
*
* @return boolean
*/ */
public function isParent($path) public function isParent($path): bool
{ {
if (isset($this->url['host']) && isset($path->url['host']) if (isset($this->url['host']) && isset($path->url['host'])
&& ($this->url['host'] != $path->url['host'])) return false; && ($this->url['host'] != $path->url['host'])) return false;
@ -223,7 +204,7 @@ class Path
return false; return false;
} }
public static function _isParent($path1, $path2) public static function _isParent(string $path1, string $path2): bool
{ {
$path = new Path($path1); $path = new Path($path1);
return $path->isParent(new Path($path2)); return $path->isParent(new Path($path2));
@ -421,7 +402,7 @@ class Path
return $result; return $result;
} }
protected static function fileListAll(&$result, $base, &$allow, &$ignore) protected static function fileListAll(array &$result, string $base, ?array &$allow, array &$ignore)
{ {
$files = self::fileList($base, $allow, $ignore); $files = self::fileList($base, $allow, $ignore);
foreach ($files as $name) { foreach ($files as $name) {

View file

@ -13,6 +13,11 @@ class SortRecord
$this->order = ((boolean)($order) === false) ? 1 : -1; $this->order = ((boolean)($order) === false) ? 1 : -1;
} }
/**
* @template T
* @param array<string, T> $a
* @param array<string, T> $b
*/
function compare(array $a, array $b): int function compare(array $a, array $b): int
{ {
if($a[$this->key] == $b[$this->key]) { if($a[$this->key] == $b[$this->key]) {
@ -29,12 +34,12 @@ class SortRecord
return ($a->{$this->key} > $b->{$this->key}) ? $this->order : -$this->order; return ($a->{$this->key} > $b->{$this->key}) ? $this->order : -$this->order;
} }
function sort(array &$list) function sort(array &$list): bool
{ {
return usort($list, [$this, 'compare']); return usort($list, [$this, 'compare']);
} }
function sortKeys(array &$list) function sortKeys(array &$list): bool
{ {
return usort($list, [$this, 'compareKeys']); return usort($list, [$this, 'compareKeys']);
} }

View file

@ -13,12 +13,12 @@ use PHPTAL_Php_TalesInternal,
class Tales_DateTime implements PHPTAL_Tales class Tales_DateTime implements PHPTAL_Tales
{ {
static public function date($expression, $nothrow = false): string static public function date(string $expression, $nothrow = false): string
{ {
return "ctiso\\Tales::phptal_date(".PHPTAL_Php_TalesInternal::path($expression).")"; return "ctiso\\Tales::phptal_date(".PHPTAL_Php_TalesInternal::path($expression).")";
} }
static public function time($expression, $nothrow = false): string static public function time(string $expression, $nothrow = false): string
{ {
return "ctiso\\Tales::phptal_time(".PHPTAL_Php_TalesInternal::path($expression).")"; return "ctiso\\Tales::phptal_time(".PHPTAL_Php_TalesInternal::path($expression).")";
} }
@ -26,7 +26,7 @@ class Tales_DateTime implements PHPTAL_Tales
class Tales_Component implements PHPTAL_Tales class Tales_Component implements PHPTAL_Tales
{ {
static public function component($expression, $nothrow = false): string static public function component(string $expression, $nothrow = false): string
{ {
$s = PHPTAL_Php_TalesInternal::string($expression); $s = PHPTAL_Php_TalesInternal::string($expression);
return "ctiso\\Tales::phptal_component(" . $s . ")"; return "ctiso\\Tales::phptal_component(" . $s . ")";
@ -35,7 +35,7 @@ class Tales_Component implements PHPTAL_Tales
class Tales_Assets implements PHPTAL_Tales class Tales_Assets implements PHPTAL_Tales
{ {
static public function assets($expression, $nothrow = false): string static public function assets(string $expression, $nothrow = false): string
{ {
$s = PHPTAL_Php_TalesInternal::string($expression); $s = PHPTAL_Php_TalesInternal::string($expression);
return "ctiso\\Tales::phptal_asset(" . $s . ")"; return "ctiso\\Tales::phptal_asset(" . $s . ")";
@ -43,18 +43,18 @@ class Tales_Assets implements PHPTAL_Tales
} }
class Tales { class Tales {
/** @var SiteInterface */ /** @var ?SiteInterface */
static $site; static $site;
static function phptal_date ($e): string { static function phptal_date (int $e): string {
return date("d.m.Y", $e); return date("d.m.Y", $e);
} }
static function phptal_time ($e): string { static function phptal_time (int $e): string {
return date("H:i", $e); return date("H:i", $e);
} }
static function phptal_asset($s): string { static function phptal_asset(string $s): string {
self::$site->addStyleSheet($s); self::$site->addStyleSheet($s);
return ""; return "";
} }
@ -74,7 +74,7 @@ class Tales {
} }
static function register($site) { static function register(?SiteInterface $site) {
self::$site = $site; self::$site = $site;
/* Регистрация нового префикса для подключения компонента */ /* Регистрация нового префикса для подключения компонента */

View file

@ -5,6 +5,7 @@
*/ */
namespace ctiso\Tools; namespace ctiso\Tools;
use ctiso\Tools\Drawing; use ctiso\Tools\Drawing;
use GdImage;
class TemplateImage class TemplateImage
{ {
@ -35,11 +36,11 @@ class TemplateImage
protected array $context = []; protected array $context = [];
protected array $data = []; protected array $data = [];
protected string $base = "c:\\windows\\fonts\\"; protected string $base = "c:\\windows\\fonts\\";
protected $image; protected GdImage $image;
protected $_prepare = true; protected $_prepare = true;
public $debug = false; public $debug = false;
public $resource; public string $resource;
public $filename; public string $filename;
function __construct (?array $template = null) function __construct (?array $template = null)
{ {
@ -66,10 +67,10 @@ class TemplateImage
function set(string $name, $value) function set(string $name, $value)
{ {
$this->context['['.$name.']'] = $this->encode($value); $this->context['['.$name.']'] = $value;
} }
function setImage($name): void function setImage(string $name): void
{ {
$this->filename = $name; $this->filename = $name;
$this->image = $this->imagefromfile($name); $this->image = $this->imagefromfile($name);
@ -140,11 +141,11 @@ class TemplateImage
/** /**
* Перекодировка текста * Перекодировка текста
* @deprecated * @deprecated Можно заменить encode($x) -> $x
*/ */
function encode(string $text): string function encode(string $text): string
{ {
return $text; //iconv("WINDOWS-1251", "UTF-8", $text); return $text;
} }
function setSize(int $new_width, int $new_height): void function setSize(int $new_width, int $new_height): void

View file

@ -11,7 +11,10 @@ class Url {
$this->parent = $parent; $this->parent = $parent;
} }
function setQuery($parts): void { /**
* @param string[] $parts
*/
function setQuery(array $parts): void {
$this->parts = $parts; $this->parts = $parts;
} }

View file

@ -6,10 +6,10 @@ use ctiso\Collection;
abstract class AbstractRule abstract class AbstractRule
{ {
public string $field; public string $field;
protected $errorMsg; protected ?string $errorMsg;
protected $ctx; protected $ctx;
public function __construct(string $field, $errorMsg = null) public function __construct(string $field, ?string $errorMsg = null)
{ {
$this->field = $field; $this->field = $field;
$this->errorMsg = $errorMsg; $this->errorMsg = $errorMsg;

View file

@ -9,15 +9,15 @@ use ctiso\Validator\Rule\AbstractRule,
class Count extends AbstractRule class Count extends AbstractRule
{ {
public $size = 1; public int $size = 1;
public $max = null; public ?int $max = null;
public function getErrorMsg(): string public function getErrorMsg(): string
{ {
return "Количество записей должно быть не менне {$this->size} и не более {$this->max}"; return "Количество записей должно быть не менне {$this->size} и не более {$this->max}";
} }
function not_empty($s) { function notEmpty($s): bool {
return $s != ""; return $s != "";
} }
@ -28,7 +28,7 @@ class Count extends AbstractRule
$this->max = $this->size; $this->max = $this->size;
} }
$count = count(array_filter(array_map('trim', $count = count(array_filter(array_map('trim',
explode(";", $container->get($this->field))), [$this, 'not_empty'])); explode(";", $container->get($this->field))), [$this, 'notEmpty']));
return $count >= $this->size && $count <= ((int)$this->max); return $count >= $this->size && $count <= ((int)$this->max);
} }

View file

@ -9,7 +9,7 @@ use ctiso\Validator\Rule\AbstractRule,
class Time extends AbstractRule class Time extends AbstractRule
{ {
private $split = ":"; private string $split = ":";
public function getErrorMsg(): string public function getErrorMsg(): string
{ {

View file

@ -17,7 +17,7 @@ class Validator
/** /**
* Поля по умолчанию * Поля по умолчанию
* @var array<string, class-string<Rule\AbstractRule>> * @var array<string, class-string<AbstractRule>>
*/ */
protected $type = [ protected $type = [
'date' => Rule\Date::class, 'date' => Rule\Date::class,
@ -43,9 +43,9 @@ class Validator
/** /**
* Добавление правила в список * Добавление правила в список
* @param string $name * @param string $name
* @param class-string<Rule\AbstractRule> $className * @param class-string<AbstractRule> $className
*/ */
function addRuleType(string $name, string $className) { function addRuleType(string $name, string $className): void {
$this->type[$name] = $className; $this->type[$name] = $className;
} }
@ -99,7 +99,7 @@ class Validator
/** /**
* @param AbstractRule $rule * @param AbstractRule $rule
*/ */
public function skip($rule, Collection $container) // -> Rule_Abstract public function skip($rule, Collection $container): bool
{ {
if ($rule->skipEmpty()) { if ($rule->skipEmpty()) {
$data = $container->get($rule->field); $data = $container->get($rule->field);
@ -111,7 +111,7 @@ class Validator
return false; return false;
} }
function reset() { function reset(): void {
$this->errorMsg = []; $this->errorMsg = [];
} }
@ -121,7 +121,7 @@ class Validator
if ($rule) { if ($rule) {
$this->chain = $rule; $this->chain = $rule;
} }
// $this->errorMsg = [];
foreach ($this->chain as $rule) { foreach ($this->chain as $rule) {
//echo $key; //echo $key;
if (!in_array($rule->field, $fields) && !$this->skip($rule, $container) && !$rule->isValid($container, $status)) { if (!in_array($rule->field, $fields) && !$this->skip($rule, $container) && !$rule->isValid($container, $status)) {
@ -133,17 +133,17 @@ class Validator
return $this->isValid(); return $this->isValid();
} }
public function addError($name, $message) public function addError(string $name, string $message)
{ {
$this->errorMsg[$name] = $message; $this->errorMsg[$name] = $message;
} }
public function isError() public function isError(): bool
{ {
return !empty($this->errorMsg); return !empty($this->errorMsg);
} }
public function isValid() public function isValid(): bool
{ {
return empty($this->errorMsg); return empty($this->errorMsg);
} }

View file

@ -6,10 +6,10 @@ use ctiso\View\View,
class Composite extends View class Composite extends View
{ {
private $tal; private PHPTAL $tal;
public $config; public $config;
function __construct($file) function __construct(string $file)
{ {
parent::__construct(); parent::__construct();
@ -29,17 +29,17 @@ class Composite extends View
$this->tal->set($key, $val); $this->tal->set($key, $val);
} }
function __set($key, $val) { function __set(string $key, mixed $val) {
$this->tal->set($key, $val); $this->tal->set($key, $val);
} }
function execute() function execute(): string
{ {
$this->processChild(); $this->processChild();
return $this->tal->execute(); return $this->tal->execute();
} }
function setTranslator($t) { function setTranslator($t): void {
$this->tal->setTranslator($t); $this->tal->setTranslator($t);
} }
} }

View file

@ -7,10 +7,15 @@ class View extends \stdClass
{ {
protected array $_section = []; // Вложенные шаблоны protected array $_section = []; // Вложенные шаблоны
// Блоки // Блоки
/** @var string[] $_stylesheet */
protected array $_stylesheet = []; // Массив стилей текущего шаблона protected array $_stylesheet = []; // Массив стилей текущего шаблона
/** @var string[] $_script */
protected array $_script = []; // Массив скриптов текущего шаблона protected array $_script = []; // Массив скриптов текущего шаблона
/** @var string[] $_scriptstring */
public array $_scriptstring = []; public array $_scriptstring = [];
/** @var string[] $_startup */
protected array $_startup = []; protected array $_startup = [];
protected array $_values = []; protected array $_values = [];
protected ?string $_title = null; // Заголовок текущего шаблона protected ?string $_title = null; // Заголовок текущего шаблона
@ -94,7 +99,7 @@ class View extends \stdClass
* @param string $list Имя свойства * @param string $list Имя свойства
* @param bool $flatten * @param bool $flatten
*/ */
protected function doTree($list, bool $flatten = true) protected function doTree($list, bool $flatten = true): array
{ {
$result = ($flatten == true) ? $this->$list : [$this->$list]; $result = ($flatten == true) ? $this->$list : [$this->$list];
foreach ($this->_section as $value) { foreach ($this->_section as $value) {
@ -131,7 +136,7 @@ class View extends \stdClass
$this->_title = $title; $this->_title = $title;
} }
protected function isNotNull($title): bool protected function isNotNull(?string $title): bool
{ {
return $title !== null; return $title !== null;
} }