diff --git a/app/admin/library/module/Server.php b/app/admin/library/module/Server.php index 655aa6258..ef3f263e5 100644 --- a/app/admin/library/module/Server.php +++ b/app/admin/library/module/Server.php @@ -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, '.')) { @@ -557,4 +557,4 @@ public static function getRuntime(string $dir, string $key = ''): mixed return $runtimeContentArr; } } -} \ No newline at end of file +} diff --git a/app/admin/model/AdminLog.php b/app/admin/model/AdminLog.php index fdb62836f..00dcf6fca 100644 --- a/app/admin/model/AdminLog.php +++ b/app/admin/model/AdminLog.php @@ -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; diff --git a/app/common.php b/app/common.php index 27ac5b9fe..f4e3b2159 100644 --- a/app/common.php +++ b/app/common.php @@ -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]; @@ -505,4 +505,4 @@ function keys_to_camel_case(array $array, array $keys = []): array } return $result; } -} \ No newline at end of file +} diff --git a/app/common/controller/Api.php b/app/common/controller/Api.php index c80c4ee05..7c6abd05e 100644 --- a/app/common/controller/Api.php +++ b/app/common/controller/Api.php @@ -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); } @@ -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); } @@ -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, @@ -114,4 +114,4 @@ public function result(string $msg, mixed $data = null, int $code = 0, string $t throw new HttpResponseException($response); } -} \ No newline at end of file +} diff --git a/app/common/library/Token.php b/app/common/library/Token.php index 79bfb1168..dc8f60de4 100644 --- a/app/common/library/Token.php +++ b/app/common/library/Token.php @@ -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; @@ -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); @@ -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); @@ -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); } @@ -229,4 +229,4 @@ public function tokenExpirationCheck(array $token): void throw new TokenExpirationException(); } } -} \ No newline at end of file +} diff --git a/app/common/library/token/Driver.php b/app/common/library/token/Driver.php index e694daba3..85ce40f08 100644 --- a/app/common/library/token/Driver.php +++ b/app/common/library/token/Driver.php @@ -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 的数据 diff --git a/app/common/library/token/driver/Mysql.php b/app/common/library/token/driver/Mysql.php index 8fc43a366..21be40891 100644 --- a/app/common/library/token/driver/Mysql.php +++ b/app/common/library/token/driver/Mysql.php @@ -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']; diff --git a/app/common/library/token/driver/Redis.php b/app/common/library/token/driver/Redis.php index c1a14d3f2..fa9ea8959 100644 --- a/app/common/library/token/driver/Redis.php +++ b/app/common/library/token/driver/Redis.php @@ -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']; diff --git a/extend/ba/Date.php b/extend/ba/Date.php index 869e5aaab..9c168e216 100644 --- a/extend/ba/Date.php +++ b/extend/ba/Date.php @@ -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 @@ -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)); @@ -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;