fix: Аннотации типов
This commit is contained in:
parent
69370bdf38
commit
09a61244ca
3 changed files with 22 additions and 19 deletions
23
src/Path.php
23
src/Path.php
|
|
@ -16,7 +16,10 @@ class Path
|
|||
protected array $url = [];
|
||||
protected bool $absolute = false;
|
||||
|
||||
public function __construct(string $path = '')
|
||||
/**
|
||||
* @param string $path Путь (Тип указан в doccomments т.к откудато приходит null)
|
||||
*/
|
||||
public function __construct($path = '')
|
||||
{
|
||||
$this->url = parse_url($path);
|
||||
|
||||
|
|
@ -264,11 +267,10 @@ class Path
|
|||
/**
|
||||
* Обьединяет строки в Path соединяя необходимым разделителем
|
||||
* fixme не обрабатывает параметры урла, решение Path::join(SITE_WWW_PATH) . '?param=pampam'
|
||||
* @param string ...$args
|
||||
* @return string
|
||||
*/
|
||||
static function fromJoin($_rest) {
|
||||
$args = func_get_args();
|
||||
|
||||
static function fromJoin(string ...$args) {
|
||||
$result = [];
|
||||
$parts0 = new Path(array_shift($args));
|
||||
$result [] = $parts0->getParts();
|
||||
|
|
@ -286,29 +288,30 @@ class Path
|
|||
/**
|
||||
* Обьединяет строки в строку пути соединяя необходимым разделителем
|
||||
* fixme не обрабатывает параметры урла, решение Path::join(SITE_WWW_PATH) . '?param=pampam'
|
||||
* @param string ...$args
|
||||
* @return string
|
||||
*/
|
||||
static function join($_rest)
|
||||
static function join(string ...$args)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$path = call_user_func_array([self::class, "fromJoin"], $args);
|
||||
return self::makeUrl($path->url);
|
||||
}
|
||||
|
||||
// Проверка структуры имени файла
|
||||
static function checkName($name, $extension)
|
||||
static function checkName(string $name, string $extension)
|
||||
{
|
||||
return (strlen(pathinfo($name, PATHINFO_FILENAME)) > 0) && (pathinfo($name, PATHINFO_EXTENSION) == $extension);
|
||||
}
|
||||
|
||||
static function isCharName($char)
|
||||
static function isCharName(string $char)
|
||||
{
|
||||
$ch = ord($char);
|
||||
return ((($ch >= ord('a')) && ($ch <= ord('z'))) || (strpos('-._', $char) !== false) || (($ch >= ord('0')) && ($ch <= ord('9'))));
|
||||
}
|
||||
|
||||
// Проверка имени файла
|
||||
static function isName($name) {
|
||||
static function isName(string $name): bool
|
||||
{
|
||||
if (strlen(trim($name)) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -320,7 +323,7 @@ class Path
|
|||
return true;
|
||||
}
|
||||
|
||||
public function isAbsolute()
|
||||
public function isAbsolute(): bool
|
||||
{
|
||||
return $this->absolute;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue