Up min PHP version from 7.3 to 8.0

This commit is contained in:
Visman 2023-04-27 19:36:15 +07:00
parent 53daef4623
commit 5528d0480b
39 changed files with 247 additions and 638 deletions

View file

@ -15,15 +15,8 @@ use ForkBB\Models\Page;
class Install
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**

View file

@ -15,15 +15,8 @@ use ForkBB\Models\Page;
class Primary
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**

View file

@ -15,15 +15,8 @@ use ForkBB\Models\Page;
class Routing
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**

View file

@ -15,15 +15,8 @@ use ForkBB\Models\Page;
class Update
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**

View file

@ -16,45 +16,38 @@ class Config
{
/**
* Путь до файла конфига
* @var string
*/
protected $path;
protected string $path;
/**
* Содержимое файла конфига
* @var string
*/
protected $fileContents;
protected string $fileContents;
/**
* Начальная позиция массива конфига
* @var int
*/
protected $arrayStartPos;
protected int $arrayStartPos;
/**
* Массив токенов
* @var array
*/
protected $tokens;
protected array $tokens;
/**
* Текущая позиция в массиве токенов
* @var int
*/
protected $position;
protected int $position;
/**
* Массив полученый из файла настройки путем его парсинга
* @var array
*/
protected $configArray;
protected array $configArray;
/**
* Строка массива конфига в файле конфигурации
* @var string
*/
protected $configStr;
protected string $configStr;
public function __construct(string $path)
{
@ -133,7 +126,7 @@ class Config
/**
* Очищает ключ от кавычек
*/
protected function clearKey(/* mixed */ $key)
protected function clearKey(mixed $key): string
{
if (! \is_string($key)) {
throw new ForkException('Config array cannot be parsed (2)');
@ -315,7 +308,7 @@ class Config
}
}
protected function isFormat(/* mixed */ $data): bool
protected function isFormat(mixed $data): bool
{
return \is_array($data)
&& \array_key_exists('value', $data)
@ -328,7 +321,7 @@ class Config
/**
* Добавляет/заменяет элемент в конфиг(е)
*/
public function add(string $path, /* mixed */ $value, string $after = null): bool
public function add(string $path, mixed $value, string $after = null): bool
{
if (empty($this->configArray)) {
$this->configArray = $this->getArray();
@ -405,7 +398,7 @@ class Config
/**
* Удаляет элемент из конфига
*/
public function delete(string $path)
public function delete(string $path): mixed
{
if (empty($this->configArray)) {
$this->configArray = $this->getArray();

View file

@ -18,9 +18,9 @@ use InvalidArgumentException;
*/
class Container
{
protected $instances = [];
protected $shared = [];
protected $multiple = [];
protected array $instances = [];
protected array $shared = [];
protected array $multiple = [];
public function __construct(array $config = null)
{
@ -64,7 +64,7 @@ class Container
/**
* Gets a service or parameter.
*/
public function __get(string $key) /* : mixed */
public function __get(string $key): mixed
{
if (\array_key_exists($key, $this->instances)) {
return $this->instances[$key];
@ -132,7 +132,7 @@ class Container
* Sets a service or parameter.
* Provides a fluent interface.
*/
public function __set(string $key, /* mixed */ $service): void
public function __set(string $key, mixed $service): void
{
if (false !== \strpos($key, '.')) {
throw new InvalidArgumentException("Wrong property name: {$key}");
@ -144,7 +144,7 @@ class Container
/**
* Gets data from array.
*/
public function fromArray(array $array, array $tree) /* : mixed */
public function fromArray(array $array, array $tree): mixed
{
$ptr = &$array;
@ -163,7 +163,7 @@ class Container
* Sets a parameter.
* Provides a fluent interface.
*/
public function setParameter(string $name, /* mixed */ $value): Container
public function setParameter(string $name, mixed $value): Container
{
$segments = \explode('.', $name);
$n = \count($segments);
@ -186,7 +186,7 @@ class Container
return $this;
}
protected function resolve(/* mixed */ $value) /* : mixed */
protected function resolve(mixed $value): mixed
{
if (\is_string($value)) {
if (false !== \strpos($value, '%')) {

View file

@ -17,33 +17,11 @@ class Csrf
{
const TOKEN_LIFETIME = 1800;
/**
* @var Secury
*/
protected $secury;
protected ?string $error = null;
protected int $hashExpiration = 3600;
/**
* @var string
*/
protected $key;
/**
* @var ?string
*/
protected $error;
/**
* @var int
*/
protected $hashExpiration = 3600;
public function __construct(
Secury $secury,
#[SensitiveParameter]
string $key
) {
$this->secury = $secury;
$this->key = \sha1($key);
public function __construct(protected Secury $secury, #[SensitiveParameter] protected string $key)
{
}
/**
@ -57,7 +35,7 @@ class Csrf
/**
* Возвращает csrf токен
*/
public function create(string $marker, array $args = [], /* string|int */ $time = null): string
public function create(string $marker, array $args = [], int|string $time = null): string
{
$marker = $this->argsToStr($marker, $args);
$time = $time ?: \time();
@ -68,7 +46,7 @@ class Csrf
/**
* Возвращает хэш
*/
public function createHash(string $marker, array $args = [], /* string|int */ $time = null): string
public function createHash(string $marker, array $args = [], int|string $time = null): string
{
$marker = $this->argsToStr($marker, $args, ['hash']);
$time = $time ?: \time() + $this->hashExpiration;

View file

@ -19,27 +19,24 @@ use SensitiveParameter;
class DB
{
/**
* @var PDO
* Экземпляр PDO через который идет работа с бд
*/
protected $pdo;
protected PDO $pdo;
/**
* Префикс для таблиц базы
* @var string
*/
protected $dbPrefix;
protected string $dbPrefix;
/**
* Тип базы данных
* @var string
*/
protected $dbType;
protected string $dbType;
/**
* Имя класса для драйвера
* @var string
*/
protected $dbDrvClass;
protected string $dbDrvClass;
/**
* Драйвер текущей базы
@ -49,32 +46,25 @@ class DB
/**
* Имя класса для PDOStatement
* @var string
*/
protected $statementClass;
protected string $statementClass;
/**
* Количество выполненных запросов
* @var int
*/
protected $qCount = 0;
protected int $qCount = 0;
/**
* Выполненные запросы
* @var array
*/
protected $queries = [];
protected array $queries = [];
/**
* Дельта времени для следующего запроса
* @var float
*/
protected $delta = 0;
protected float $delta = 0;
/**
* @var array
*/
protected $pdoMethods = [
protected array $pdoMethods = [
'beginTransaction' => true,
'commit' => true,
'errorCode' => true,
@ -108,8 +98,7 @@ class DB
public function __construct(
string $dsn,
string $username = null,
#[SensitiveParameter]
string $password = null,
#[SensitiveParameter] string $password = null,
array $options = [],
string $prefix = ''
) {
@ -270,7 +259,7 @@ class DB
/**
* Метод возвращает значение из массива параметров по ключу или исключение
*/
public function getValue(/* int|string */ $key, array $params) /* : mixed */
public function getValue(int|string $key, array $params): mixed
{
if (
\is_string($key)
@ -330,7 +319,7 @@ class DB
/**
* Метод расширяет PDO::exec()
*/
public function exec(string $query, array $params = []) /* : int|false */
public function exec(string $query, array $params = []): int|false
{
$map = $this->parse($query, $params);
@ -365,7 +354,7 @@ class DB
/**
* Метод расширяет PDO::prepare()
*/
public function prepare(string $query, array $params = [], array $options = []) /* : DBStatement|false */
public function prepare(string $query, array $params = [], array $options = []): DBStatement|false
{
$map = $this->parse($query, $params);
$start = \microtime(true);
@ -387,7 +376,7 @@ class DB
/**
* Метод расширяет PDO::query()
*/
public function query(string $query, /* mixed */ ...$args) /* : DBStatement|false */
public function query(string $query, mixed ...$args): DBStatement|false
{
if (
isset($args[0])
@ -478,7 +467,7 @@ class DB
/**
* Передает вызовы метода в PDO или драйвер текущей базы
*/
public function __call(string $name, array $args) /* : mixed */
public function __call(string $name, array $args): mixed
{
if (isset($this->pdoMethods[$name])) {
return $this->pdo->$name(...$args);

View file

@ -19,36 +19,31 @@ abstract class AbstractStatement extends DBStatement
{
/**
* Типы столбцов полученные через getColumnMeta()
* @var array
*/
protected $columnsType;
protected ?array $columnsType = null;
/**
* Режим выборки установленный через setFetchMode()/fetchAll()
* @var int
*/
protected $fetchMode;
protected int $fetchMode;
/**
* colno, class или object из setFetchMode()/fetchAll()
* @var mixed
*/
protected $fetchArg;
protected mixed $fetchArg;
/**
* constructorArgs из setFetchMode()/fetchAll()
* @var array
*/
protected $ctorArgs;
protected ?array $ctorArgs = null;
/**
* Флаг успешного завершения fetch() для PDO::FETCH_COLUMN
* @var bool
*/
protected $okFetchColumn;
protected bool $okFetchColumn;
abstract public function getColumnsType(): array;
abstract protected function convToBoolean(/* mixed */ $value): bool;
abstract protected function convToBoolean(mixed $value): bool;
protected function setFetchVars(int $mode, ...$args): void
{

View file

@ -22,27 +22,15 @@ class DBStatement
const INTEGER = 'i';
const STRING = 's';
/**
* @var DB
*/
protected $db;
/**
* @var PDOStatement
*/
protected $stmt;
/**
* Карта преобразования переменных
* @var array
*/
protected $map = [];
protected array $map = [];
/**
* Карта типов
* @var array
*/
protected $types = [
protected array $types = [
'b' => PDO::PARAM_BOOL,
'f' => PDO::PARAM_STR,
'i' => PDO::PARAM_INT,
@ -52,10 +40,8 @@ class DBStatement
'as' => PDO::PARAM_STR,
];
public function __construct(DB $db, PDOStatement $stmt)
public function __construct(protected DB $db, protected PDOStatement $stmt)
{
$this->db = $db;
$this->stmt = $stmt;
}
/**
@ -115,7 +101,7 @@ class DBStatement
/**
* Передает вызовы метода в PDOStatement
*/
public function __call(string $name, array $args) /* : mixed */
public function __call(string $name, array $args): mixed
{
return $this->stmt->$name(...$args);
}

View file

@ -17,30 +17,17 @@ use PDOException;
class Mysql
{
/**
* @var DB
*/
protected $db;
/**
* Префикс для таблиц базы
* @var string
*/
protected $dbPrefix;
/**
* Массив замены типов полей таблицы
* @var array
*/
protected $dbTypeRepl = [
protected array $dbTypeRepl = [
'%^SERIAL$%i' => 'INT(10) UNSIGNED AUTO_INCREMENT',
];
/**
* Подстановка типов полей для карты БД
* @var array
*/
protected $types = [
protected array $types = [
'bool' => 'b',
'boolean' => 'b',
'tinyint' => 'i',
@ -55,13 +42,9 @@ class Mysql
'double' => 'i',
];
public function __construct(DB $db, string $prefix)
public function __construct(protected DB $db, protected string $dbPrefix)
{
$this->db = $db;
$this->nameCheck($prefix);
$this->dbPrefix = $prefix;
$this->nameCheck($dbPrefix);
}
/**
@ -129,7 +112,7 @@ class Mysql
/**
* Конвертирует данные в строку для DEFAULT
*/
protected function convToStr(/* mixed */ $data): string
protected function convToStr(mixed $data): string
{
if (\is_string($data)) {
return $this->db->quote($data);
@ -336,7 +319,7 @@ class Mysql
/**
* Добавляет поле в таблицу
*/
public function addField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function addField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$table = $this->tName($table);
@ -358,7 +341,7 @@ class Mysql
/**
* Модифицирует поле в таблице
*/
public function alterField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function alterField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$table = $this->tName($table);
$query = "ALTER TABLE `{$table}` MODIFY " . $this->buildColumn($field, [$type, $allowNull, $default, $collate]);

View file

@ -17,22 +17,10 @@ use PDOException;
class Pgsql
{
/**
* @var DB
*/
protected $db;
/**
* Префикс для таблиц базы
* @var string
*/
protected $dbPrefix;
/**
* Массив замены типов полей таблицы
* @var array
*/
protected $dbTypeRepl = [
protected array $dbTypeRepl = [
'%^(?:TINY|SMALL)INT(?:\s*\(\d+\))?(?:\s*UNSIGNED)?$%i' => 'SMALLINT',
'%^(?:MEDIUM)?INT(?:\s*\(\d+\))?(?:\s*UNSIGNED)?$%i' => 'INTEGER',
'%^BIGINT(?:\s*\(\d+\))?(?:\s*UNSIGNED)?$%i' => 'BIGINT',
@ -43,9 +31,8 @@ class Pgsql
/**
* Подстановка типов полей для карты БД
* @var array
*/
protected $types = [
protected array $types = [
'bool' => 'b',
'boolean' => 'b',
'tinyint' => 'i',
@ -62,13 +49,9 @@ class Pgsql
'double precision' => 'i',
];
public function __construct(DB $db, string $prefix)
public function __construct(protected DB $db, protected string $dbPrefix)
{
$this->db = $db;
$this->nameCheck($prefix);
$this->dbPrefix = $prefix;
$this->nameCheck($dbPrefix);
}
/**
@ -345,7 +328,7 @@ class Pgsql
/**
* Добавляет поле в таблицу
*/
public function addField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function addField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$table = $this->tName($table);
@ -361,7 +344,7 @@ class Pgsql
/**
* Модифицирует поле в таблице
*/
public function alterField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function alterField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$this->nameCheck($field);

View file

@ -17,22 +17,10 @@ use PDOException;
class Sqlite
{
/**
* @var DB
*/
protected $db;
/**
* Префикс для таблиц базы
* @var string
*/
protected $dbPrefix;
/**
* Массив замены типов полей таблицы
* @var array
*/
protected $dbTypeRepl = [
protected array $dbTypeRepl = [
'%^.*?INT.*$%i' => 'INTEGER',
'%^.*?(?:CHAR|CLOB|TEXT).*$%i' => 'TEXT',
'%^.*?BLOB.*$%i' => 'BLOB',
@ -44,22 +32,17 @@ class Sqlite
/**
* Подстановка типов полей для карты БД
* @var array
*/
protected $types = [
protected array $types = [
'boolean' => 'b',
'integer' => 'i',
'real' => 'f',
'numeric' => 'f',
];
public function __construct(DB $db, string $prefix)
public function __construct(protected DB $db, protected string $dbPrefix)
{
$this->db = $db;
$this->nameCheck($prefix);
$this->dbPrefix = $prefix;
$this->nameCheck($dbPrefix);
}
/**
@ -508,7 +491,7 @@ class Sqlite
/**
* Добавляет поле в таблицу
*/
public function addField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function addField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$table = $this->tName($table);
@ -524,7 +507,7 @@ class Sqlite
/**
* Модифицирует поле в таблице
*/
public function alterField(string $table, string $field, string $type, bool $allowNull, /* mixed */ $default = null, string $collate = null, string $after = null): bool
public function alterField(string $table, string $field, string $type, bool $allowNull, mixed $default = null, string $collate = null, string $after = null): bool
{
$this->nameCheck($field);

View file

@ -33,10 +33,7 @@ class SqliteStatement extends AbstractStatement
* ... (это те типы, которые прописаны в CREATE TABLE и полученные после перекодировки из {driver}::bTypeRepl)
*/
/**
* @var array
*/
protected $nativeTypeRepl = [
protected array $nativeTypeRepl = [
'integer' => self::INTEGER,
'double' => self::FLOAT,
];
@ -81,7 +78,7 @@ class SqliteStatement extends AbstractStatement
return $this->columnsType;
}
protected function convToBoolean(/* mixed */ $value): bool
protected function convToBoolean(mixed $value): bool
{
return (bool) $value;
}

View file

@ -16,35 +16,27 @@ use Throwable;
class ErrorHandler
{
/**
* Контейнер
* @var Container
*/
protected $c;
protected Container $c;
/**
* Уровень буфера вывода на котором работает обработчик
* @var int
*/
protected $obLevel;
protected int $obLevel;
/**
* Описание ошибки
* @var array
*/
protected $error;
protected ?array $error = null;
/**
* Скрываемая часть пути до файла
* @var string
*/
protected $hidePath;
protected string $hidePath;
/**
* Список ошибок
* @var array
*/
protected $type = [
protected array $type = [
0 => ['OTHER_ERROR', 'error'],
\E_ERROR => ['E_ERROR', 'error'],
\E_WARNING => ['E_WARNING', 'warning'],
@ -65,9 +57,8 @@ class ErrorHandler
/**
* Уровень ошибок только для логирования
* @var int
*/
protected $logOnly = 0;
protected int $logOnly = 0;
public function __construct()
{

View file

@ -18,63 +18,35 @@ class File
{
/**
* Текст ошибки
* @var null|string
*/
protected $error;
/**
* Путь до файла
* @var null|string
*/
protected $path;
protected ?string $error = null;
/**
* Содержимое файла
* @var null|string
*/
protected $data;
/**
* Оригинальное имя файла без расширения
* @var null|string
*/
protected $name;
/**
* Оригинальное расширение файла
* @var null|string
*/
protected $ext;
protected ?string $data;
/**
* Размер оригинального файла
*/
protected $size;
protected int|false $size;
/**
* Флаг автопереименования файла
* @var bool
*/
protected $rename = false;
protected bool $rename = false;
/**
* Флаг перезаписи файла
* @var bool
*/
protected $rewrite = false;
protected bool $rewrite = false;
/**
* Паттерн для pathinfo
* @var string
*/
protected $pattern = '%^(?!.*?\.\.)([\w.\x5C/:-]*[\x5C/])?(\*|[\w.-]+)\.(\*|[a-z\d]+)$%iD';
protected string $pattern = '%^(?!.*?\.\.)([\w.\x5C/:-]*[\x5C/])?(\*|[\w.-]+)\.(\*|[a-z\d]+)$%iD';
/**
* @var Files
*/
protected $files;
public function __construct(string $path, string $name, string $ext, Files $files)
public function __construct(protected string $path, protected string $name, protected string $ext, protected Files $files)
{
if ($files->isBadPath($path)) {
throw new FileException('Bad path to file');
@ -86,10 +58,6 @@ class File
throw new FileException('File can not be read');
}
$this->files = $files;
$this->path = $path;
$this->name = $name;
$this->ext = $ext;
$this->data = null;
$this->size = \is_string($this->data) ? \strlen($this->data) : \filesize($path);

View file

@ -20,53 +20,35 @@ use RuntimeException;
class Files
{
/**
* Контейнер
* @var Container
*/
protected $c;
/**
* Максимальный размер для картинок
* @var int
*/
protected $maxImgSize;
protected int $maxImgSize;
/**
* Максимальный размер для файлов
* @var int
*/
protected $maxFileSize;
protected int $maxFileSize;
/**
* Максимальный число пикселей
* @var int
*/
protected $maxPixels;
protected int $maxPixels;
/**
* Текст ошибки
* @var null|string
*/
protected $error;
protected ?string $error = null;
/**
* Класс обработки изображений
* @var DefaultDriver
*/
protected $imageDriver;
/**
* Список имён драйверов
* @var array
*/
protected $imageDrivers;
protected ?DefaultDriver $imageDriver = null;
/**
* Список mime типов считающихся картинками
* @var array
*/
protected $imageType = [
protected array $imageType = [
'image/gif' => 'gif',
'image/jpeg' => 'jpg',
'image/png' => 'png',
@ -79,16 +61,14 @@ class Files
/**
* Список единиц измерения
* @var string
*/
protected $units = 'BKMGTPEZY';
protected string $units = 'BKMGTPEZY';
/**
* Допустимые расширения файлов для mime типов
* http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
* @var array
*/
protected $mimeToExt = [
protected array $mimeToExt = [
'application/andrew-inset' => 'ez',
'application/applixware' => 'aw',
'application/atom+xml' => 'atom',
@ -861,11 +841,8 @@ class Files
'image/avif' => 'avif',
];
public function __construct(/* string|int */ $maxFileSize, /* string|int */ $maxImgSize, array $imageDrivers, Container $c)
public function __construct(int|string $maxFileSize, int|string $maxImgSize, protected array $imageDrivers, protected Container $c)
{
$this->c = $c;
$this->imageDrivers = $imageDrivers;
$init = \min(
\PHP_INT_MAX,
$this->size(\ini_get('upload_max_filesize')),
@ -924,7 +901,7 @@ class Files
* Переводит объем информации из одних единиц в другие
* кило = 1024, а не 1000
*/
public function size(/* int|float|string */ $value, string $to = null): int
public function size(int|float|string $value, string $to = null): int
{
if (\is_string($value)) {
if (! \preg_match('%^([^a-z]+)([a-z]+)?$%i', \trim($value), $matches)) {
@ -975,7 +952,7 @@ class Files
/**
* Определяет расширение картинки по содержимому файла
*/
public function imageExt(/* mixed */ $file): ?string
public function imageExt(mixed $file): ?string
{
if ($file instanceof Image) {
return $file->ext();
@ -1011,7 +988,7 @@ class Files
/**
* Получает файл(ы) из формы
*/
public function upload(array $file) /* : mixed */
public function upload(array $file): mixed
{
$this->error = null;

View file

@ -15,33 +15,23 @@ use function \ForkBB\__;
class Func
{
/**
* Контейнер
* @var Container
*/
protected $c;
/**
* Список доступных стилей
* @var array
*/
protected $styles;
protected ?array $styles = null;
/**
* Список доступных языков
* @var array
*/
protected $langs;
protected ?array $langs = null;
/**
* Список имен доступных языков
* @var array
*/
protected $nameLangs;
protected ?array $nameLangs = null;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**
@ -75,10 +65,13 @@ class Func
{
if (! \is_array($this->nameLangs)) {
$langs = $this->getLangs();
foreach ($langs as &$value) {
$value = include "{$this->c->DIR_LANG}/{$value}/name.php";
}
unset($value);
$this->nameLangs = $langs;
}
@ -105,6 +98,7 @@ class Func
$result[$entry] = $entry;
}
}
\closedir($dh);
\asort($result, \SORT_NATURAL);
}
@ -232,6 +226,7 @@ class Func
foreach (\explode(',', $str) as $step) {
$dsr = \explode(';', $step, 2);
if (
isset($dsr[1])) {
$q = \trim(\ltrim(\ltrim($dsr[1], 'q '), '='));
@ -248,10 +243,12 @@ class Func
}
$l = \trim($dsr[0]);
if (\preg_match('%^[[:alpha:]]{1,8}(?:-[[:alnum:]]{1,8})?$%', $l)) {
$result[$l] = $q;
}
}
\arsort($result, \SORT_NUMERIC);
return \array_keys($result);

View file

@ -15,8 +15,9 @@ use RuntimeException;
class HTMLCleaner extends Jevix
{
protected $hConfigFile;
protected $hConfigName;
protected string $hConfigFile;
protected ?string $hConfigName = null;
public function __construct(string $file)
{

View file

@ -20,27 +20,23 @@ class Image extends File
{
/**
* Изображение
* @var mixed
*/
protected $image;
protected mixed $image;
/**
* Класс обработки изображений
* @var DefaultDriver
*/
protected $imgDriver;
protected DefaultDriver $imgDriver;
/**
* Качество изображения
* @var int
*/
protected $quality = 100;
protected int $quality = 100;
/**
* Паттерн для pathinfo
* @var string
*/
protected $pattern = '%^(?!.*?\.\.)([\w.\x5C/:-]*[\x5C/])?(\*|[\w.-]+)\.(\*|[a-z\d]+|\([a-z\d]+(?:\|[a-z\d]+)*\))$%iD';
protected string $pattern = '%^(?!.*?\.\.)([\w.\x5C/:-]*[\x5C/])?(\*|[\w.-]+)\.(\*|[a-z\d]+|\([a-z\d]+(?:\|[a-z\d]+)*\))$%iD';
public function __construct(string $path, string $name, string $ext, Files $files)
{

View file

@ -17,20 +17,11 @@ class DefaultDriver
{
const DEFAULT = true;
/**
* @var bool
*/
protected $ready;
protected bool $ready = false;
/**
* @var Files
*/
protected $files;
public function __construct(Files $files)
public function __construct(protected Files $files)
{
$this->ready = true;
$this->files = $files;
}
public function ready(): bool
@ -38,27 +29,27 @@ class DefaultDriver
return $this->ready;
}
public function readFromStr(string $data) /* : mixed|false */
public function readFromStr(string $data): mixed
{
return false;
}
public function readFromPath(string $path) /* : mixed|false */
public function readFromPath(string $path): mixed
{
return false;
}
public function writeToPath(/* mixed */ $image, string $path, int $quality): ?bool
public function writeToPath(mixed $image, string $path, int $quality): ?bool
{
return null;
}
public function resize(/* mixed */ $image, int $maxW, int $maxH) /* : mixed */
public function resize(mixed $image, int $maxW, int $maxH): mixed
{
return $image;
}
public function destroy(/* mixed */ $image): void
public function destroy(mixed $image): void
{
}
}

View file

@ -25,12 +25,12 @@ class GDDriver extends DefaultDriver
$this->ready = \extension_loaded('gd') && \function_exists('\\imagecreatetruecolor');
}
public function readFromStr(string $data) /* : mixed|false */
public function readFromStr(string $data): mixed
{
return $this->tuning($this->ready ? \imagecreatefromstring($data) : false);
}
public function readFromPath(string $path) /* : mixed|false */
public function readFromPath(string $path): mixed
{
if (
! $this->ready
@ -42,7 +42,7 @@ class GDDriver extends DefaultDriver
}
}
protected function tuning(/* mixed */ $image) /* : mixed */
protected function tuning(mixed $image): mixed
{
if (
false !== $image
@ -57,7 +57,7 @@ class GDDriver extends DefaultDriver
}
}
public function writeToPath(/* mixed */ $image, string $path, int $quality): ?bool
public function writeToPath(mixed $image, string $path, int $quality): ?bool
{
$args = [$image, $path];
$type = \pathinfo($path, \PATHINFO_EXTENSION);
@ -92,7 +92,7 @@ class GDDriver extends DefaultDriver
}
}
public function resize(/* mixed */ $image, int $maxW, int $maxH) /* : mixed */
public function resize(mixed $image, int $maxW, int $maxH): mixed
{
if (! $this->ready) {
throw new FileException('GD library not enabled');
@ -140,7 +140,7 @@ class GDDriver extends DefaultDriver
return $result;
}
public function destroy(/* mixed */ $image): void
public function destroy(mixed $image): void
{
if (\is_resource($image)) {
\imagedestroy($image);

View file

@ -27,7 +27,7 @@ class ImagickDriver extends DefaultDriver
$this->ready = \extension_loaded('imagick') && \class_exists('\\Imagick');
}
public function readFromStr(string $data) /* : mixed|false */
public function readFromStr(string $data): mixed
{
if ($this->ready) {
try {
@ -43,7 +43,7 @@ class ImagickDriver extends DefaultDriver
return false;
}
public function readFromPath(string $path) /* : mixed|false */
public function readFromPath(string $path): mixed
{
if (
! $this->ready
@ -59,7 +59,7 @@ class ImagickDriver extends DefaultDriver
}
}
public function writeToPath(/* mixed */ $imagick, string $path, int $quality): ?bool
public function writeToPath(mixed $imagick, string $path, int $quality): ?bool
{
if (! $this->ready) {
return null;
@ -83,7 +83,7 @@ class ImagickDriver extends DefaultDriver
}
}
public function resize(/* mixed */ $imagick, int $maxW, int $maxH) /* : mixed */
public function resize(mixed $imagick, int $maxW, int $maxH): mixed
{
if (! $this->ready) {
throw new FileException('ImageMagick library not enabled');
@ -124,7 +124,7 @@ class ImagickDriver extends DefaultDriver
}
}
public function destroy(/* mixed */ $imagick): void
public function destroy(mixed $imagick): void
{
}
}

View file

@ -11,50 +11,38 @@ declare(strict_types=1);
namespace ForkBB\Core;
use ForkBB\Core\Container;
use Psr\SimpleCache\CacheInterface;
use InvalidArgumentException;
use RuntimeException;
class Lang
{
/**
* Контейнер
* @var Container
*/
protected $c;
/**
* @var Psr\SimpleCache\CacheInterface
*/
protected $cache;
protected CacheInterface $cache;
/**
* Массив переводов
* @var array
*/
protected $tr = [];
protected array $tr = [];
/**
* Загруженные переводы
* @var array
*/
protected $loaded = [];
protected array $loaded = [];
/**
* Порядок перебора языка
* @var array
*/
protected $langOrder = [];
protected array $langOrder = [];
/**
* @var string
* Имя текущего загружаемого языкового файла в формате lang/name.po
*/
protected $cur;
protected string $cur;
/**
* Список операторов для вычисления Plural Forms
* @var array
*/
protected $oprtrs = [
protected array $oprtrs = [
'**' => [23, true , 2], // возведение в степень
'!' => [20, false, 1],
'*' => [19, false, 2],
@ -88,20 +76,19 @@ class Lang
];
/**
* @var array
* Список преобразованных формул Plural Forms
*/
protected $pluralCashe = [];
protected array $pluralCashe = [];
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
$this->cache = $container->Cache;
$this->cache = $c->Cache;
}
/**
* Ищет сообщение в загруженных переводах
*/
public function get(string $message, string $lang = null) /* : null|string|array */
public function get(string $message, string $lang = null): null|string|array
{
if (
null !== $lang
@ -459,7 +446,7 @@ class Lang
/**
* Вычисляет выражение представленное токенами в postfix записи и переменными
*/
protected function calcPostfix(array $postfixList, array $vars = []) /* : mixed */
protected function calcPostfix(array $postfixList, array $vars = []): mixed
{
foreach ($postfixList as $token) {
if (\is_string($token)) {

View file

@ -23,21 +23,14 @@ class Log implements LoggerInterface
{
const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_INVALID_UTF8_SUBSTITUTE | \JSON_THROW_ON_ERROR;
/**
* Контейнер
* @var Container
*/
protected $c;
protected $path;
protected $lineFormat;
protected $timeFormat;
protected string $path;
protected string $lineFormat;
protected string $timeFormat;
protected $resource;
protected $hidePath;
protected string $hidePath;
public function __construct(array $config, Container $c)
public function __construct(array $config, protected Container $c)
{
$this->c = $c;
$this->path = $config['path'] ?? __DIR__ . '/../log/{Y-m-d}.log';
$this->lineFormat = $config['lineFormat'] ?? "%datetime% [%level_name%] %message%\t%context%\n";
$this->timeFormat = $config['timeFormat'] ?? 'Y-m-d H:i:s';

View file

@ -20,21 +20,19 @@ class LogViewer
{
const CACHE_KEY = 'logs_info';
protected $cache;
protected $dir;
protected $namePattern;
protected $linePattern;
protected $typePattern;
protected $resource;
protected $fileList;
protected $hashList;
protected $replName = [
protected string $dir;
protected string $namePattern;
protected string $linePattern;
protected string $typePattern;
protected array $fileList;
protected array $hashList;
protected array $replName = [
'.' => '\\.',
'*' => '.*',
'?' => '.',
'%' => '\\%',
];
protected $replLine = [
protected array $replLine = [
'[' => '\\[',
']' => '\\]',
'%datetime%' => '(?P<datetime>(?=\S)[a-z0-9,\.:/ -]+)',
@ -43,9 +41,8 @@ class LogViewer
'%context%' => '(?P<context>(?:\[.*?\]|{.*?}))',
];
public function __construct(array $config, CacheInterface $cache)
public function __construct(array $config, protected CacheInterface $cache)
{
$this->cache = $cache;
$this->dir = \rtrim(\realpath($config['dir'] ?? __DIR__ . '/../log'), '\\/');
$this->namePattern = $this->toNamePattern($config['pattern'] ?? '*.log');
$this->fileList = $this->getFileList();
@ -53,7 +50,7 @@ class LogViewer
$this->setPatterns($config['lineFormat'] ?? "%datetime% [%level_name%] %message%\t%context%\n");
}
protected function setPatterns($format): void
protected function setPatterns(string $format): void
{
$pos = \strpos($format, '%level_name%');

View file

@ -18,79 +18,22 @@ use function \ForkBB\e;
class Mail
{
/**
* Контейнер
* @var Container
*/
protected $c;
/**
* @var string
*/
protected $folder;
/**
* @var string
*/
protected $language;
/**
* @var string
*/
protected $from;
/**
* @var array
*/
protected $to = [];
/**
* @var array
*/
protected $headers = [];
/**
* @var string
*/
protected $message;
/**
* @var array
*/
protected $smtp;
/**
* @var string
*/
protected $EOL;
/**
* @var Resource
*/
protected string $folder;
protected string $language;
protected string $from;
protected array $to = [];
protected array $headers = [];
protected string $message;
protected array $smtp;
protected string $EOL;
protected $connect;
/**
* var int
*/
protected $auth = 0;
/**
* var int
*/
protected $maxRecipients = 1;
/**
* @var array
*/
protected $tplHeaders = [
protected int $auth = 0;
protected int $maxRecipients = 1;
protected array $tplHeaders = [
'Subject' => true,
'Content-Type' => true,
];
/**
* @var string
*/
protected $response;
protected string $response;
public function __construct(
/* string */ $host,
@ -99,10 +42,8 @@ class Mail
/* string */ $pass,
/* bool */ $ssl,
/* string */ $eol,
Container $c
protected Container $c
) {
$this->c = $c;
if (
\is_string($host)
&& \strlen(\trim($host)) > 0
@ -134,7 +75,7 @@ class Mail
/**
* Валидация email
*/
public function valid(/* mixed */ $email, bool $strict = false, bool $idna = false) /* : string|false */
public function valid(mixed $email, bool $strict = false, bool $idna = false): string|false
{
if (
! \is_string($email)
@ -252,7 +193,7 @@ class Mail
/**
* Задает заголовок To
*/
public function setTo(/* array|string */ $email, string $name = null): Mail
public function setTo(array|string $email, string $name = null): Mail
{
$this->to = [];

View file

@ -15,15 +15,8 @@ use ForkBB\Core\Container;
class Parser extends Parserus
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(int $flag, Container $container)
public function __construct(int $flag, protected Container $c)
{
$this->c = $container;
parent::__construct($flag);
$this->init();
}

View file

@ -26,80 +26,59 @@ class Router
/**
* Массив постоянных маршрутов
* @var array
*/
protected $statical = [];
protected array $statical = [];
/**
* Массив динамических маршрутов
* @var array
*/
protected $dynamic = [];
protected array $dynamic = [];
/**
* Список методов доступа
* @var array
*/
protected $methods = [];
protected array $methods = [];
/**
* Массив для построения ссылок
* @var array
*/
protected $links = [];
/**
* Базовый url сайта
* @var string
*/
protected $baseUrl;
protected array $links = [];
/**
* Host сайта
* @var string
*/
protected $host;
protected string $host;
/**
* Префикс uri
* @var string
*/
protected $prefix;
protected string $prefix;
/**
* Длина префикса в байтах
* @var int
*/
protected $length;
protected int $length;
protected $subSearch = [
protected array $subSearch = [
'/',
'\\',
];
protected $subRepl = [
protected array $subRepl = [
'(_slash_)',
'(_backslash_)',
];
/**
* @var Csrf
*/
protected $csrf;
public function __construct(string $base, Csrf $csrf)
public function __construct(protected string $baseUrl, protected Csrf $csrf)
{
$this->baseUrl = $base;
$this->csrf = $csrf;
$this->host = \parse_url($base, \PHP_URL_HOST);
$this->prefix = \parse_url($base, \PHP_URL_PATH) ?? '';
$this->host = \parse_url($baseUrl, \PHP_URL_HOST);
$this->prefix = \parse_url($baseUrl, \PHP_URL_PATH) ?? '';
$this->length = \strlen($this->prefix);
}
/**
* Проверка url на принадлежность форуму
*/
public function validate(/* mixed */ $url, string $defMarker, array $defArgs = []): string
public function validate(mixed $url, string $defMarker, array $defArgs = []): string
{
if (
\is_string($url)
@ -310,7 +289,7 @@ class Router
/**
* Метод добавляет маршрут
*/
public function add(/* array|string */ $method, string $route, string $handler, string $marker = null): void
public function add(array|string $method, string $route, string $handler, string $marker = null): void
{
if (\is_array($method)) {
foreach ($method as $m) {

View file

@ -15,15 +15,8 @@ use RuntimeException;
abstract class RulesValidator
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
/**

View file

@ -18,13 +18,7 @@ use InvalidArgumentException;
class Secury
{
/**
* Algorithm and salt for hash_hmac
* @var array
*/
protected $hmac;
public function __construct(array $hmac)
public function __construct(protected array $hmac)
{
if (
empty($hmac['salt'])
@ -36,8 +30,6 @@ class Secury
if (! \in_array($hmac['algo'], \hash_hmac_algos(), true)) {
throw new UnexpectedValueException('Algorithm not supported');
}
$this->hmac = $hmac;
}
/**
@ -51,11 +43,8 @@ class Secury
/**
* Обертка для hash_hmac
*/
public function hmac(
string $data,
#[SensitiveParameter]
string $key
): string {
public function hmac(string $data, #[SensitiveParameter] string $key): string
{
if (empty($key)) {
throw new InvalidArgumentException('Key can not be empty');
}
@ -92,7 +81,7 @@ class Secury
* For string: Replacing invalid UTF-8 characters and remove control characters
* For other scalar or null: unchanged
*/
public function replInvalidChars(/* mixed */ $data) /* : mixed */
public function replInvalidChars(mixed $data): mixed
{
if (\is_array($data)) {
return \array_map([$this, 'replInvalidChars'], $data);

View file

@ -15,15 +15,8 @@ use ForkBB\Core\Validator;
class Test
{
/**
* Контейнер
* @var Container
*/
protected $c;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
}
public function beforeValidation(Validator $v): Validator
@ -38,7 +31,7 @@ class Test
return $v;
}
public function vTestCheck(Validator $v, /* mixed */ $value) /* : mixed */
public function vTestCheck(Validator $v, mixed $value): mixed
{
if (null !== $value) {
$v->addError('The :alias contains an invalid value');

View file

@ -19,87 +19,68 @@ use function \ForkBB\__;
class Validator
{
/**
* Контейнер
* @var Container
*/
protected $c;
/**
* Массив валидаторов
* @var array
*/
protected $validators;
protected array $validators;
/**
* Массив правил для текущей проверки данных
* @var array
*/
protected $rules;
protected array $rules;
/**
* Массив результатов проверенных данных
* @var array
*/
protected $result;
protected array $result;
/**
* Массив дополнительных аргументов для валидаторов и конкретных полей/правил
* @var array
*/
protected $arguments;
protected array $arguments;
/**
* Массив сообщений об ошибках для конкретных полей/правил
* @var array
*/
protected $messages;
protected array $messages;
/**
* Массив псевдонимов имен полей для вывода в ошибках
* @var array
*/
protected $aliases;
protected array $aliases;
/**
* Массив ошибок валидации
* @var array
*/
protected $errors;
protected array $errors;
/**
* Массив имен полей для обработки
* @var array
*/
protected $fields;
protected array $fields;
/**
* Массив состояний проверки полей
* @var array
*/
protected $status;
protected array $status;
/**
* Массив входящих данных для обработки
* @var array
*/
protected $raw;
protected ?array $raw;
/**
* Данные для текущей обработки
* @var array
*/
protected $curData;
protected array $curData;
/**
* Флаг ошибки
* @var ?bool
*/
protected $error;
protected ?bool $error = null;
public function __construct(Container $container)
public function __construct(protected Container $c)
{
$this->c = $container;
$this->reset();
}
@ -286,7 +267,7 @@ class Validator
* Проверяет поле согласно заданным правилам
* Возвращает значение запрашиваемого поля
*/
public function __get(string $field) /* : mixed */
public function __get(string $field): mixed
{
if (isset($this->status[$field])) {
return $this->result[$field];
@ -320,7 +301,7 @@ class Validator
/**
* Проверяет значение списком правил
*/
protected function checkValue(/* mixed */ $value, array $rules, string $field) /* : mixed */
protected function checkValue(mixed $value, array $rules, string $field): mixed
{
foreach ($rules as $validator => $attr) {
// данные для обработчика ошибок
@ -346,7 +327,7 @@ class Validator
/**
* Добавляет ошибку
*/
public function addError(/* string|array|null */ $error, string $type = 'v'): void
public function addError(string|array|null $error, string $type = 'v'): void
{
if (empty($vars = \end($this->curData))) {
throw new RuntimeException('The array of variables is empty');
@ -386,7 +367,7 @@ class Validator
/**
* Возвращает дополнительные аргументы
*/
protected function getArguments(string $field, string $rule) /* : mixed */
protected function getArguments(string $field, string $rule): mixed
{
return $this->arguments["{$field}.{$rule}"] ?? $this->arguments[$field] ?? null;
}
@ -461,7 +442,7 @@ class Validator
/**
* Проверяет переменную на отсутсвие содержимого
*/
public function noValue(/* mixed */ $value, bool $withArray = false): bool
public function noValue(mixed $value, bool $withArray = false): bool
{
if (null === $value) {
return true;
@ -484,7 +465,7 @@ class Validator
*
* @return mixed
*/
protected function vAbsent(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vAbsent(Validator $v, mixed $value, string $attr): mixed
{
if (null === $value) {
if (isset($attr[0])) {
@ -497,7 +478,7 @@ class Validator
return $value;
}
protected function vExist(Validator $v, /* mixed */ $value) /* : mixed */
protected function vExist(Validator $v, mixed $value): mixed
{
if (null === $value) {
$this->addError('The :alias not exist');
@ -506,7 +487,7 @@ class Validator
return $value;
}
protected function vRequired(Validator $v, /* mixed */ $value) /* : mixed */
protected function vRequired(Validator $v, mixed $value): mixed
{
if ($this->noValue($value, true)) {
$this->addError('The :alias is required');
@ -517,7 +498,7 @@ class Validator
return $value;
}
protected function vRequiredWith(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vRequiredWith(Validator $v, mixed $value, string $attr): mixed
{
foreach (\explode(',', $attr) as $field) {
if (null !== $this->__get($field)) { // если есть хотя бы одно поле,
@ -532,7 +513,7 @@ class Validator
return $value;
}
protected function vString(Validator $v, /* mixed */ $value, string $attr): ?string
protected function vString(Validator $v, mixed $value, string $attr): ?string
{
if (\is_string($value)) {
if (isset($attr[0])) {
@ -584,7 +565,7 @@ class Validator
return $value;
}
protected function vNumeric(Validator $v, /* mixed */ $value) /* : mixed */
protected function vNumeric(Validator $v, mixed $value): mixed
{
if (\is_numeric($value)) {
$value += 0;
@ -604,7 +585,7 @@ class Validator
return $value;
}
protected function vInteger(Validator $v, /* mixed */ $value) /* : mixed */
protected function vInteger(Validator $v, mixed $value): mixed
{
if (
\is_numeric($value)
@ -627,7 +608,7 @@ class Validator
return $value;
}
protected function vArray(Validator $v, $value, array $attr): ?array
protected function vArray(Validator $v, mixed $value, array $attr): ?array
{
if (
null !== $value
@ -691,7 +672,7 @@ class Validator
}
}
protected function vMin(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vMin(Validator $v, mixed $value, string $attr): mixed
{
if (! \preg_match('%^(-?\d+)(\s*bytes)?$%i', $attr, $matches)) {
throw new InvalidArgumentException('Expected number in attribute');
@ -730,7 +711,7 @@ class Validator
return $value;
}
protected function vMax(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vMax(Validator $v, mixed $value, string $attr): mixed
{
if (! \preg_match('%^(-?\d+)(\s*bytes)?$%i', $attr, $matches)) {
throw new InvalidArgumentException('Expected number in attribute');
@ -785,7 +766,7 @@ class Validator
return $value;
}
protected function vToken(Validator $v, /* mixed */ $value, string $attr, /* mixed */ $args): ?string
protected function vToken(Validator $v, mixed $value, string $attr, mixed $args): ?string
{
if (! \is_array($args)) {
$args = [];
@ -803,7 +784,7 @@ class Validator
return $value;
}
protected function vCheckbox(Validator $v, /* mixed */ $value) /* : mixed */
protected function vCheckbox(Validator $v, mixed $value): mixed
{
if (null === $value) {
$this->addError(null);
@ -820,7 +801,7 @@ class Validator
return $value;
}
protected function vReferer(Validator $v, /* mixed */ $value, string $attr, /* mixed */ $args): string
protected function vReferer(Validator $v, mixed $value, string $attr, mixed $args): string
{
if (! \is_array($args)) {
$args = [];
@ -829,7 +810,7 @@ class Validator
return $this->c->Router->validate($value, $attr, $args);
}
protected function vSame(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vSame(Validator $v, mixed $value, string $attr): mixed
{
if (
$this->getStatus($attr)
@ -857,7 +838,7 @@ class Validator
return $this->vRegex($v, $value, '%[^\x20][\x20][^\x20]%');
}
protected function vIn(Validator $v, /* mixed */ $value, /* string|array */ $attr) /* : mixed */
protected function vIn(Validator $v, mixed $value, string|array $attr): mixed
{
if (! \is_scalar($value)) {
$value = null;
@ -880,7 +861,7 @@ class Validator
return $value;
}
protected function vNotIn(Validator $v, /* mixed */ $value, /* string|array */ $attr) /* : mixed */
protected function vNotIn(Validator $v, mixed $value, string|array $attr): mixed
{
if (! \is_scalar($value)) {
$value = null;
@ -904,7 +885,7 @@ class Validator
}
protected function vFile(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vFile(Validator $v, mixed $value, string $attr): mixed
{
if ($this->noValue($value, true)) {
$this->addError(null);
@ -941,7 +922,7 @@ class Validator
return $value;
}
protected function vImage(Validator $v, /* mixed */ $value, string $attr) /* : mixed */
protected function vImage(Validator $v, mixed $value, string $attr): mixed
{
$value = $this->vFile($v, $value, $attr);
@ -965,7 +946,7 @@ class Validator
return $value;
}
protected function vDate(Validator $v, /* mixed */ $value): ?string
protected function vDate(Validator $v, mixed $value): ?string
{
if ($this->noValue($value)) {
$value = null;

View file

@ -20,7 +20,7 @@ use function \ForkBB\__;
class Install extends Admin
{
const PHP_MIN = '7.3.0';
const PHP_MIN = '8.0.0';
const MYSQL_MIN = '5.5.3';
const SQLITE_MIN = '3.25.0';
const PGSQL_MIN = '10.0';

View file

@ -23,8 +23,8 @@ use function \ForkBB\__;
class Update extends Admin
{
const PHP_MIN = '7.3.0';
const REV_MIN_FOR_UPDATE = 42;
const PHP_MIN = '8.0.0';
const REV_MIN_FOR_UPDATE = 53;
const LATEST_REV_WITH_DB_CHANGES = 53;
const LOCK_NAME = 'lock_update';
const LOCK_TTL = 1800;

View file

@ -62,23 +62,6 @@ $c->FORK_REVISION = 53;
$c->START = $forkStart;
$c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix;
// Temporary crutch for update from rev.48-
try {
$e = $c->DIR_ROOT;
} catch (Exception $e) {
$c->DIR_APP = __DIR__;
$c->DIR_PUBLIC = \realpath(__DIR__ . '/../public');
$c->DIR_CACHE = __DIR__ . '/cache';
$c->DIR_CONFIG = __DIR__ . '/config';
$c->DIR_VIEWS = __DIR__ . '/templates';
$c->DIR_LANG = __DIR__ . '/lang';
$c->DIR_LOG = __DIR__ . '/log';
$c->DATE_FORMATS = ['Y-m-d', 'd M Y', 'Y-m-d', 'Y-d-m', 'd-m-Y', 'm-d-Y', 'M j Y', 'jS M Y'];
$c->TIME_FORMATS = ['H:i:s', 'H:i', 'H:i:s', 'H:i', 'g:i:s a', 'g:i a'];
} finally {
unset($e);
}
$controllers = ['Primary', 'Routing'];
foreach ($controllers as $controller) {

View file

@ -24,7 +24,7 @@
}
],
"require": {
"php": ">=7.3.0",
"php": ">=8.0.0",
"ext-mbstring": "*",
"ext-fileinfo": "*",
"ext-intl" : "*",

View file

@ -12,7 +12,7 @@ No: plugins/extensions system, ...
## Requirements
* PHP 7.3+
* PHP 8.0+
* PHP extensions: pdo, intl, json, mbstring, fileinfo
* PHP extensions (suggests): imagick or gd (for upload avatars and other images), openssl (for send email via smtp server using SSL/TLS)
* A database such as MySQL 5.5.3+ (an extension using the mysqlnd driver must be enabled), SQLite 3.25+, PostgreSQL 10+

View file

@ -4,8 +4,8 @@
$issues = array();
if (!(PHP_VERSION_ID >= 70300)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {