From 68d123d127fc09416abf3eec4db5e56bc5514005 Mon Sep 17 00:00:00 2001 From: jwj <86849180@qq.com> Date: Sat, 22 Feb 2025 15:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/think/Request.php | 39 +++++++++++++++++------------------- src/think/facade/Request.php | 16 ++++++++------- src/think/response/View.php | 4 ++-- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/think/Request.php b/src/think/Request.php index ecdb8d7f11..1a1e373c69 100644 --- a/src/think/Request.php +++ b/src/think/Request.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare (strict_types=1); namespace think; @@ -988,8 +989,8 @@ public function get(string | array | bool $name = '', $default = null, string | /** * 获取中间件传递的参数 * @access public - * @param string $name 变量名 - * @param mixed $default 默认值 + * @param string|null $name 变量名 + * @param mixed $default 默认值 * @return mixed */ public function middleware(?string $name = null, $default = null) @@ -1078,9 +1079,9 @@ public function patch(string | array | bool $name = '', $default = null, string /** * 获取request变量 * @access public - * @param string|array $name 数据名称 - * @param mixed $default 默认值 - * @param string|array|null $filter 过滤方法 + * @param string|array|bool $name 数据名称 + * @param mixed $default 默认值 + * @param string|array|null $filter 过滤方法 * @return mixed */ public function request(string | array | bool $name = '', $default = null, string | array | null $filter = '') @@ -1095,8 +1096,8 @@ public function request(string | array | bool $name = '', $default = null, strin /** * 获取环境变量 * @access public - * @param string $name 数据名称 - * @param string $default 默认值 + * @param string $name 数据名称 + * @param string|null $default 默认值 * @return mixed */ public function env(string $name = '', ?string $default = null) @@ -1110,8 +1111,8 @@ public function env(string $name = '', ?string $default = null) /** * 获取session数据 * @access public - * @param string $name 数据名称 - * @param string $default 默认值 + * @param string $name 数据名称 + * @param string|null $default 默认值 * @return mixed */ public function session(string $name = '', $default = null) @@ -1125,9 +1126,9 @@ public function session(string $name = '', $default = null) /** * 获取cookie参数 * @access public - * @param mixed $name 数据名称 - * @param string $default 默认值 - * @param string|array|null $filter 过滤方法 + * @param mixed $name 数据名称 + * @param string|null $default 默认值 + * @param string|array|null $filter 过滤方法 * @return mixed */ public function cookie(string $name = '', $default = null, string | array | null $filter = '') @@ -1259,8 +1260,8 @@ protected function throwUploadFileError($error) /** * 设置或者获取当前的Header * @access public - * @param string $name header名称 - * @param string $default 默认值 + * @param string $name header名称 + * @param string|null $default 默认值 * @return string|array|null */ public function header(string $name = '', ?string $default = null) @@ -2208,11 +2209,7 @@ public function offsetGet(mixed $name): mixed return $this->param($name); } - public function offsetSet(mixed $name, mixed $value): void - { - } + public function offsetSet(mixed $name, mixed $value): void {} - public function offsetUnset(mixed $name): void - { - } + public function offsetUnset(mixed $name): void {} } diff --git a/src/think/facade/Request.php b/src/think/facade/Request.php index b4a7b0dd5a..afc60df87a 100644 --- a/src/think/facade/Request.php +++ b/src/think/facade/Request.php @@ -58,18 +58,18 @@ * @method static \think\Request setRoute(array $route) 设置路由变量 * @method static mixed route(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取路由参数 * @method static mixed get(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取GET参数 - * @method static mixed middleware(mixed $name, mixed $default = null) 获取中间件传递的参数 + * @method static mixed middleware(string|null $name, mixed $default = null) 获取中间件传递的参数 * @method static mixed post(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取POST参数 * @method static mixed put(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取PUT参数 * @method static mixed delete(mixed $name = '', mixed $default = null, string|array|null $filter = '') 设置获取DELETE参数 * @method static mixed patch(mixed $name = '', mixed $default = null, string|array|null $filter = '') 设置获取PATCH参数 - * @method static mixed request(string|array $name = '', mixed $default = null, string|array|null $filter = '') 获取request变量 - * @method static mixed env(string $name = '', string $default = null) 获取环境变量 - * @method static mixed session(string $name = '', string $default = null) 获取session数据 - * @method static mixed cookie(mixed $name = '', string $default = null, string|array|null $filter = '') 获取cookie参数 + * @method static mixed request(string|array|bool $name = '', mixed $default = null, string|array|null $filter = '') 获取request变量 + * @method static mixed env(string $name = '', string|null $default = null) 获取环境变量 + * @method static mixed session(string $name = '', string|null $default = null) 获取session数据 + * @method static mixed cookie(mixed $name = '', string|null $default = null, string|array|null $filter = '') 获取cookie参数 * @method static mixed server(string $name = '', string $default = '') 获取server参数 * @method static null|array|UploadedFile file(string $name = '') 获取上传的文件信息 - * @method static string|array header(string $name = '', string $default = null) 设置或者获取当前的Header + * @method static string|array header(string $name = '', string|null $default = null) 设置或者获取当前的Header * @method static mixed input(array $data = [], string|false $name = '', mixed $default = null, string|array|null $filter = '') 获取变量 支持过滤和默认值 * @method static mixed filter(mixed $filter = null) 设置或获取当前的过滤规则 * @method static mixed filterValue(mixed &$value, mixed $key, array $filters) 递归过滤给定的值 @@ -93,9 +93,11 @@ * @method static int remotePort() 当前请求 REMOTE_PORT * @method static string contentType() 当前请求 HTTP_CONTENT_TYPE * @method static string secureKey() 获取当前请求的安全Key + * @method static \think\Request setLayer(string $layer) 设置当前的分层名 * @method static \think\Request setController(string $controller) 设置当前的控制器名 * @method static \think\Request setAction(string $action) 设置当前的操作名 - * @method static string controller(bool $convert = false) 获取当前的控制器名 + * @method static string layer(bool $convert = false) 获取当前的模块名 + * @method static string controller(bool $convert = false, bool $base = false) 获取当前的控制器名 * @method static string action(bool $convert = false) 获取当前的操作名 * @method static string getContent() 设置或者获取当前请求的content * @method static string getInput() 获取当前请求的php://input diff --git a/src/think/response/View.php b/src/think/response/View.php index 8102ced4ad..42d434da4c 100644 --- a/src/think/response/View.php +++ b/src/think/response/View.php @@ -95,7 +95,7 @@ protected function output($data): string /** * 获取视图变量 * @access public - * @param string $name 模板变量 + * @param string|null $name 模板变量 * @return mixed */ public function getVars(?string $name = null) @@ -128,7 +128,7 @@ public function assign(string|array $name, $value = null) /** * 视图内容过滤 * @access public - * @param callable $filter + * @param callable|null $filter * @return $this */ public function filter(?callable $filter = null)