Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/admin/library/module/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public static function setIni(string $dir, array $arr): bool
return true;
}

public static function getClass(string $uid, string $type = 'event', string $class = null): string
public static function getClass(string $uid, string $type = 'event', ?string $class = null): string
{
$name = parse_name($uid);
if (!is_null($class) && strpos($class, '.')) {
Expand Down Expand Up @@ -557,4 +557,4 @@ public static function getRuntime(string $dir, string $key = ''): mixed
return $runtimeContentArr;
}
}
}
}
2 changes: 1 addition & 1 deletion app/admin/model/AdminLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function desensitization(array|string $data): array|string
* @param string|array|null $data
* @throws Throwable
*/
public function record(string $title = '', string|array $data = null): void
public function record(string $title = '', string|array|null $data = null): void
{
$auth = Auth::instance();
$adminId = $auth->isLogin() ? $auth->id : 0;
Expand Down
4 changes: 2 additions & 2 deletions app/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function action_in_arr(array $arr = []): bool
* @param ?string $background 背景颜色,如:rgb(255,255,255)
* @return string
*/
function build_suffix_svg(string $suffix = 'file', string $background = null): string
function build_suffix_svg(string $suffix = 'file', ?string $background = null): string
{
$suffix = mb_substr(strtoupper($suffix), 0, 4);
$total = unpack('L', hash('adler32', $suffix, true))[1];
Expand Down Expand Up @@ -505,4 +505,4 @@ function keys_to_camel_case(array $array, array $keys = []): array
}
return $result;
}
}
}
8 changes: 4 additions & 4 deletions app/common/controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function initialize(): void
* @param array $header 发送的 header 信息
* @param array $options Response 输出参数
*/
protected function success(string $msg = '', mixed $data = null, int $code = 1, string $type = null, array $header = [], array $options = []): void
protected function success(string $msg = '', mixed $data = null, int $code = 1, ?string $type = null, array $header = [], array $options = []): void
{
$this->result($msg, $data, $code, $type, $header, $options);
}
Expand All @@ -84,7 +84,7 @@ protected function success(string $msg = '', mixed $data = null, int $code = 1,
* @param array $header 发送的 header 信息
* @param array $options Response 输出参数
*/
protected function error(string $msg = '', mixed $data = null, int $code = 0, string $type = null, array $header = [], array $options = []): void
protected function error(string $msg = '', mixed $data = null, int $code = 0, ?string $type = null, array $header = [], array $options = []): void
{
$this->result($msg, $data, $code, $type, $header, $options);
}
Expand All @@ -98,7 +98,7 @@ protected function error(string $msg = '', mixed $data = null, int $code = 0, st
* @param array $header 发送的 header 信息
* @param array $options Response 输出参数
*/
public function result(string $msg, mixed $data = null, int $code = 0, string $type = null, array $header = [], array $options = [])
public function result(string $msg, mixed $data = null, int $code = 0, ?string $type = null, array $header = [], array $options = [])
{
$result = [
'code' => $code,
Expand All @@ -114,4 +114,4 @@ public function result(string $msg, mixed $data = null, int $code = 0, string $t
throw new HttpResponseException($response);
}

}
}
14 changes: 7 additions & 7 deletions app/common/library/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Token
* @param string|null $name
* @return object
*/
public function getDriver(string $name = null): object
public function getDriver(?string $name = null): object
{
if (!is_null($this->handler)) {
return $this->handler;
Expand Down Expand Up @@ -94,10 +94,10 @@ protected function getDefaultDriver(): string
/**
* 获取驱动配置
* @param string|null $name 要获取的配置项,不传递获取完整token配置
* @param null $default
* @param mixed $default
* @return array|string
*/
protected function getConfig(string $name = null, $default = null): array|string
protected function getConfig(?string $name = null, $default = null): array|string
{
if (!is_null($name)) {
return Config::get('buildadmin.token.' . $name, $default);
Expand Down Expand Up @@ -139,10 +139,10 @@ protected function resolveClass(string $type): string
* 获取驱动配置
* @param string $store
* @param string|null $name
* @param null $default
* @param mixed $default
* @return array|string
*/
protected function getStoreConfig(string $store, string $name = null, $default = null): array|string
protected function getStoreConfig(string $store, ?string $name = null, $default = null): array|string
{
if ($config = $this->getConfig("stores.$store")) {
return Arr::get($config, $name, $default);
Expand All @@ -169,7 +169,7 @@ protected function resolveType(string $name): string
* @param int|null $expire
* @return bool
*/
public function set(string $token, string $type, int $user_id, int $expire = null): bool
public function set(string $token, string $type, int $user_id, ?int $expire = null): bool
{
return $this->getDriver()->set($token, $type, $user_id, $expire);
}
Expand Down Expand Up @@ -229,4 +229,4 @@ public function tokenExpirationCheck(array $token): void
throw new TokenExpirationException();
}
}
}
}
2 changes: 1 addition & 1 deletion app/common/library/token/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class Driver
* @param ?int $expire 过期时间
* @return bool
*/
abstract public function set(string $token, string $type, int $userId, int $expire = null): bool;
abstract public function set(string $token, string $type, int $userId, ?int $expire = null): bool;

/**
* 获取 token 的数据
Expand Down
2 changes: 1 addition & 1 deletion app/common/library/token/driver/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(array $options = [])
/**
* @throws Throwable
*/
public function set(string $token, string $type, int $userId, int $expire = null): bool
public function set(string $token, string $type, int $userId, ?int $expire = null): bool
{
if (is_null($expire)) {
$expire = $this->options['expire'];
Expand Down
2 changes: 1 addition & 1 deletion app/common/library/token/driver/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(array $options = [])
/**
* @throws Throwable
*/
public function set(string $token, string $type, int $userId, int $expire = null): bool
public function set(string $token, string $type, int $userId, ?int $expire = null): bool
{
if (is_null($expire)) {
$expire = $this->options['expire'];
Expand Down
6 changes: 3 additions & 3 deletions extend/ba/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Date
* @throws Throwable
* @example $seconds = self::offset('America/Chicago', 'GMT');
*/
public static function offset(string $remote, string $local = null, string|int $now = null): int
public static function offset(string $remote, ?string $local = null, string|int|null $now = null): int
{
if ($local === null) {
// Use the default timezone
Expand Down Expand Up @@ -64,7 +64,7 @@ public static function offset(string $remote, string $local = null, string|int $
* @return bool|array|string associative list of all outputs requested|when only a single output is requested
* @from https://github.com/kohana/ohanzee-helpers/blob/master/src/Date.php
*/
public static function span(int $remote, int $local = null, string $output = 'years,months,weeks,days,hours,minutes,seconds'): bool|array|string
public static function span(int $remote, ?int $local = null, string $output = 'years,months,weeks,days,hours,minutes,seconds'): bool|array|string
{
// Normalize output
$output = trim(strtolower($output));
Expand Down Expand Up @@ -161,7 +161,7 @@ public static function human(int $remote, ?int $local = null): string
* @param int|null $minute 基准分钟,默认为null,即以当前分钟为基准
* @return int 处理后的Unix时间戳
*/
public static function unixTime(string $type = 'day', int $offset = 0, string $position = 'begin', int $year = null, int $month = null, int $day = null, int $hour = null, int $minute = null): int
public static function unixTime(string $type = 'day', int $offset = 0, string $position = 'begin', ?int $year = null, ?int $month = null, ?int $day = null, ?int $hour = null, ?int $minute = null): int
{
$year = is_null($year) ? date('Y') : $year;
$month = is_null($month) ? date('m') : $month;
Expand Down