Преглед на файлове

Up min PHP version from 7.3 to 8.0 - 4

Visman преди 2 години
родител
ревизия
e2cf3896b6

+ 2 - 4
app/Core/Cache/FileCache.php

@@ -28,7 +28,7 @@ class FileCache implements CacheInterface
      */
     protected $cacheDir;
 
-    public function __construct(string $dir, /* string */ $resetMark)
+    public function __construct(string $dir, string $resetMark)
     {
         $dir = \rtrim($dir, '\\/');
 
@@ -42,9 +42,7 @@ class FileCache implements CacheInterface
 
         $this->cacheDir = $dir;
 
-        if (\is_string($resetMark)) {
-            $this->resetIfRequired($resetMark);
-        }
+        $this->resetIfRequired($resetMark);
     }
 
     /**

+ 1 - 1
app/Core/DB/AbstractStatement.php

@@ -70,7 +70,7 @@ abstract class AbstractStatement extends DBStatement
         return $this->stmt->setFetchMode($mode, ...$args);
     }
 
-    public function fetch(int $mode = 0, int $orientation = PDO::FETCH_ORI_NEXT, int $offset = 0) /* : mixed */
+    public function fetch(int $mode = 0, int $orientation = PDO::FETCH_ORI_NEXT, int $offset = 0): mixed
     {
         $this->okFetchColumn = false;
 

+ 1 - 1
app/Core/DB/Pgsql.php

@@ -119,7 +119,7 @@ class Pgsql
     /**
      * Конвертирует данные в строку для DEFAULT
      */
-    protected function convToStr(/* mixed */ $data): string
+    protected function convToStr(mixed $data): string
     {
         if (\is_string($data)) {
             return $this->db->quote($data);

+ 1 - 1
app/Core/DB/Sqlite.php

@@ -118,7 +118,7 @@ class Sqlite
     /**
      * Конвертирует данные в строку для DEFAULT
      */
-    protected function convToStr(/* mixed */ $data): string
+    protected function convToStr(mixed $data): string
     {
         if (\is_string($data)) {
             return $this->db->quote($data);

+ 5 - 15
app/Core/Mail.php

@@ -35,19 +35,9 @@ class Mail
     ];
     protected string $response;
 
-    public function __construct(
-        /* string */ $host,
-        /* string */ $user,
-        #[SensitiveParameter]
-        /* string */ $pass,
-        /* bool */ $ssl,
-        /* string */ $eol,
-        protected Container $c
-    ) {
-        if (
-            \is_string($host)
-            && \strlen(\trim($host)) > 0
-        ) {
+    public function __construct(string $host, string $user, #[SensitiveParameter] string $pass, int $ssl, string $eol, protected Container $c)
+    {
+        if ('' != $host) {
             $hp = \explode(':', $host, 2);
 
             if (
@@ -62,8 +52,8 @@ class Mail
             $this->smtp = [
                 'host'    => ($ssl ? 'ssl://' : '') . $hp[0],
                 'port'    => (int) $hp[1],
-                'user'    => (string) $user,
-                'pass'    => (string) $pass,
+                'user'    => $user,
+                'pass'    => $pass,
                 'timeout' => 15,
             ];
             $this->EOL = "\r\n";

+ 1 - 1
app/Models/PM/PM.php

@@ -77,7 +77,7 @@ class PM extends Model
         return $this->repository[$type][$key] ?? null;
     }
 
-    public function set(int $type, int $key, /* mixed */ $value): self
+    public function set(int $type, int $key, ?DataModel $value): self
     {
         $this->checkType($type);
 

+ 1 - 1
app/Models/Page.php

@@ -464,7 +464,7 @@ abstract class Page extends Model
      * Возвращает массив хлебных крошек
      * Заполняет массив титула страницы
      */
-    protected function crumbs(/* mixed */ ...$crumbs): array
+    protected function crumbs(mixed ...$crumbs): array
     {
         $result = [];
         $active = true;

+ 1 - 1
app/Models/Pages/Admin.php

@@ -94,7 +94,7 @@ abstract class Admin extends Page
      * Возвращает массив хлебных крошек
      * Заполняет массив титула страницы
      */
-    protected function crumbs(/* mixed */ ...$crumbs): array
+    protected function crumbs(mixed ...$crumbs): array
     {
         if ('index' !== $this->aIndex) {
             if (isset($this->aNavigation[$this->aIndex])) {

+ 1 - 1
app/Models/Pages/Admin/Bans.php

@@ -46,7 +46,7 @@ class Bans extends Admin
     /**
      * Декодирует данные фильтра из url
      */
-    protected function decodeData(string $data) /* : mixed */
+    protected function decodeData(string $data): array|false
     {
         $data = \explode(':', $data);
 

+ 3 - 3
app/Models/Pages/Admin/Users.php

@@ -34,7 +34,7 @@ abstract class Users extends Admin
     /**
      * Кодирует данные фильтра для url
      */
-    protected function encodeData(/* array|string */ $data): string
+    protected function encodeData(string|array $data): string
     {
         if (\is_array($data)) {
             unset($data['token']);
@@ -50,7 +50,7 @@ abstract class Users extends Admin
     /**
      * Декодирует данные фильтра из url
      */
-    protected function decodeData(string $data) /* : mixed */
+    protected function decodeData(string $data): array|false
     {
         $data = \explode(':', $data);
 
@@ -77,7 +77,7 @@ abstract class Users extends Admin
     /**
      * Проверяет доступность действий над выбранными пользователями
      */
-    protected function checkSelected(array $selected, string $action, bool $profile = false) /* : array|false */
+    protected function checkSelected(array $selected, string $action, bool $profile = false): array|false
     {
         $selected = \array_map('\\intval', $selected);
         $bad      = \array_filter($selected, function ($value) {

+ 1 - 1
app/Models/Pages/Auth.php

@@ -135,7 +135,7 @@ class Auth extends Page
     /**
      * Подготавливает массив данных для формы
      */
-    protected function formLogin(string $username, /* mixed */ $save, string $redirect): array
+    protected function formLogin(string $username, mixed $save, string $redirect): array
     {
         return [
             'action' => $this->c->Router->link('Login'),

+ 1 - 1
app/Models/Pages/Message.php

@@ -18,7 +18,7 @@ class Message extends Page
     /**
      * Подготавливает данные для шаблона
      */
-    public function message(/* string|array */ $message, bool $back = true, int $status = 400, array $headers = []): Page
+    public function message(string|array $message, bool $back = true, int $status = 400, array $headers = []): Page
     {
         $this->nameTpl      = 'message';
         $this->onlinePos    = 'info-' . $status;

+ 1 - 1
app/Models/Pages/PM/AbstractPM.php

@@ -121,7 +121,7 @@ abstract class AbstractPM extends Page
      * Возвращает массив хлебных крошек
      * Заполняет массив титула страницы
      */
-    protected function crumbs(/* mixed */ ...$crumbs): array
+    protected function crumbs(mixed ...$crumbs): array
     {
         $pms      = $this->pms;
         $action   = $this->args['action'] ?? ($this->user->u_pm_num_new > 0 ? Cnst::ACTION_NEW : Cnst::ACTION_CURRENT);

+ 1 - 1
app/Models/Pages/PostValidatorTrait.php

@@ -235,7 +235,7 @@ trait PostValidatorTrait
     /**
      * Дополнительная проверка опроса
      */
-    public function vCheckPoll(Validator $v, /* string|false */ $enable, $attr) /* : string|false */
+    public function vCheckPoll(Validator $v, string|false $enable, $attr): string|false
     {
         if (
             false !== $enable

+ 1 - 1
app/Models/Pages/Profile.php

@@ -67,7 +67,7 @@ abstract class Profile extends Page
      * Возвращает массив хлебных крошек
      * Заполняет массив титула страницы
      */
-    protected function crumbs(/* mixed */ ...$crumbs): array
+    protected function crumbs(mixed ...$crumbs): array
     {
         $crumbs[] = [$this->curUser->link, ['User %s', $this->curUser->username]];
         $crumbs[] = [$this->c->Router->link('Userlist'), 'User list'];

+ 1 - 1
app/Models/Pages/Redirect.php

@@ -46,7 +46,7 @@ class Redirect extends Page
     /**
      * Задает сообщение
      */
-    public function message(/* string|array */ $message): Page
+    public function message(string|array $message): Page
     {
         // переадресация без вывода сообщения
         if ($this->c->config->i_redirect_delay < 1) {

+ 2 - 2
app/Models/Pages/Search.php

@@ -361,7 +361,7 @@ class Search extends Page
     /**
      * Дополнительная проверка разделов
      */
-    public function vCheckForums(Validator $v, /* mixed */ $forums) /* : mixed */
+    public function vCheckForums(Validator $v, mixed $forums): mixed
     {
         if ('*' !== $forums) {
             if (
@@ -543,7 +543,7 @@ class Search extends Page
      * Возвращает массив хлебных крошек
      * Заполняет массив титула страницы
      */
-    protected function crumbs(/* mixed */ ...$crumbs): array
+    protected function crumbs(mixed ...$crumbs): array
     {
         $crumbs[] = [$this->c->Router->link('Search'), 'Search'];
 

+ 1 - 1
app/Models/Poll/Poll.php

@@ -236,7 +236,7 @@ class Poll extends DataModel
     /**
      * Возвращает статус опроса для текущего пользователя или null
      */
-    protected function getstatus() /* : null|string|array */
+    protected function getstatus(): string|array|null
     {
         if ($this->tid < 1) {
             return null;

+ 1 - 1
app/Models/User/UpdateCountPosts.php

@@ -19,7 +19,7 @@ class UpdateCountPosts extends Action
     /**
      * Обновляет число сообщений пользователя(ей)
      */
-    public function updateCountPosts(/* mixed */ ...$args): void
+    public function updateCountPosts(mixed ...$args): void
     {
         $ids = [];
         foreach ($args as $arg) {

+ 1 - 1
app/Models/User/UpdateCountTopics.php

@@ -19,7 +19,7 @@ class UpdateCountTopics extends Action
     /**
      * Обновляет число тем пользователя(ей)
      */
-    public function updateCountTopics(/* mixed */ ...$args): void
+    public function updateCountTopics(mixed ...$args): void
     {
         $ids = [];
         foreach ($args as $arg) {

+ 2 - 2
app/functions.php

@@ -28,7 +28,7 @@ function _init(Container $c): void
  * Переводит строку с подстановкой аргументов
  * Защита от дурака отсутствует, ловим ошибки/исключения
  */
-function __(/* string|array */ $arg): string
+function __(string|array $arg): string
 {
     static $c, $lang;
 
@@ -81,7 +81,7 @@ function e(string $arg): string
 /**
  * Возвращает число в формате текущего пользователя
  */
-function num(/* mixed */ $number, int $decimals = 0): string
+function num(mixed $number, int $decimals = 0): string
 {
     return \is_numeric($number)
         ? \number_format((float) $number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep'))