chore: Аннотации к типам

This commit is contained in:
origami11@yandex.ru 2025-10-22 17:48:37 +03:00
parent e2ba6bd46e
commit e5713e9015
28 changed files with 305 additions and 110 deletions

View file

@ -160,6 +160,10 @@ class Path
return false;
}
/**
* Преобразует путь в строку
* @param array{ host?: string, path?: string, query?: string, fragment?: string, scheme?: string, user?: string, pass?: string, port?: int} $path Путь
*/
public static function makeUrl($path): string
{
$slash = (isset($path['host']) && (strlen($path['path']) > 0) && ($path['path'][0] != '/')) ? '/' : '';
@ -231,7 +235,12 @@ class Path
return $path->__toString();
}
// Вычисляет относительный путь в виде строки
/**
* Вычисляет относительный путь в виде строки
* @param string $rpath Путь относительно которого вычисляется относительный путь
* @param string $lpath Путь к которому вычисляется относительный путь
* @return string Относительный путь
*/
static function relative($rpath, $lpath) {
// Нужно проверять диск!!
$self = new Path($rpath);
@ -259,6 +268,7 @@ class Path
/**
* @param string $path
* @return string
*/
public function append($path)
{
@ -300,12 +310,12 @@ class Path
}
// Проверка структуры имени файла
static function checkName(string $name, string $extension)
static function checkName(string $name, string $extension): bool
{
return (strlen(pathinfo($name, PATHINFO_FILENAME)) > 0) && (pathinfo($name, PATHINFO_EXTENSION) == $extension);
}
static function isCharName(string $char)
static function isCharName(string $char): bool
{
$ch = ord($char);
return ((($ch >= ord('a')) && ($ch <= ord('z'))) || (strpos('-._', $char) !== false) || (($ch >= ord('0')) && ($ch <= ord('9'))));
@ -354,10 +364,10 @@ class Path
/**
* Список файлов в директории
*
* @param ?array $allow массив расширений для файлов
* @param array $ignore массив имен пааок которые не нужно обрабатывать
* @param ?string[] $allow массив расширений для файлов
* @param string[] $ignore массив имен пааок которые не нужно обрабатывать
*
* @returnarray
* @return string[]
*/
public function getContent(?array $allow = null, array $ignore = [])
{
@ -368,10 +378,10 @@ class Path
/**
* Обьединяет строки в путь соединяя необходимым разделителем
*
* @param ?array $allow массив расширений разрешеных для файлов
* @param array $ignore массив имен пааок которые не нужно обрабатывать
* @param ?string[] $allow массив расширений разрешеных для файлов
* @param string[] $ignore массив имен папок которые не нужно обрабатывать
*
* @return array
* @return string[]
*/
function getContentRec(?array $allow = null, array $ignore = [])
{
@ -381,7 +391,15 @@ class Path
return $result;
}
// Использовать SPL ???
/**
* Список файлов в директории
*
* @param string $base Базовый путь
* @param ?string[] $allow массив расширений для файлов
* @param string[] $ignore массив имен папок которые не нужно обрабатывать
*
* @return string[]
*/
protected static function fileList(string $base, ?array &$allow, array &$ignore): array
{
if ($base == '') $base = '.';
@ -407,7 +425,7 @@ class Path
return $result;
}
protected static function fileListAll(array &$result, string $base, ?array &$allow, array &$ignore)
protected static function fileListAll(array &$result, string $base, ?array &$allow, array &$ignore): void
{
$files = self::fileList($base, $allow, $ignore);
foreach ($files as $name) {