chore: Типы

This commit is contained in:
origami11@yandex.ru 2025-12-04 19:44:02 +03:00
parent 08defbd046
commit b782af55a5
6 changed files with 20 additions and 18 deletions

View file

@ -81,7 +81,7 @@ class Login extends Filter
$request->set('timeout_error', true); $request->set('timeout_error', true);
break; break;
} else { } else {
$this->role->resetTries($request->get('login')); $this->role->resetTries($request->getString('login'));
} }
} }
// Извлечнеие пользователя из родительской CMS, для проверки пароля // Извлечнеие пользователя из родительской CMS, для проверки пароля
@ -154,7 +154,7 @@ class Login extends Filter
public function execute(HttpRequest $request): mixed public function execute(HttpRequest $request): mixed
{ {
$logged = $this->isLoggin($request); $logged = $this->isLoggin($request);
if ($request->get('action') == 'user_access') { if ($request->getString('action') == 'user_access') {
if ($logged) { if ($logged) {
$result = []; $result = [];
$result['fullname'] = $this->user->getString('patronymic') . " " . $this->user->getString('firstname'); $result['fullname'] = $this->user->getString('patronymic') . " " . $this->user->getString('firstname');
@ -166,7 +166,7 @@ class Login extends Filter
} }
} }
if ($request->get('action') == 'relogin') { if ($request->getString('action') == 'relogin') {
if ($logged) { if ($logged) {
return json_encode(['result' => 'ok', 'message' => "Авторизация успешна"]); return json_encode(['result' => 'ok', 'message' => "Авторизация успешна"]);
} else { } else {
@ -177,7 +177,7 @@ class Login extends Filter
if (!$logged) { if (!$logged) {
// Параметры при неправильной авторизации // Параметры при неправильной авторизации
// Действия по умолчанию !! Возможно переход на форму регистрации // Действия по умолчанию !! Возможно переход на форму регистрации
if ($request->get('mode') == 'ajax') { if ($request->getString('mode') == 'ajax') {
if (!$this->requestIsWhite($request)) { if (!$this->requestIsWhite($request)) {
return json_encode(['result' => 'fail', 'message' =>"NOT_AUTHORIZED"]); return json_encode(['result' => 'fail', 'message' =>"NOT_AUTHORIZED"]);
} }
@ -188,7 +188,7 @@ class Login extends Filter
} else if (isset($_SERVER['HTTP_REFERER'])) { } else if (isset($_SERVER['HTTP_REFERER'])) {
$arr = []; $arr = [];
parse_str(parse_url($_SERVER['HTTP_REFERER'] ?? '', PHP_URL_QUERY) ?? '', $arr); parse_str(parse_url($_SERVER['HTTP_REFERER'] ?? '', PHP_URL_QUERY) ?? '', $arr);
if (isset($arr['back_page']) && $request->get('mode') != 'ajax') { if (isset($arr['back_page']) && $request->getString('mode') != 'ajax') {
$request->redirect($arr['back_page']); $request->redirect($arr['back_page']);
} }
} }

View file

@ -120,12 +120,12 @@ class Path
* Преобразует строку пути в массив * Преобразует строку пути в массив
* *
* @param string $path Путь * @param string $path Путь
* @return list<string>|false * @return list<string>
*/ */
public static function listFromString(string $path): array|false public static function listFromString(string $path): array
{ {
$list = preg_split('#\\\\|/#s', $path); $list = preg_split('#\\\\|/#s', $path);
return $list; return $list ?: [];
} }
/** /**

View file

@ -16,10 +16,7 @@ class Session
{ {
if (is_array($key)) { if (is_array($key)) {
$className = get_class($key[0]); $className = get_class($key[0]);
/*if ($className === false) { $_SESSION[strtolower($className ?: '')][$key[1]] = $value;
throw new \RuntimeException("Invalid class name " . $className);
}*/
$_SESSION[strtolower($className)][$key[1]] = $value;
} else { } else {
$_SESSION[$key] = $value; $_SESSION[$key] = $value;
} }

View file

@ -10,6 +10,7 @@
namespace ctiso; namespace ctiso;
use ctiso\Tools\SQLStatementExtractor; use ctiso\Tools\SQLStatementExtractor;
use ctiso\Path; use ctiso\Path;
use ctiso\File;
use SimpleXMLElement; use SimpleXMLElement;
class FakeZipArchive { class FakeZipArchive {
@ -26,7 +27,7 @@ class FakeZipArchive {
* @return string * @return string
*/ */
function getFromName($file) { function getFromName($file) {
return file_get_contents(Path::join($this->base, $file)); return File::getContents(Path::join($this->base, $file));
} }
} }

View file

@ -96,11 +96,11 @@ class StringUtil
/** /**
* Разбивает строку на массив символов * Разбивает строку на массив символов
* @param string $str * @param string $str
* @return array|false * @return array
*/ */
static function mb_str_split(string $str): array|false static function mb_str_split(string $str): array
{ {
return preg_split('~~u', $str, -1, PREG_SPLIT_NO_EMPTY); return preg_split('~~u', $str, -1, PREG_SPLIT_NO_EMPTY) ?: [];
} }
/** /**

View file

@ -196,12 +196,16 @@ class TemplateImage
return $text; return $text;
} }
function setSize(int $new_width, int $new_height): void /**
* @param int<1,max> $new_width
* @param ?int<1,max> $new_height
*/
function setSize(int $new_width, ?int $new_height = null): void
{ {
$width = imagesx($this->image); $width = imagesx($this->image);
$height = imagesy($this->image); $height = imagesy($this->image);
if ($new_height == null) { if ($new_height == null) {
$new_height = ceil($height * $new_width / $width); $new_height = max(1, (int)ceil($height * $new_width / $width));
} }
// Resample // Resample