提交的内容
This commit is contained in:
67
vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml
vendored
Normal file
67
vendor/topthink/framework/.github/ISSUE_TEMPLATE/1-bug-report.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
name: Bug 反馈
|
||||
description: 反馈您所遇到的问题,以帮助我们更好的改进
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: addon
|
||||
attributes:
|
||||
label: 所属功能组件
|
||||
options:
|
||||
- 路由(Route)
|
||||
- 控制器(Controller)
|
||||
- 中间件(Middleware)
|
||||
- 容器(Container)
|
||||
- 服务(Service)
|
||||
- 门面(Facade)
|
||||
- 事件(Event)
|
||||
- 请求(Request)
|
||||
- 缓存(Cache)
|
||||
- 响应(Response)
|
||||
- 视图(View)
|
||||
- 异常(Exception)
|
||||
- 日志(Log)
|
||||
- 验证器(Validate)
|
||||
- 多语言(Lang)
|
||||
- Session/Cookie
|
||||
- 文件系统(Filesystem)
|
||||
- 命令行(Command)
|
||||
- 其它
|
||||
description: |
|
||||
* 模型(Model)和数据库(Db)功能请前往 https://github.com/top-think/think-orm/issues 反馈
|
||||
* 多应用(MultiApp)功能请前往 https://github.com/top-think/think-multi-app/issues 反馈
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: ThinkPHP 版本
|
||||
description: 您所使用的 ThinkPHP 版本是?
|
||||
placeholder: 如:8.0.3
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: system
|
||||
attributes:
|
||||
label: 操作系统
|
||||
description: 您代码在什么系统上运行?
|
||||
placeholder: 如:Windows、Centos、Ubuntu、Debian
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 错误信息
|
||||
description: 如果有报错信息,请附上相关错误信息或截图。如:错误提示语、出错文件路径、出错行号和 Traces 等信息
|
||||
placeholder: |
|
||||
信息:控制器不存在
|
||||
路径:vendor/topthink/framework/src/think/App.php
|
||||
行号:313
|
||||
Traces:
|
||||
......
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 其它说明
|
||||
description: 如您还有其它需要补充,可在此输入。
|
||||
validations:
|
||||
required: false
|
||||
20
vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md
vendored
Normal file
20
vendor/topthink/framework/.github/ISSUE_TEMPLATE/2-feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
name: 功能请求
|
||||
about: 您对 ThinkPHP 有什么改进的想法或建议,可在此提出。
|
||||
title: ''
|
||||
labels: 'enhancement'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**您的功能请求与问题相关吗?**
|
||||
[是的话请在此描述]
|
||||
|
||||
**描述您想要的解决方案**
|
||||
[有的话请在此描述]
|
||||
|
||||
**描述您考虑过的替代方案**
|
||||
[有的话请在此描述]
|
||||
|
||||
**其它信息**
|
||||
[其它相关信息或截图]
|
||||
10
vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md
vendored
Normal file
10
vendor/topthink/framework/.github/ISSUE_TEMPLATE/3-custom.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: 其它问题
|
||||
about: 其它问题可在此反馈
|
||||
title: ''
|
||||
labels: 'question'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
8
vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
vendor/topthink/framework/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: ThinkPHP 完全开发手册
|
||||
url: https://doc.thinkphp.cn/
|
||||
about: 在创建 Issue 之前,请仔细查阅开发手册,以便对其有更深入的了解,和更好地分析问题。
|
||||
- name: ThinkPHP 轻社区
|
||||
url: https://q.thinkphp.cn/
|
||||
about: 欢迎来到ThinkPHP轻社区和大家一起交流。
|
||||
4
vendor/topthink/framework/.github/workflows/build.yml
vendored
Executable file → Normal file
4
vendor/topthink/framework/.github/workflows/build.yml
vendored
Executable file → Normal file
@ -3,7 +3,7 @@ name: build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "8.0"
|
||||
- "8.x"
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
@ -15,7 +15,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [8.0, 8.1, 8.2]
|
||||
php: [8.0, 8.1, 8.2, 8.3, 8.4]
|
||||
|
||||
name: PHP ${{ matrix.php }}
|
||||
|
||||
|
||||
31
vendor/topthink/framework/.github/workflows/php-cs-fixer.yml
vendored
Normal file
31
vendor/topthink/framework/.github/workflows/php-cs-fixer.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: PHP CS Fixer
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "8.x"
|
||||
paths:
|
||||
- '**.php'
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 10
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
tools: cs2pr,php-cs-fixer
|
||||
|
||||
- name: Run PHP CS Fixer
|
||||
run: |
|
||||
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- '*.php')
|
||||
for file in $changed_files; do
|
||||
php-cs-fixer fix "$file" --dry-run --diff --rules=@PER-CS2.0 --format=checkstyle | cs2pr
|
||||
done
|
||||
0
vendor/topthink/framework/.gitignore
vendored
Executable file → Normal file
0
vendor/topthink/framework/.gitignore
vendored
Executable file → Normal file
16
vendor/topthink/framework/CONTRIBUTING.md
vendored
Executable file → Normal file
16
vendor/topthink/framework/CONTRIBUTING.md
vendored
Executable file → Normal file
@ -19,11 +19,11 @@ ThinkPHP 目前使用 Git 来控制程序版本,如果你想为 ThinkPHP 贡
|
||||
|
||||
### 注意事项
|
||||
|
||||
* 本项目代码格式化标准选用 [**PSR-2**](http://www.kancloud.cn/thinkphp/php-fig-psr/3141);
|
||||
* 本项目代码格式化标准选用 [**PER-CS2.0**](https://cs.symfony.com/doc/ruleSets/PER-CS2.0.html);
|
||||
* 类名和类文件名遵循 [**PSR-4**](http://www.kancloud.cn/thinkphp/php-fig-psr/3144);
|
||||
* 对于 Issues 的处理,请使用诸如 `fix #xxx(Issue ID)` 的 commit title 直接关闭 issue。
|
||||
* 系统会自动在 PHP 7.1 ~ 7.3 上测试修改,请确保你的修改符合 PHP 7.1 ~ 7.3 的语法规范;
|
||||
* 管理员不会合并造成 CI faild 的修改,若出现 CI faild 请检查自己的源代码或修改相应的[单元测试文件](tests);
|
||||
* 系统会自动在 PHP 8.0 ~ 8.3 版本上测试修改,请确保你的修改符合 PHP 版本的语法规范;
|
||||
* 管理员不会合并造成 CI Failed 的修改,若出现 CI Failed 请检查自己的源代码或修改相应的[单元测试文件](tests);
|
||||
|
||||
## GitHub Issue
|
||||
|
||||
@ -77,14 +77,14 @@ GitHub 提供了 Issue 功能,该功能可以用于:
|
||||
|
||||
### 开发环境
|
||||
|
||||
* XAMPP for Windows 5.5.x
|
||||
* WampServer (for Windows)
|
||||
* upupw Apache PHP5.4 ( for Windows)
|
||||
* [XAMPP](https://www.apachefriends.org/zh_cn/download.html) - Windows、Linux、Mac OS
|
||||
* [WampServer](https://www.apachefriends.org/zh_cn/download.html) - Windows
|
||||
* Docker - Windows、Linux、Mac OS
|
||||
|
||||
或自行安装
|
||||
|
||||
- Apache / Nginx
|
||||
- PHP 7.1 ~ 7.3
|
||||
- PHP 8.0 ~ 8.3
|
||||
- MySQL / MariaDB
|
||||
|
||||
*Windows 用户推荐添加 PHP bin 目录到 PATH,方便使用 composer*
|
||||
@ -109,7 +109,7 @@ phpfmt 插件参数
|
||||
}
|
||||
```
|
||||
|
||||
或其他 编辑器 / IDE 配合 PSR2 自动格式化工具
|
||||
或其他 编辑器 / IDE 配合自动格式化工具
|
||||
|
||||
### Git GUI
|
||||
|
||||
|
||||
0
vendor/topthink/framework/LICENSE.txt
vendored
Executable file → Normal file
0
vendor/topthink/framework/LICENSE.txt
vendored
Executable file → Normal file
50
vendor/topthink/framework/README.md
vendored
Executable file → Normal file
50
vendor/topthink/framework/README.md
vendored
Executable file → Normal file
@ -1,11 +1,8 @@
|
||||

|
||||
|
||||
ThinkPHP 8.0
|
||||
===============
|
||||
# ThinkPHP 8
|
||||
|
||||
[](https://github.com/top-think/framework/actions)
|
||||
[](https://scrutinizer-ci.com/g/top-think/framework/?branch=8.0)
|
||||
[](https://scrutinizer-ci.com/g/top-think/framework/?branch=8.0)
|
||||
[](https://packagist.org/packages/topthink/framework)
|
||||
[](https://packagist.org/packages/topthink/framework)
|
||||
[](http://www.php.net/)
|
||||
@ -13,28 +10,30 @@ ThinkPHP 8.0
|
||||
|
||||
## 主要特性
|
||||
|
||||
* 基于PHP`8.0+`重构
|
||||
* 升级`PSR`依赖
|
||||
* 依赖`think-orm`3.0版本
|
||||
* `6.0`/`6.1`无缝升级
|
||||
- 基于 PHP`8.0+`重构
|
||||
- 升级`PSR`依赖
|
||||
- 依赖`think-orm`3.0+ 版本
|
||||
- 全新的`think-dumper`支持远程调试
|
||||
- `6.0`/`6.1`无缝升级
|
||||
|
||||
> ThinkPHP8 的运行环境要求 PHP8.0+
|
||||
|
||||
> ThinkPHP8.0的运行环境要求PHP8.0.0+
|
||||
|
||||
现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务!
|
||||
现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习 ThinkPHP 的旅途中享受私人 AI 助理服务!
|
||||
|
||||
[](https://chat.topthink.com/)
|
||||
|
||||
ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。
|
||||
ThinkPHP 生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。
|
||||
|
||||
## 文档
|
||||
|
||||
[完全开发手册](https://doc.thinkphp.cn)
|
||||
|
||||
基于官方手册的数据训练和提供精准解答服务
|
||||
[官方专家智能体](https://chat.topthink.com/chat/eorole)
|
||||
|
||||
## 赞助商
|
||||
|
||||
全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。
|
||||
全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及 GIT 仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障 ThinkPHP 的可持续发展。
|
||||
|
||||
[](https://www.thinkphp.cn/sponsor/special)
|
||||
|
||||
@ -42,43 +41,44 @@ ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)
|
||||
|
||||
## 安装
|
||||
|
||||
~~~
|
||||
```
|
||||
composer create-project topthink/think tp
|
||||
~~~
|
||||
```
|
||||
|
||||
启动服务
|
||||
|
||||
~~~
|
||||
```
|
||||
cd tp
|
||||
php think run
|
||||
~~~
|
||||
```
|
||||
|
||||
然后就可以在浏览器中访问
|
||||
|
||||
~~~
|
||||
```
|
||||
http://localhost:8000
|
||||
~~~
|
||||
```
|
||||
|
||||
如果需要更新框架使用
|
||||
~~~
|
||||
|
||||
```
|
||||
composer update topthink/framework
|
||||
~~~
|
||||
```
|
||||
|
||||
## 命名规范
|
||||
|
||||
`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。
|
||||
`ThinkPHP`遵循 PSR-2 命名规范和 PSR-4 自动加载规范。
|
||||
|
||||
## 参与开发
|
||||
|
||||
直接提交PR或者Issue即可
|
||||
直接提交 PR 或者 Issue 即可
|
||||
|
||||
## 版权信息
|
||||
|
||||
ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
|
||||
ThinkPHP 遵循 Apache2 开源协议发布,并提供免费使用。
|
||||
|
||||
本项目包含的第三方源码和二进制文件之版权信息另行标注。
|
||||
|
||||
版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。
|
||||
版权所有 Copyright © 2006-2024 by ThinkPHP (http://thinkphp.cn) All rights reserved。
|
||||
|
||||
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
|
||||
|
||||
|
||||
11
vendor/topthink/framework/composer.json
vendored
Executable file → Normal file
11
vendor/topthink/framework/composer.json
vendored
Executable file → Normal file
@ -22,12 +22,14 @@
|
||||
"php": ">=8.0.0",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-ctype": "*",
|
||||
"psr/log": "^1.0|^2.0|^3.0",
|
||||
"psr/container": "^2.0",
|
||||
"psr/simple-cache": "^1.0|^2.0|^3.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"topthink/think-orm": "^3.0",
|
||||
"topthink/think-helper": "^3.1"
|
||||
"topthink/think-orm": "^3.0|^4.0",
|
||||
"topthink/think-helper": "^3.1",
|
||||
"topthink/think-container": "^3.0",
|
||||
"topthink/think-validate": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
@ -50,5 +52,8 @@
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"scripts": {
|
||||
"php-cs-fixer": "php-cs-fixer fix src/ --rules=@PER-CS2.0 --dry-run --diff"
|
||||
}
|
||||
}
|
||||
|
||||
0
vendor/topthink/framework/logo.png
vendored
Executable file → Normal file
0
vendor/topthink/framework/logo.png
vendored
Executable file → Normal file
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
0
vendor/topthink/framework/phpunit.xml.dist
vendored
Executable file → Normal file
0
vendor/topthink/framework/phpunit.xml.dist
vendored
Executable file → Normal file
21
vendor/topthink/framework/src/helper.php
vendored
Executable file → Normal file
21
vendor/topthink/framework/src/helper.php
vendored
Executable file → Normal file
@ -2,13 +2,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
//------------------------
|
||||
// ThinkPHP 助手函数
|
||||
@ -37,6 +37,7 @@ use think\response\View;
|
||||
use think\response\Xml;
|
||||
use think\route\Url as UrlBuild;
|
||||
use think\Validate;
|
||||
use think\validate\ValidateRuleSet;
|
||||
|
||||
if (!function_exists('abort')) {
|
||||
/**
|
||||
@ -92,7 +93,7 @@ if (!function_exists('cache')) {
|
||||
* @param string $tag 缓存标签
|
||||
* @return mixed
|
||||
*/
|
||||
function cache(string $name = null, $value = '', $options = null, $tag = null)
|
||||
function cache(?string $name = null, $value = '', $options = null, $tag = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
return app('cache');
|
||||
@ -211,7 +212,7 @@ if (!function_exists('env')) {
|
||||
* @param string $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
function env(string $name = null, $default = null)
|
||||
function env(?string $name = null, $default = null)
|
||||
{
|
||||
return Env::get($name, $default);
|
||||
}
|
||||
@ -540,6 +541,18 @@ if (!function_exists('validate')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('rules')) {
|
||||
/**
|
||||
* 定义ValidateRuleSet规则集合
|
||||
* @param array $rules 验证因子集
|
||||
* @return ValidateRuleSet
|
||||
*/
|
||||
function rules(array $rules): ValidateRuleSet
|
||||
{
|
||||
return ValidateRuleSet::rules($rules);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('view')) {
|
||||
/**
|
||||
* 渲染模板输出
|
||||
|
||||
9
vendor/topthink/framework/src/lang/zh-cn.php
vendored
Executable file → Normal file
9
vendor/topthink/framework/src/lang/zh-cn.php
vendored
Executable file → Normal file
@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -101,6 +102,7 @@ return [
|
||||
':attribute must be integer' => ':attribute必须是整数',
|
||||
':attribute must be float' => ':attribute必须是浮点数',
|
||||
':attribute must be string' => ':attribute必须是字符串',
|
||||
':attribute must be :rule enum' => ':attribute必须是有效的 :rule 枚举',
|
||||
':attribute must start with :rule' => ':attribute必须以 :rule 开头',
|
||||
':attribute must end with :rule' => ':attribute必须以 :rule 结尾',
|
||||
':attribute must contain :rule' => ':attribute必须包含 :rule',
|
||||
@ -108,7 +110,8 @@ return [
|
||||
':attribute not a valid email address' => ':attribute格式不符',
|
||||
':attribute not a valid mobile' => ':attribute格式不符',
|
||||
':attribute must be a array' => ':attribute必须是数组',
|
||||
':attribute must be yes,on or 1' => ':attribute必须是yes、on或者1',
|
||||
':attribute must be yes,on,true or 1' => ':attribute必须是yes、on、true或者1',
|
||||
':attribute must be no,off,false or 0' => ':attribute必须是no、off、false或者0',
|
||||
':attribute not a valid datetime' => ':attribute不是一个有效的日期或时间格式',
|
||||
':attribute not a valid file' => ':attribute不是有效的上传文件',
|
||||
':attribute not a valid image' => ':attribute不是有效的图像文件',
|
||||
@ -142,8 +145,10 @@ return [
|
||||
':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule',
|
||||
':attribute must less than :rule' => ':attribute必须小于 :rule',
|
||||
':attribute must equal :rule' => ':attribute必须等于 :rule',
|
||||
':attribute must not be equal to :rule' => ':attribute不能等于 :rule',
|
||||
':attribute has exists' => ':attribute已存在',
|
||||
':attribute not conform to the rules' => ':attribute不符合指定规则',
|
||||
':attribute must multiple :rule' => ':attribute必须是 :rule 的倍数',
|
||||
'invalid Request method' => '无效的请求类型',
|
||||
'invalid token' => '令牌数据无效',
|
||||
'not conform to the rules' => '规则错误',
|
||||
|
||||
41
vendor/topthink/framework/src/think/App.php
vendored
Executable file → Normal file
41
vendor/topthink/framework/src/think/App.php
vendored
Executable file → Normal file
@ -2,13 +2,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
@ -39,6 +39,10 @@ use think\initializer\RegisterService;
|
||||
*/
|
||||
class App extends Container
|
||||
{
|
||||
/**
|
||||
* 核心框架版本
|
||||
* @deprecated 已经废弃 请改用version()方法
|
||||
*/
|
||||
const VERSION = '8.0.0';
|
||||
|
||||
/**
|
||||
@ -47,6 +51,12 @@ class App extends Container
|
||||
*/
|
||||
protected $appDebug = false;
|
||||
|
||||
/**
|
||||
* 公共环境变量标识
|
||||
* @var string
|
||||
*/
|
||||
protected $baseEnvName = '';
|
||||
|
||||
/**
|
||||
* 环境变量标识
|
||||
* @var string
|
||||
@ -189,7 +199,7 @@ class App extends Container
|
||||
* @param bool $force 强制重新注册
|
||||
* @return Service|null
|
||||
*/
|
||||
public function register(Service|string $service, bool $force = false)
|
||||
public function register(Service | string $service, bool $force = false)
|
||||
{
|
||||
$registered = $this->getService($service);
|
||||
|
||||
@ -230,7 +240,7 @@ class App extends Container
|
||||
* @param string|Service $service
|
||||
* @return Service|null
|
||||
*/
|
||||
public function getService(Service|string $service): ?Service
|
||||
public function getService(Service | string $service): ?Service
|
||||
{
|
||||
$name = is_string($service) ? $service : $service::class;
|
||||
return array_values(array_filter($this->services, function ($value) use ($name) {
|
||||
@ -282,6 +292,18 @@ class App extends Container
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置公共环境变量标识
|
||||
* @access public
|
||||
* @param string $name 环境标识
|
||||
* @return $this
|
||||
*/
|
||||
public function setBaseEnvName(string $name)
|
||||
{
|
||||
$this->baseEnvName = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置环境变量标识
|
||||
* @access public
|
||||
@ -440,6 +462,12 @@ class App extends Container
|
||||
$this->beginTime = microtime(true);
|
||||
$this->beginMem = memory_get_usage();
|
||||
|
||||
// 加载环境变量
|
||||
if ($this->baseEnvName) {
|
||||
$this->loadEnv($this->baseEnvName);
|
||||
}
|
||||
|
||||
$this->envName = $this->envName ?: (string) $this->env->get('env_name', '');
|
||||
$this->loadEnv($this->envName);
|
||||
|
||||
$this->configExt = $this->env->get('config_ext', '.php');
|
||||
@ -546,6 +574,9 @@ class App extends Container
|
||||
// 应用调试模式
|
||||
if (!$this->appDebug) {
|
||||
$this->appDebug = $this->env->get('app_debug') ? true : false;
|
||||
}
|
||||
|
||||
if (!$this->appDebug) {
|
||||
ini_set('display_errors', 'Off');
|
||||
}
|
||||
|
||||
@ -579,7 +610,7 @@ class App extends Container
|
||||
|
||||
if (isset($event['subscribe'])) {
|
||||
$this->event->subscribe($event['subscribe']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
vendor/topthink/framework/src/think/Cache.php
vendored
Executable file → Normal file
8
vendor/topthink/framework/src/think/Cache.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -46,7 +46,7 @@ class Cache extends Manager implements CacheInterface
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null)
|
||||
public function getConfig(?string $name = null, $default = null)
|
||||
{
|
||||
if (!is_null($name)) {
|
||||
return $this->app->config->get('cache.' . $name, $default);
|
||||
@ -62,7 +62,7 @@ class Cache extends Manager implements CacheInterface
|
||||
* @param mixed $default
|
||||
* @return array
|
||||
*/
|
||||
public function getStoreConfig(string $store, string $name = null, $default = null)
|
||||
public function getStoreConfig(string $store, ?string $name = null, $default = null)
|
||||
{
|
||||
if ($config = $this->getConfig("stores.{$store}")) {
|
||||
return Arr::get($config, $name, $default);
|
||||
@ -87,7 +87,7 @@ class Cache extends Manager implements CacheInterface
|
||||
* @param string|null $name 连接配置名
|
||||
* @return Driver
|
||||
*/
|
||||
public function store(string $name = null)
|
||||
public function store(?string $name = null)
|
||||
{
|
||||
return $this->driver($name);
|
||||
}
|
||||
|
||||
72
vendor/topthink/framework/src/think/Config.php
vendored
Executable file → Normal file
72
vendor/topthink/framework/src/think/Config.php
vendored
Executable file → Normal file
@ -2,16 +2,18 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* 配置管理类
|
||||
* @package think
|
||||
@ -24,6 +26,12 @@ class Config
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* 注册配置获取器
|
||||
* @var Closure
|
||||
*/
|
||||
protected $hook;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
@ -74,11 +82,11 @@ class Config
|
||||
$type = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$config = [];
|
||||
$config = match ($type) {
|
||||
'php' => include $file,
|
||||
'yml','yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [],
|
||||
'ini' => parse_ini_file($file, true, INI_SCANNER_TYPED) ?: [],
|
||||
'json' => json_decode(file_get_contents($file), true),
|
||||
default => [],
|
||||
'php' => include $file,
|
||||
'yml', 'yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [],
|
||||
'ini' => parse_ini_file($file, true, INI_SCANNER_TYPED) ?: [],
|
||||
'json' => json_decode(file_get_contents($file), true),
|
||||
default => [],
|
||||
};
|
||||
|
||||
return is_array($config) ? $this->set($config, strtolower($name)) : [];
|
||||
@ -107,11 +115,20 @@ class Config
|
||||
*/
|
||||
protected function pull(string $name): array
|
||||
{
|
||||
$name = strtolower($name);
|
||||
|
||||
return $this->config[$name] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册配置获取器
|
||||
* @access public
|
||||
* @param Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function hook(Closure $callback)
|
||||
{
|
||||
$this->hook = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置参数 为空则获取所有配置
|
||||
* @access public
|
||||
@ -119,7 +136,7 @@ class Config
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $name = null, $default = null)
|
||||
public function get(?string $name = null, $default = null)
|
||||
{
|
||||
// 无参数时获取所有
|
||||
if (empty($name)) {
|
||||
@ -127,23 +144,42 @@ class Config
|
||||
}
|
||||
|
||||
if (!str_contains($name, '.')) {
|
||||
return $this->pull($name);
|
||||
$name = strtolower($name);
|
||||
$result = $this->pull($name);
|
||||
return $this->hook ? $this->lazy($name, $result, []) : $result;
|
||||
}
|
||||
|
||||
$name = explode('.', $name);
|
||||
$name[0] = strtolower($name[0]);
|
||||
$item = explode('.', $name);
|
||||
$item[0] = strtolower($item[0]);
|
||||
$config = $this->config;
|
||||
|
||||
// 按.拆分成多维数组进行判断
|
||||
foreach ($name as $val) {
|
||||
foreach ($item as $val) {
|
||||
if (isset($config[$val])) {
|
||||
$config = $config[$val];
|
||||
} else {
|
||||
return $default;
|
||||
return $this->hook ? $this->lazy($name, null, $default) : $default;
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
return $this->hook ? $this->lazy($name, $config, $default) : $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过获取器加载配置
|
||||
* @access public
|
||||
* @param string $name 配置参数
|
||||
* @param mixed $value 配置值
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
protected function lazy(?string $name, $value = null, $default = null)
|
||||
{
|
||||
// 通过获取器返回
|
||||
$result = call_user_func_array($this->hook, [$name, $value]);
|
||||
if (is_null($result)) {
|
||||
return $default;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,7 +189,7 @@ class Config
|
||||
* @param string $name 配置名
|
||||
* @return array
|
||||
*/
|
||||
public function set(array $config, string $name = null): array
|
||||
public function set(array $config, ?string $name = null): array
|
||||
{
|
||||
if (empty($name)) {
|
||||
$this->config = array_merge($this->config, array_change_key_case($config));
|
||||
|
||||
10
vendor/topthink/framework/src/think/Console.php
vendored
Executable file → Normal file
10
vendor/topthink/framework/src/think/Console.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | TopThink [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2015 http://www.topthink.com All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://www.topthink.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: zhangyajun <448901948@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
@ -93,6 +93,12 @@ class Console
|
||||
//加载指令
|
||||
$this->loadCommands();
|
||||
|
||||
// 设置执行用户
|
||||
$user = $this->app->config->get('console.user');
|
||||
if (!empty($user)) {
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
$this->start();
|
||||
}
|
||||
|
||||
@ -590,7 +596,7 @@ class Console
|
||||
* @return Command[]
|
||||
* @api
|
||||
*/
|
||||
public function all(string $namespace = null): array
|
||||
public function all(?string $namespace = null): array
|
||||
{
|
||||
if (null === $namespace) {
|
||||
return $this->commands;
|
||||
|
||||
17
vendor/topthink/framework/src/think/Cookie.php
vendored
Executable file → Normal file
17
vendor/topthink/framework/src/think/Cookie.php
vendored
Executable file → Normal file
@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace think;
|
||||
|
||||
@ -51,7 +52,7 @@ class Cookie
|
||||
*/
|
||||
public function __construct(protected Request $request, array $config = [])
|
||||
{
|
||||
$this->config = array_merge($this->config, array_change_key_case($config));
|
||||
$this->config = array_merge($this->config, array_change_key_case($config));
|
||||
}
|
||||
|
||||
public static function __make(Request $request, Config $config)
|
||||
@ -111,6 +112,7 @@ class Cookie
|
||||
}
|
||||
|
||||
$this->setCookie($name, $value, $expire, $config);
|
||||
$this->request->setCookie($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,6 +160,7 @@ class Cookie
|
||||
{
|
||||
$config = array_merge($this->config, array_change_key_case($options));
|
||||
$this->setCookie($name, '', time() - 3600, $config);
|
||||
$this->request->setCookie($name, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,14 +184,14 @@ class Cookie
|
||||
[$value, $expire, $option] = $val;
|
||||
|
||||
$this->saveCookie(
|
||||
$name,
|
||||
(string) $name,
|
||||
$value,
|
||||
$expire,
|
||||
$option['path'],
|
||||
$option['domain'],
|
||||
$option['secure'] ? true : false,
|
||||
$option['httponly'] ? true : false,
|
||||
$option['samesite']
|
||||
(bool) $option['secure'],
|
||||
(bool) $option['httponly'],
|
||||
$option['samesite'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/topthink/framework/src/think/Db.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/Db.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
10
vendor/topthink/framework/src/think/Env.php
vendored
Executable file → Normal file
10
vendor/topthink/framework/src/think/Env.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -61,7 +61,7 @@ class Env implements ArrayAccess
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $name = null, $default = null)
|
||||
public function get(?string $name = null, $default = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
return $this->data;
|
||||
@ -115,7 +115,11 @@ class Env implements ArrayAccess
|
||||
foreach ($env as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k => $v) {
|
||||
$this->data[$key . '_' . strtoupper($k)] = $v;
|
||||
if (is_string($k)) {
|
||||
$this->data[$key . '_' . strtoupper($k)] = $v;
|
||||
} else {
|
||||
$this->data[$key][$k] = $v;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->data[$key] = $val;
|
||||
|
||||
36
vendor/topthink/framework/src/think/Event.php
vendored
Executable file → Normal file
36
vendor/topthink/framework/src/think/Event.php
vendored
Executable file → Normal file
@ -2,18 +2,19 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use think\helper\Str;
|
||||
|
||||
/**
|
||||
* 事件管理类
|
||||
@ -27,6 +28,12 @@ class Event
|
||||
*/
|
||||
protected $listener = [];
|
||||
|
||||
/**
|
||||
* 观察者
|
||||
* @var array
|
||||
*/
|
||||
protected $observer = [];
|
||||
|
||||
/**
|
||||
* 事件别名
|
||||
* @var array
|
||||
@ -144,9 +151,9 @@ class Event
|
||||
*/
|
||||
public function subscribe($subscriber)
|
||||
{
|
||||
$subscribers = (array) $subscriber;
|
||||
$subscribers = is_object($subscriber) ? [$subscriber] : (array) $subscriber;
|
||||
|
||||
foreach ($subscribers as $subscriber) {
|
||||
foreach ($subscribers as $name => $subscriber) {
|
||||
if (is_string($subscriber)) {
|
||||
$subscriber = $this->app->make($subscriber);
|
||||
}
|
||||
@ -154,6 +161,9 @@ class Event
|
||||
if (method_exists($subscriber, 'subscribe')) {
|
||||
// 手动订阅
|
||||
$subscriber->subscribe($this);
|
||||
} elseif (!is_numeric($name)) {
|
||||
// 注册观察者
|
||||
$this->observer[$name] = $subscriber;
|
||||
} else {
|
||||
// 智能订阅
|
||||
$this->observe($subscriber);
|
||||
@ -164,7 +174,7 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动注册事件观察者
|
||||
* 自动注册事件监听
|
||||
* @access public
|
||||
* @param string|object $observer 观察者
|
||||
* @param null|string $prefix 事件名前缀
|
||||
@ -218,9 +228,19 @@ class Event
|
||||
$listeners = $this->listener[$event] ?? [];
|
||||
|
||||
if (str_contains($event, '.')) {
|
||||
[$prefix, $event] = explode('.', $event, 2);
|
||||
if (isset($this->listener[$prefix . '.*'])) {
|
||||
$listeners = array_merge($listeners, $this->listener[$prefix . '.*']);
|
||||
[$prefix, $name] = explode('.', $event, 2);
|
||||
if (isset($this->observer[$prefix])) {
|
||||
// 检查观察者事件响应方法
|
||||
$observer = $this->observer[$prefix];
|
||||
$method = 'on' . Str::studly($name);
|
||||
if (method_exists($observer, $method)) {
|
||||
return $this->dispatch([$observer, $method], $params);
|
||||
}
|
||||
}
|
||||
|
||||
$name = substr($event, 0, strrpos($event, '.'));
|
||||
if (isset($this->listener[$name . '.*'])) {
|
||||
$listeners = array_merge($listeners, $this->listener[$name . '.*']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
vendor/topthink/framework/src/think/Exception.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/Exception.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
6
vendor/topthink/framework/src/think/File.php
vendored
Executable file → Normal file
6
vendor/topthink/framework/src/think/File.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -100,7 +100,7 @@ class File extends SplFileInfo
|
||||
* @param string|null $name 保存的文件名
|
||||
* @return File
|
||||
*/
|
||||
public function move(string $directory, string $name = null): File
|
||||
public function move(string $directory, ?string $name = null): File
|
||||
{
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
@ -124,7 +124,7 @@ class File extends SplFileInfo
|
||||
* @param null|string $name
|
||||
* @return File
|
||||
*/
|
||||
protected function getTargetFile(string $directory, string $name = null): File
|
||||
protected function getTargetFile(string $directory, ?string $name = null): File
|
||||
{
|
||||
if (!is_dir($directory)) {
|
||||
if (false === @mkdir($directory, 0777, true) && !is_dir($directory)) {
|
||||
|
||||
4
vendor/topthink/framework/src/think/Http.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/Http.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -149,7 +149,7 @@ class Http
|
||||
* @param Request|null $request
|
||||
* @return Response
|
||||
*/
|
||||
public function run(Request $request = null): Response
|
||||
public function run(?Request $request = null): Response
|
||||
{
|
||||
//初始化
|
||||
$this->initialize();
|
||||
|
||||
40
vendor/topthink/framework/src/think/Lang.php
vendored
Executable file → Normal file
40
vendor/topthink/framework/src/think/Lang.php
vendored
Executable file → Normal file
@ -2,13 +2,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
@ -26,25 +26,27 @@ class Lang
|
||||
*/
|
||||
protected $config = [
|
||||
// 默认语言
|
||||
'default_lang' => 'zh-cn',
|
||||
'default_lang' => 'zh-cn',
|
||||
// 自动侦测浏览器语言
|
||||
'auto_detect_browser' => true,
|
||||
// 允许的语言列表
|
||||
'allow_lang_list' => [],
|
||||
'allow_lang_list' => [],
|
||||
// 是否使用Cookie记录
|
||||
'use_cookie' => true,
|
||||
'use_cookie' => true,
|
||||
// 扩展语言包
|
||||
'extend_list' => [],
|
||||
'extend_list' => [],
|
||||
// 多语言cookie变量
|
||||
'cookie_var' => 'think_lang',
|
||||
'cookie_var' => 'think_lang',
|
||||
// 多语言header变量
|
||||
'header_var' => 'think-lang',
|
||||
'header_var' => 'think-lang',
|
||||
// 多语言自动侦测变量名
|
||||
'detect_var' => 'lang',
|
||||
'detect_var' => 'lang',
|
||||
// Accept-Language转义为对应语言包名称
|
||||
'accept_language' => [
|
||||
'accept_language' => [
|
||||
'zh-hans-cn' => 'zh-cn',
|
||||
],
|
||||
// 是否支持语言分组
|
||||
'allow_group' => false,
|
||||
'allow_group' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -136,7 +138,7 @@ class Lang
|
||||
$this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php',
|
||||
]);
|
||||
|
||||
// 加载系统语言包
|
||||
// 加载应用语言包(支持多种类型)
|
||||
$files = glob($this->app->getAppPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*');
|
||||
$this->load($files);
|
||||
|
||||
@ -188,10 +190,10 @@ class Lang
|
||||
{
|
||||
$type = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$result = match ($type) {
|
||||
'php' => include $file,
|
||||
'yml','yaml'=> function_exists('yaml_parse_file') ? yaml_parse_file($file) : [],
|
||||
'json' => json_decode(file_get_contents($file), true),
|
||||
default => [],
|
||||
'php' => include $file,
|
||||
'yml', 'yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [],
|
||||
'json' => json_decode(file_get_contents($file), true),
|
||||
default => [],
|
||||
};
|
||||
|
||||
return is_array($result) ? $result : [];
|
||||
@ -200,8 +202,8 @@ class Lang
|
||||
/**
|
||||
* 判断是否存在语言定义(不区分大小写)
|
||||
* @access public
|
||||
* @param string|null $name 语言变量
|
||||
* @param string $range 语言作用域
|
||||
* @param string $name 语言变量
|
||||
* @param string $range 语言作用域
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name, string $range = ''): bool
|
||||
@ -224,7 +226,7 @@ class Lang
|
||||
* @param string $range 语言作用域
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $name = null, array $vars = [], string $range = '')
|
||||
public function get(?string $name = null, array $vars = [], string $range = '')
|
||||
{
|
||||
$range = $range ?: $this->range;
|
||||
|
||||
|
||||
10
vendor/topthink/framework/src/think/Log.php
vendored
Executable file → Normal file
10
vendor/topthink/framework/src/think/Log.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -57,7 +57,7 @@ class Log extends Manager implements LoggerInterface
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null)
|
||||
public function getConfig(?string $name = null, $default = null)
|
||||
{
|
||||
if (!is_null($name)) {
|
||||
return $this->app->config->get('log.' . $name, $default);
|
||||
@ -73,7 +73,7 @@ class Log extends Manager implements LoggerInterface
|
||||
* @param mixed $default
|
||||
* @return array
|
||||
*/
|
||||
public function getChannelConfig(string $channel, string $name = null, $default = null)
|
||||
public function getChannelConfig(string $channel, ?string $name = null, $default = null)
|
||||
{
|
||||
if ($config = $this->getConfig("channels.{$channel}")) {
|
||||
return Arr::get($config, $name, $default);
|
||||
@ -87,7 +87,7 @@ class Log extends Manager implements LoggerInterface
|
||||
* @param string|array $name 渠道名
|
||||
* @return Channel|ChannelSet
|
||||
*/
|
||||
public function channel(string|array $name = null)
|
||||
public function channel(string|array|null $name = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return new ChannelSet($this, $name);
|
||||
@ -156,7 +156,7 @@ class Log extends Manager implements LoggerInterface
|
||||
* @param string $channel 日志通道名
|
||||
* @return array
|
||||
*/
|
||||
public function getLog(string $channel = null): array
|
||||
public function getLog(?string $channel = null): array
|
||||
{
|
||||
return $this->channel($channel)->getLog();
|
||||
}
|
||||
|
||||
4
vendor/topthink/framework/src/think/Manager.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/Manager.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -38,7 +38,7 @@ abstract class Manager
|
||||
* @param null|string $name
|
||||
* @return mixed
|
||||
*/
|
||||
protected function driver(string $name = null)
|
||||
protected function driver(?string $name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
|
||||
6
vendor/topthink/framework/src/think/Middleware.php
vendored
Executable file → Normal file
6
vendor/topthink/framework/src/think/Middleware.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -186,6 +186,10 @@ class Middleware
|
||||
*/
|
||||
protected function buildMiddleware(array|string|Closure $middleware, string $type): array
|
||||
{
|
||||
if (empty($middleware)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (is_array($middleware)) {
|
||||
[$middleware, $params] = $middleware;
|
||||
}
|
||||
|
||||
2
vendor/topthink/framework/src/think/Pipeline.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/Pipeline.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
190
vendor/topthink/framework/src/think/Request.php
vendored
Executable file → Normal file
190
vendor/topthink/framework/src/think/Request.php
vendored
Executable file → Normal file
@ -2,13 +2,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
@ -27,7 +27,7 @@ class Request implements ArrayAccess
|
||||
* 兼容PATH_INFO获取
|
||||
* @var array
|
||||
*/
|
||||
protected $pathinfoFetch = ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'];
|
||||
protected $pathinfoFetch = ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL', 'PHP_SELF'];
|
||||
|
||||
/**
|
||||
* PATHINFO变量名 用于兼容模式
|
||||
@ -155,6 +155,12 @@ class Request implements ArrayAccess
|
||||
*/
|
||||
protected $realIP;
|
||||
|
||||
/**
|
||||
* 当前控制器分层名
|
||||
* @var string
|
||||
*/
|
||||
protected $layer;
|
||||
|
||||
/**
|
||||
* 当前控制器名
|
||||
* @var string
|
||||
@ -373,6 +379,17 @@ class Request implements ArrayAccess
|
||||
return $this->scheme() . '://' . $this->host($port);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置根域名
|
||||
* @param string $domain
|
||||
* @return $this
|
||||
*/
|
||||
public function setRootDomain(string $domain)
|
||||
{
|
||||
$this->rootDomain = $domain;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前根域名
|
||||
* @access public
|
||||
@ -391,7 +408,7 @@ class Request implements ArrayAccess
|
||||
$root = $item[$count - 3] . '.' . $root;
|
||||
}
|
||||
} else {
|
||||
$root = $item[0];
|
||||
$root = $item[0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,7 +650,7 @@ class Request implements ArrayAccess
|
||||
foreach ($this->pathinfoFetch as $type) {
|
||||
if ($this->server($type)) {
|
||||
$pathinfo = str_starts_with($this->server($type), $this->server('SCRIPT_NAME')) ?
|
||||
substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type);
|
||||
substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -734,7 +751,9 @@ class Request implements ArrayAccess
|
||||
if ($origin) {
|
||||
// 获取原始请求类型
|
||||
return $this->server('REQUEST_METHOD') ?: 'GET';
|
||||
} elseif (!$this->method) {
|
||||
}
|
||||
|
||||
if (!$this->method) {
|
||||
if (isset($this->post[$this->varMethod])) {
|
||||
$method = strtolower($this->post[$this->varMethod]);
|
||||
if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) {
|
||||
@ -852,20 +871,20 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function param($name = '', $default = null, string|array|null $filter = '')
|
||||
public function param($name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (empty($this->mergeParam)) {
|
||||
$method = $this->method(true);
|
||||
|
||||
// 自动获取请求变量
|
||||
$vars = match ($method) {
|
||||
'POST' => $this->post(false),
|
||||
'PUT','DELETE','PATCH' => $this->put(false),
|
||||
default => [],
|
||||
$vars = match ($method) {
|
||||
'POST' => $this->post(false),
|
||||
'PUT', 'DELETE', 'PATCH' => $this->put(false),
|
||||
default => [],
|
||||
};
|
||||
|
||||
// 当前请求参数和URL地址中的参数合并
|
||||
$this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false));
|
||||
$this->param = array_merge($this->param, $this->route(false), $this->get(false), $vars);
|
||||
|
||||
$this->mergeParam = true;
|
||||
}
|
||||
@ -884,7 +903,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function all(string|array $name = '', string|array|null $filter = '')
|
||||
public function all(string | array $name = '', string | array | null $filter = '')
|
||||
{
|
||||
$data = array_merge($this->param(), $this->file() ?: []);
|
||||
|
||||
@ -940,7 +959,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function route(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function route(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->only($name, $this->route, $filter);
|
||||
@ -957,7 +976,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function get(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->only($name, $this->get, $filter);
|
||||
@ -973,8 +992,11 @@ class Request implements ArrayAccess
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function middleware(string $name, $default = null)
|
||||
public function middleware(?string $name = null, $default = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
return $this->middleware;
|
||||
}
|
||||
return $this->middleware[$name] ?? $default;
|
||||
}
|
||||
|
||||
@ -986,7 +1008,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function post(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function post(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->only($name, $this->post, $filter);
|
||||
@ -1003,7 +1025,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function put(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function put(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->only($name, $this->put, $filter);
|
||||
@ -1018,7 +1040,9 @@ class Request implements ArrayAccess
|
||||
if ('application/x-www-form-urlencoded' == $contentType) {
|
||||
parse_str($content, $data);
|
||||
return $data;
|
||||
} elseif (str_contains($contentType, 'json')) {
|
||||
}
|
||||
|
||||
if (str_contains($contentType, 'json')) {
|
||||
return (array) json_decode($content, true);
|
||||
}
|
||||
|
||||
@ -1033,7 +1057,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function delete(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
return $this->put($name, $default, $filter);
|
||||
}
|
||||
@ -1046,7 +1070,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function patch(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function patch(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
return $this->put($name, $default, $filter);
|
||||
}
|
||||
@ -1059,7 +1083,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function request(string|array|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function request(string | array | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (is_array($name)) {
|
||||
return $this->only($name, $this->request, $filter);
|
||||
@ -1075,7 +1099,7 @@ class Request implements ArrayAccess
|
||||
* @param string $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function env(string $name = '', string $default = null)
|
||||
public function env(string $name = '', ?string $default = null)
|
||||
{
|
||||
if (empty($name)) {
|
||||
return $this->env->get();
|
||||
@ -1106,7 +1130,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return mixed
|
||||
*/
|
||||
public function cookie(string $name = '', $default = null, string|array|null $filter = '')
|
||||
public function cookie(string $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (!empty($name)) {
|
||||
$data = $this->getData($this->cookie, $name, $default);
|
||||
@ -1239,7 +1263,7 @@ class Request implements ArrayAccess
|
||||
* @param string $default 默认值
|
||||
* @return string|array|null
|
||||
*/
|
||||
public function header(string $name = '', string $default = null)
|
||||
public function header(string $name = '', ?string $default = null)
|
||||
{
|
||||
if ('' === $name) {
|
||||
return $this->header;
|
||||
@ -1258,7 +1282,7 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤函数
|
||||
* @return mixed
|
||||
*/
|
||||
public function input(array $data = [], string|bool $name = '', $default = null, string|array|null $filter = '')
|
||||
public function input(array $data = [], string | bool $name = '', $default = null, string | array | null $filter = '')
|
||||
{
|
||||
if (false === $name) {
|
||||
// 获取原始数据
|
||||
@ -1273,28 +1297,21 @@ class Request implements ArrayAccess
|
||||
}
|
||||
|
||||
$data = $this->getData($data, $name);
|
||||
|
||||
if (is_null($data)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (is_object($data)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->filterData($data, $filter, $name, $default);
|
||||
|
||||
if (isset($type) && $data !== $default) {
|
||||
// 强制类型转换
|
||||
$this->typeCast($data, $type);
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $this->filterData($data, $filter, $name, $default, $type ?? '');
|
||||
}
|
||||
|
||||
protected function filterData($data, $filter, $name, $default)
|
||||
protected function filterData($data, $filter, $name, $default, $type)
|
||||
{
|
||||
if (is_null($data)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (is_object($data)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 解析过滤器
|
||||
$filter = $this->getFilter($filter, $default);
|
||||
|
||||
@ -1304,6 +1321,11 @@ class Request implements ArrayAccess
|
||||
$this->filterValue($data, $name, $filter);
|
||||
}
|
||||
|
||||
if ($type) {
|
||||
// 强制类型转换
|
||||
$this->typeCast($data, $type);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -1316,16 +1338,14 @@ class Request implements ArrayAccess
|
||||
*/
|
||||
protected function typeCast(&$data, string $type)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
if (in_array($type, ['a', 'b', 'd', 'f', 's'])) {
|
||||
$data = match ($type) {
|
||||
'a' => (array) $data, // 数组
|
||||
'b' => (bool) $data, // 布尔
|
||||
'd' => (int) $data, // 数字
|
||||
'f' => (float) $data, // 浮点
|
||||
's' => is_scalar($data) ? (string) $data : throw new \InvalidArgumentException('variable type error:' . gettype($data)), //字符串
|
||||
};
|
||||
}
|
||||
$data = match (strtolower($type)) {
|
||||
'a' => (array) $data,
|
||||
'b' => (bool) $data,
|
||||
'd' => (int) $data,
|
||||
'f' => (float) $data,
|
||||
's' => is_scalar($data) ? (string) $data : throw new \InvalidArgumentException('variable type error:' . gettype($data)),
|
||||
default => $data,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1467,24 +1487,30 @@ class Request implements ArrayAccess
|
||||
* @param string|array|null $filter 过滤方法
|
||||
* @return array
|
||||
*/
|
||||
public function only(array $name, $data = 'param', string|array|null $filter = ''): array
|
||||
public function only(array $name, $data = 'param', string | array | null $filter = ''): array
|
||||
{
|
||||
$data = is_array($data) ? $data : $this->$data();
|
||||
|
||||
$item = [];
|
||||
foreach ($name as $key => $val) {
|
||||
|
||||
$type = '';
|
||||
if (is_int($key)) {
|
||||
if (str_contains($val, '/')) {
|
||||
[$val, $type] = explode('/', $val);
|
||||
}
|
||||
$default = null;
|
||||
$key = $val;
|
||||
if (!key_exists($key, $data)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (str_contains($key, '/')) {
|
||||
[$key, $type] = explode('/', $key);
|
||||
}
|
||||
$default = $val;
|
||||
}
|
||||
|
||||
$item[$key] = $this->filterData($data[$key] ?? $default, $filter, $key, $default);
|
||||
$item[$key] = $this->filterData($data[$key] ?? $default, $filter, $key, $default, $type);
|
||||
}
|
||||
|
||||
return $item;
|
||||
@ -1659,10 +1685,10 @@ class Request implements ArrayAccess
|
||||
*/
|
||||
public function isValidIP(string $ip, string $type = ''): bool
|
||||
{
|
||||
$flag = match (strtolower($type)) {
|
||||
'ipv4' => FILTER_FLAG_IPV4,
|
||||
'ipv6' => FILTER_FLAG_IPV6,
|
||||
default => 0,
|
||||
$flag = match (strtolower($type)) {
|
||||
'ipv4' => FILTER_FLAG_IPV4,
|
||||
'ipv6' => FILTER_FLAG_IPV6,
|
||||
default => 0,
|
||||
};
|
||||
|
||||
return boolval(filter_var($ip, FILTER_VALIDATE_IP, $flag));
|
||||
@ -1829,6 +1855,18 @@ class Request implements ArrayAccess
|
||||
return $this->secureKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前的分层名
|
||||
* @access public
|
||||
* @param string $layer 控制器分层名
|
||||
* @return $this
|
||||
*/
|
||||
public function setLayer(string $layer)
|
||||
{
|
||||
$this->layer = $layer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前的控制器名
|
||||
* @access public
|
||||
@ -1854,14 +1892,30 @@ class Request implements ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的控制器名
|
||||
* 获取当前的模块名
|
||||
* @access public
|
||||
* @param bool $convert 转换为小写
|
||||
* @return string
|
||||
*/
|
||||
public function controller(bool $convert = false): string
|
||||
public function layer(bool $convert = false): string
|
||||
{
|
||||
$name = $this->layer ?: '';
|
||||
return $convert ? strtolower($name) : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前的控制器名
|
||||
* @access public
|
||||
* @param bool $convert 转换为小写
|
||||
* @param bool $base 仅返回basename
|
||||
* @return string
|
||||
*/
|
||||
public function controller(bool $convert = false, bool $base = false): string
|
||||
{
|
||||
$name = $this->controller ?: '';
|
||||
if ($base) {
|
||||
$name = basename(str_replace('.', '/', $name));
|
||||
}
|
||||
return $convert ? strtolower($name) : $name;
|
||||
}
|
||||
|
||||
@ -2007,6 +2061,18 @@ class Request implements ArrayAccess
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新COOKIE数据
|
||||
* @access public
|
||||
* @param string $name cookie名
|
||||
* @param mixed $value 数据
|
||||
* @return void
|
||||
*/
|
||||
public function setCookie(string $name, mixed $value)
|
||||
{
|
||||
$this->cookie[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置SESSION数据
|
||||
* @access public
|
||||
|
||||
12
vendor/topthink/framework/src/think/Response.php
vendored
Executable file → Normal file
12
vendor/topthink/framework/src/think/Response.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -412,4 +412,14 @@ abstract class Response
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Cookie对象
|
||||
* @access public
|
||||
* @return Cookie
|
||||
*/
|
||||
public function getCookie()
|
||||
{
|
||||
return $this->cookie;
|
||||
}
|
||||
}
|
||||
|
||||
188
vendor/topthink/framework/src/think/Route.php
vendored
Executable file → Normal file
188
vendor/topthink/framework/src/think/Route.php
vendored
Executable file → Normal file
@ -2,13 +2,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace think;
|
||||
|
||||
@ -16,7 +16,6 @@ use Closure;
|
||||
use think\exception\RouteNotFoundException;
|
||||
use think\route\Dispatch;
|
||||
use think\route\dispatch\Callback;
|
||||
use think\route\dispatch\Url as UrlDispatch;
|
||||
use think\route\Domain;
|
||||
use think\route\Resource;
|
||||
use think\route\ResourceRegister;
|
||||
@ -65,8 +64,6 @@ class Route
|
||||
'route_complete_match' => false,
|
||||
// 去除斜杠
|
||||
'remove_slash' => false,
|
||||
// 使用注解路由
|
||||
'route_annotation' => false,
|
||||
// 默认的路由变量规则
|
||||
'default_route_pattern' => '[\w\.]+',
|
||||
// URL伪静态后缀
|
||||
@ -77,6 +74,8 @@ class Route
|
||||
'empty_controller' => 'Error',
|
||||
// 是否使用控制器后缀
|
||||
'controller_suffix' => false,
|
||||
// 默认模块名
|
||||
'default_module' => 'index',
|
||||
// 默认控制器名
|
||||
'default_controller' => 'Index',
|
||||
// 默认操作名
|
||||
@ -85,6 +84,8 @@ class Route
|
||||
'action_suffix' => '',
|
||||
// 非路由变量是否使用普通参数方式(用于URL生成)
|
||||
'url_common_param' => true,
|
||||
// 操作方法的参数绑定方式 route get param
|
||||
'action_bind_param' => 'get',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -110,12 +111,6 @@ class Route
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
* 路由绑定
|
||||
* @var array
|
||||
*/
|
||||
protected $bind = [];
|
||||
|
||||
/**
|
||||
* 域名对象
|
||||
* @var Domain[]
|
||||
@ -179,7 +174,7 @@ class Route
|
||||
}, 'options');
|
||||
}
|
||||
|
||||
public function config(string $name = null)
|
||||
public function config(?string $name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
return $this->config;
|
||||
@ -247,7 +242,7 @@ class Route
|
||||
* @param string $name 分组标识
|
||||
* @return RuleGroup
|
||||
*/
|
||||
public function getGroup(string $name = null)
|
||||
public function getGroup(?string $name = null)
|
||||
{
|
||||
return $name ? $this->ruleName->getGroup($name) : $this->group;
|
||||
}
|
||||
@ -285,7 +280,7 @@ class Route
|
||||
* @param mixed $rule 路由规则
|
||||
* @return Domain
|
||||
*/
|
||||
public function domain(string|array $name, $rule = null): Domain
|
||||
public function domain(string | array $name, $rule = null): Domain
|
||||
{
|
||||
// 支持多个域名使用相同路由规则
|
||||
$domainName = is_array($name) ? array_shift($name) : $name;
|
||||
@ -321,6 +316,23 @@ class Route
|
||||
return $this->domains;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取域名路由的绑定信息
|
||||
* @access public
|
||||
* @param string $domain 子域名
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDomainBind(?string $domain = null)
|
||||
{
|
||||
if ($domain && isset($this->domains[$domain])) {
|
||||
$item = $this->domains[$domain];
|
||||
if (is_string($item)) {
|
||||
$item = $this->domains[$item];
|
||||
}
|
||||
return $item->getBind();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取RuleName对象
|
||||
* @access public
|
||||
@ -331,67 +343,6 @@ class Route
|
||||
return $this->ruleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置路由绑定
|
||||
* @access public
|
||||
* @param string $bind 绑定信息
|
||||
* @param string $domain 域名
|
||||
* @return $this
|
||||
*/
|
||||
public function bind(string $bind, string $domain = null)
|
||||
{
|
||||
$domain = is_null($domain) ? '-' : $domain;
|
||||
|
||||
$this->bind[$domain] = $bind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取路由绑定信息
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getBind(): array
|
||||
{
|
||||
return $this->bind;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取路由绑定
|
||||
* @access public
|
||||
* @param string $domain 域名
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDomainBind(string $domain = null)
|
||||
{
|
||||
if (is_null($domain)) {
|
||||
$domain = $this->host;
|
||||
} elseif (!str_contains($domain, '.') && $this->request) {
|
||||
$domain .= '.' . $this->request->rootDomain();
|
||||
}
|
||||
|
||||
if ($this->request) {
|
||||
$subDomain = $this->request->subDomain();
|
||||
|
||||
if (str_contains($subDomain, '.')) {
|
||||
$name = '*' . strstr($subDomain, '.');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->bind[$domain])) {
|
||||
$result = $this->bind[$domain];
|
||||
} elseif (isset($name) && isset($this->bind[$name])) {
|
||||
$result = $this->bind[$name];
|
||||
} elseif (!empty($subDomain) && isset($this->bind['*'])) {
|
||||
$result = $this->bind['*'];
|
||||
} else {
|
||||
$result = null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取路由标识
|
||||
* @access public
|
||||
@ -400,7 +351,7 @@ class Route
|
||||
* @param string $method 请求类型
|
||||
* @return array
|
||||
*/
|
||||
public function getName(string $name = null, string $domain = null, string $method = '*'): array
|
||||
public function getName(?string $name = null, ?string $domain = null, string $method = '*'): array
|
||||
{
|
||||
return $this->ruleName->getName($name, $domain, $method);
|
||||
}
|
||||
@ -436,7 +387,7 @@ class Route
|
||||
* @param RuleItem $ruleItem RuleItem对象
|
||||
* @return void
|
||||
*/
|
||||
public function setRule(string $rule, RuleItem $ruleItem = null): void
|
||||
public function setRule(string $rule, ?RuleItem $ruleItem = null): void
|
||||
{
|
||||
$this->ruleName->setRule($rule, $ruleItem);
|
||||
}
|
||||
@ -513,7 +464,7 @@ class Route
|
||||
* @param mixed $route 分组路由
|
||||
* @return RuleGroup
|
||||
*/
|
||||
public function group(string|Closure $name, $route = null): RuleGroup
|
||||
public function group(string | Closure $name, $route = null): RuleGroup
|
||||
{
|
||||
if ($name instanceof Closure) {
|
||||
$route = $name;
|
||||
@ -626,11 +577,12 @@ class Route
|
||||
* @access public
|
||||
* @param string $rule 路由规则
|
||||
* @param string $route 路由地址
|
||||
* @param Closure $extend 扩展规则
|
||||
* @return Resource|ResourceRegister
|
||||
*/
|
||||
public function resource(string $rule, string $route)
|
||||
public function resource(string $rule, string $route, ?Closure $extend = null)
|
||||
{
|
||||
$resource = new Resource($this, $this->group, $rule, $route, $this->rest);
|
||||
$resource = (new Resource($this, $this->group, $rule, $route, $this->rest))->extend($extend);
|
||||
|
||||
if (!$this->lazy) {
|
||||
return new ResourceRegister($resource);
|
||||
@ -671,7 +623,8 @@ class Route
|
||||
foreach ($matches as $key => $value) {
|
||||
$search[] = '<' . $key . '>';
|
||||
$replace[] = $value;
|
||||
|
||||
$search[] = '{' . $key . '}';
|
||||
$replace[] = $value;
|
||||
$search[] = ':' . $key;
|
||||
$replace[] = $value;
|
||||
}
|
||||
@ -688,7 +641,7 @@ class Route
|
||||
* @param array|bool $resource 资源
|
||||
* @return $this
|
||||
*/
|
||||
public function rest(string|array $name, array|bool $resource = [])
|
||||
public function rest(string | array $name, array | bool $resource = [])
|
||||
{
|
||||
if (is_array($name)) {
|
||||
$this->rest = $resource ? $name : array_merge($this->rest, $name);
|
||||
@ -705,7 +658,7 @@ class Route
|
||||
* @param string $name 方法名称
|
||||
* @return array|null
|
||||
*/
|
||||
public function getRest(string $name = null)
|
||||
public function getRest(?string $name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
return $this->rest;
|
||||
@ -721,7 +674,7 @@ class Route
|
||||
* @param string $method 请求类型
|
||||
* @return RuleItem
|
||||
*/
|
||||
public function miss(string|Closure $route, string $method = '*'): RuleItem
|
||||
public function miss(string | Closure $route, string $method = '*'): RuleItem
|
||||
{
|
||||
return $this->group->miss($route, $method);
|
||||
}
|
||||
@ -732,19 +685,24 @@ class Route
|
||||
* @param Closure|bool $withRoute
|
||||
* @return Response
|
||||
*/
|
||||
public function dispatch(Request $request, Closure|bool $withRoute = true)
|
||||
public function dispatch(Request $request, Closure | bool $withRoute = true)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->host = $this->request->host(true);
|
||||
$completeMatch = (bool) $this->config['route_complete_match'];
|
||||
$url = str_replace($this->config['pathinfo_depr'], '|', $this->path());
|
||||
|
||||
if ($withRoute) {
|
||||
//加载路由
|
||||
if ($withRoute instanceof Closure) {
|
||||
$withRoute();
|
||||
}
|
||||
$dispatch = $this->check();
|
||||
} else {
|
||||
$dispatch = $this->url($this->path());
|
||||
// 路由检测
|
||||
$dispatch = $this->check($url, $completeMatch);
|
||||
}
|
||||
|
||||
if (empty($dispatch)) {
|
||||
// 默认URL调度
|
||||
$dispatch = $this->checkUrlDispatch($url);
|
||||
}
|
||||
|
||||
$dispatch->init($this->app);
|
||||
@ -759,16 +717,13 @@ class Route
|
||||
/**
|
||||
* 检测URL路由
|
||||
* @access public
|
||||
* @param bool $completeMatch
|
||||
* @return Dispatch|false
|
||||
* @throws RouteNotFoundException
|
||||
*/
|
||||
public function check()
|
||||
public function check(string $url, bool $completeMatch = false)
|
||||
{
|
||||
// 自动检测域名路由
|
||||
$url = str_replace($this->config['pathinfo_depr'], '|', $this->path());
|
||||
|
||||
$completeMatch = $this->config['route_complete_match'];
|
||||
|
||||
// 检测域名路由
|
||||
$result = $this->checkDomain()->check($this->request, $url, $completeMatch);
|
||||
|
||||
if (false === $result && !empty($this->cross)) {
|
||||
@ -776,13 +731,12 @@ class Route
|
||||
$result = $this->cross->check($this->request, $url, $completeMatch);
|
||||
}
|
||||
|
||||
if (false !== $result) {
|
||||
return $result;
|
||||
} elseif ($this->config['url_route_must']) {
|
||||
if (false === $result && $this->config['url_route_must']) {
|
||||
// 开启强制路由
|
||||
throw new RouteNotFoundException();
|
||||
}
|
||||
|
||||
return $this->url($url);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -810,12 +764,35 @@ class Route
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认URL解析
|
||||
* 自动多模块URL路由 如使用多模块在路由定义文件最后定义
|
||||
* @access public
|
||||
* @param string $url URL地址
|
||||
* @param string $rule 路由规则
|
||||
* @param mixed $route 路由地址
|
||||
* @param bool $middleware 自动注册中间件
|
||||
* @return RuleItem
|
||||
*/
|
||||
public function auto(string $rule = '[:__module__]/[:__controller__]/[:__action__]', $route = ':__module__/:__controller__/:__action__', bool $middleware = false): RuleItem
|
||||
{
|
||||
return $this->rule($rule, $route)
|
||||
->name('__think_auto_route__')
|
||||
->pattern([
|
||||
'__module__' => '[A-Za-z0-9\.\_]+',
|
||||
'__controller__' => '[A-Za-z0-9\.\_]+',
|
||||
'__action__' => '[A-Za-z0-9\_]+',
|
||||
])->default([
|
||||
'__module__' => $this->config['default_module'],
|
||||
'__controller__' => $this->config['default_controller'],
|
||||
'__action__' => $this->config['default_action'],
|
||||
])->autoMiddleware($middleware);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测默认URL解析路由
|
||||
* @access public
|
||||
* @param string $url URL
|
||||
* @return Dispatch
|
||||
*/
|
||||
public function url(string $url): Dispatch
|
||||
protected function checkUrlDispatch(string $url): Dispatch
|
||||
{
|
||||
if ($this->request->method() == 'OPTIONS') {
|
||||
// 自动响应options请求
|
||||
@ -824,7 +801,7 @@ class Route
|
||||
});
|
||||
}
|
||||
|
||||
return new UrlDispatch($this->request, $this->group, $url);
|
||||
return $this->group->auto()->checkBind($this->request, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -839,9 +816,8 @@ class Route
|
||||
if (count($this->domains) > 1) {
|
||||
// 获取当前子域名
|
||||
$subDomain = $this->request->subDomain();
|
||||
|
||||
$domain = $subDomain ? explode('.', $subDomain) : [];
|
||||
$domain2 = $domain ? array_pop($domain) : '';
|
||||
$domain = $subDomain ? explode('.', $subDomain) : [];
|
||||
$domain2 = $domain ? array_pop($domain) : '';
|
||||
|
||||
if ($domain) {
|
||||
// 存在三级域名
|
||||
|
||||
2
vendor/topthink/framework/src/think/Service.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/Service.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
4
vendor/topthink/framework/src/think/Session.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/Session.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -38,7 +38,7 @@ class Session extends Manager
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name = null, $default = null)
|
||||
public function getConfig(?string $name = null, $default = null)
|
||||
{
|
||||
if (!is_null($name)) {
|
||||
return $this->app->config->get('session.' . $name, $default);
|
||||
|
||||
9
vendor/topthink/framework/src/think/View.php
vendored
Executable file → Normal file
9
vendor/topthink/framework/src/think/View.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace think;
|
||||
|
||||
use think\contract\TemplateHandlerInterface;
|
||||
use think\helper\Arr;
|
||||
|
||||
/**
|
||||
@ -39,9 +40,9 @@ class View extends Manager
|
||||
* 获取模板引擎
|
||||
* @access public
|
||||
* @param string $type 模板引擎类型
|
||||
* @return $this
|
||||
* @return TemplateHandlerInterface
|
||||
*/
|
||||
public function engine(string $type = null)
|
||||
public function engine(?string $type = null)
|
||||
{
|
||||
return $this->driver($type);
|
||||
}
|
||||
@ -70,7 +71,7 @@ class View extends Manager
|
||||
* @param Callable $filter 过滤方法或闭包
|
||||
* @return $this
|
||||
*/
|
||||
public function filter(callable $filter = null)
|
||||
public function filter(?callable $filter = null)
|
||||
{
|
||||
$this->filter = $filter;
|
||||
return $this;
|
||||
|
||||
57
vendor/topthink/framework/src/think/cache/Driver.php
vendored
Executable file → Normal file
57
vendor/topthink/framework/src/think/cache/Driver.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -20,7 +20,8 @@ use Exception;
|
||||
use think\Container;
|
||||
use think\contract\CacheHandlerInterface;
|
||||
use think\exception\InvalidArgumentException;
|
||||
use throwable;
|
||||
use think\exception\InvalidCacheException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* 缓存基础类
|
||||
@ -63,14 +64,14 @@ abstract class Driver implements CacheHandlerInterface
|
||||
* @param integer|DateInterval|DateTimeInterface $expire 有效期
|
||||
* @return int
|
||||
*/
|
||||
protected function getExpireTime(int|DateInterval|DateTimeInterface $expire): int
|
||||
protected function getExpireTime(int | DateInterval | DateTimeInterface $expire): int
|
||||
{
|
||||
if ($expire instanceof DateTimeInterface) {
|
||||
$expire = $expire->getTimestamp() - time();
|
||||
} elseif ($expire instanceof DateInterval) {
|
||||
$expire = DateTime::createFromFormat('U', (string) time())
|
||||
->add($expire)
|
||||
->format('U') - time();
|
||||
->add($expire)
|
||||
->format('U') - time();
|
||||
}
|
||||
|
||||
return $expire;
|
||||
@ -91,16 +92,17 @@ abstract class Driver implements CacheHandlerInterface
|
||||
* 读取缓存并删除
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param mixed $default 默认值
|
||||
* @return mixed
|
||||
*/
|
||||
public function pull($name)
|
||||
public function pull($name, $default = null)
|
||||
{
|
||||
$result = $this->get($name, false);
|
||||
|
||||
if ($result) {
|
||||
if ($this->has($name)) {
|
||||
$result = $this->get($name, $default);
|
||||
$this->delete($name);
|
||||
return $result;
|
||||
}
|
||||
return $this->getDefaultValue($name, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,7 +180,7 @@ abstract class Driver implements CacheHandlerInterface
|
||||
|
||||
// 解锁
|
||||
$this->delete($name . '_lock');
|
||||
} catch (Exception|throwable $e) {
|
||||
} catch (Exception | Throwable $e) {
|
||||
$this->delete($name . '_lock');
|
||||
throw $e;
|
||||
}
|
||||
@ -233,10 +235,10 @@ abstract class Driver implements CacheHandlerInterface
|
||||
* @param mixed $data 缓存数据
|
||||
* @return string
|
||||
*/
|
||||
protected function serialize($data): string
|
||||
protected function serialize($data)
|
||||
{
|
||||
if (is_numeric($data)) {
|
||||
return (string) $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
$serialize = $this->options['serialize'][0] ?? "serialize";
|
||||
@ -250,15 +252,38 @@ abstract class Driver implements CacheHandlerInterface
|
||||
* @param string $data 缓存数据
|
||||
* @return mixed
|
||||
*/
|
||||
protected function unserialize(string $data)
|
||||
protected function unserialize($data)
|
||||
{
|
||||
if (is_numeric($data)) {
|
||||
return $data;
|
||||
}
|
||||
try {
|
||||
$unserialize = $this->options['serialize'][1] ?? "unserialize";
|
||||
$content = $unserialize($data);
|
||||
if (is_null($content)) {
|
||||
throw new InvalidCacheException;
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
} catch (Exception | Throwable $e) {
|
||||
throw new InvalidCacheException;
|
||||
}
|
||||
}
|
||||
|
||||
$unserialize = $this->options['serialize'][1] ?? "unserialize";
|
||||
|
||||
return $unserialize($data);
|
||||
/**
|
||||
* 获取默认值
|
||||
* @access protected
|
||||
* @param string $name 缓存标识
|
||||
* @param mixed $default 默认值
|
||||
* @param bool $fail 是否有异常
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getDefaultValue($name, $default, $fail = false)
|
||||
{
|
||||
if ($fail && $this->options['fail_delete']) {
|
||||
$this->delete($name);
|
||||
}
|
||||
return $default instanceof Closure ? $default() : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
6
vendor/topthink/framework/src/think/cache/TagSet.php
vendored
Executable file → Normal file
6
vendor/topthink/framework/src/think/cache/TagSet.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -109,8 +109,8 @@ class TagSet
|
||||
{
|
||||
// 指定标签清除
|
||||
foreach ($this->tag as $tag) {
|
||||
$names = $this->handler->getTagItems($tag);
|
||||
$this->handler->clearTag($names);
|
||||
$keys = $this->handler->getTagItems($tag);
|
||||
if (!empty($keys)) $this->handler->clearTag($keys);
|
||||
|
||||
$key = $this->handler->getTagKey($tag);
|
||||
$this->handler->delete($key);
|
||||
|
||||
10
vendor/topthink/framework/src/think/cache/driver/File.php
vendored
Executable file → Normal file
10
vendor/topthink/framework/src/think/cache/driver/File.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -16,6 +16,7 @@ use DateTimeInterface;
|
||||
use FilesystemIterator;
|
||||
use think\App;
|
||||
use think\cache\Driver;
|
||||
use think\exception\InvalidCacheException;
|
||||
|
||||
/**
|
||||
* 文件缓存类
|
||||
@ -35,6 +36,7 @@ class File extends Driver
|
||||
'data_compress' => false,
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'fail_delete' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -135,7 +137,11 @@ class File extends Driver
|
||||
{
|
||||
$raw = $this->getRaw($name);
|
||||
|
||||
return is_null($raw) ? $default : $this->unserialize($raw['content']);
|
||||
try {
|
||||
return is_null($raw) ? $this->getDefaultValue($name, $default) : $this->unserialize($raw['content']);
|
||||
} catch (InvalidCacheException $e) {
|
||||
return $this->getDefaultValue($name, $default, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
34
vendor/topthink/framework/src/think/cache/driver/Memcache.php
vendored
Executable file → Normal file
34
vendor/topthink/framework/src/think/cache/driver/Memcache.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -15,6 +15,7 @@ namespace think\cache\driver;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use think\cache\Driver;
|
||||
use think\exception\InvalidCacheException;
|
||||
|
||||
/**
|
||||
* Memcache缓存类
|
||||
@ -26,14 +27,15 @@ class Memcache extends Driver
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'expire' => 0,
|
||||
'timeout' => 0, // 超时时间(单位:毫秒)
|
||||
'persistent' => true,
|
||||
'prefix' => '',
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'expire' => 0,
|
||||
'timeout' => 0,
|
||||
'persistent' => true,
|
||||
'prefix' => '',
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'fail_delete' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -66,8 +68,8 @@ class Memcache extends Driver
|
||||
foreach ($hosts as $i => $host) {
|
||||
$port = $ports[$i] ?? $ports[0];
|
||||
$this->options['timeout'] > 0 ?
|
||||
$this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) :
|
||||
$this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
|
||||
$this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) :
|
||||
$this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +97,11 @@ class Memcache extends Driver
|
||||
{
|
||||
$result = $this->handler->get($this->getCacheKey($name));
|
||||
|
||||
return false !== $result ? $this->unserialize($result) : $default;
|
||||
try {
|
||||
return false !== $result ? $this->unserialize($result) : $this->getDefaultValue($name, $default);
|
||||
} catch (InvalidCacheException $e) {
|
||||
return $this->getDefaultValue($name, $default, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,8 +175,8 @@ class Memcache extends Driver
|
||||
$key = $this->getCacheKey($name);
|
||||
|
||||
return false === $ttl ?
|
||||
$this->handler->delete($key) :
|
||||
$this->handler->delete($key, $ttl);
|
||||
$this->handler->delete($key) :
|
||||
$this->handler->delete($key, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
35
vendor/topthink/framework/src/think/cache/driver/Memcached.php
vendored
Executable file → Normal file
35
vendor/topthink/framework/src/think/cache/driver/Memcached.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -15,6 +15,7 @@ namespace think\cache\driver;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use think\cache\Driver;
|
||||
use think\exception\InvalidCacheException;
|
||||
|
||||
/**
|
||||
* Memcached缓存类
|
||||
@ -26,16 +27,17 @@ class Memcached extends Driver
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'expire' => 0,
|
||||
'timeout' => 0, // 超时时间(单位:毫秒)
|
||||
'prefix' => '',
|
||||
'username' => '', //账号
|
||||
'password' => '', //密码
|
||||
'option' => [],
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'expire' => 0,
|
||||
'timeout' => 0,
|
||||
'prefix' => '',
|
||||
'option' => [],
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'fail_delete' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -108,8 +110,11 @@ class Memcached extends Driver
|
||||
public function get($name, $default = null): mixed
|
||||
{
|
||||
$result = $this->handler->get($this->getCacheKey($name));
|
||||
|
||||
return false !== $result ? $this->unserialize($result) : $default;
|
||||
try {
|
||||
return false !== $result ? $this->unserialize($result) : $this->getDefaultValue($name, $default);
|
||||
} catch (InvalidCacheException $e) {
|
||||
return $this->getDefaultValue($name, $default, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,8 +188,8 @@ class Memcached extends Driver
|
||||
$key = $this->getCacheKey($name);
|
||||
|
||||
return false === $ttl ?
|
||||
$this->handler->delete($key) :
|
||||
$this->handler->delete($key, $ttl);
|
||||
$this->handler->delete($key) :
|
||||
$this->handler->delete($key, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
123
vendor/topthink/framework/src/think/cache/driver/Redis.php
vendored
Executable file → Normal file
123
vendor/topthink/framework/src/think/cache/driver/Redis.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -15,6 +15,7 @@ namespace think\cache\driver;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use think\cache\Driver;
|
||||
use think\exception\InvalidCacheException;
|
||||
|
||||
class Redis extends Driver
|
||||
{
|
||||
@ -26,16 +27,17 @@ class Redis extends Driver
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'password' => '',
|
||||
'select' => 0,
|
||||
'timeout' => 0,
|
||||
'expire' => 0,
|
||||
'persistent' => false,
|
||||
'prefix' => '',
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'password' => '',
|
||||
'select' => 0,
|
||||
'timeout' => 0,
|
||||
'expire' => 0,
|
||||
'persistent' => false,
|
||||
'prefix' => '',
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'fail_delete' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -48,42 +50,49 @@ class Redis extends Driver
|
||||
if (!empty($options)) {
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
}
|
||||
|
||||
if (extension_loaded('redis')) {
|
||||
$this->handler = new \Redis;
|
||||
public function handler()
|
||||
{
|
||||
if (!$this->handler) {
|
||||
if (extension_loaded('redis')) {
|
||||
$this->handler = new \Redis;
|
||||
|
||||
if ($this->options['persistent']) {
|
||||
$this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_' . $this->options['select']);
|
||||
} else {
|
||||
$this->handler->connect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout']);
|
||||
}
|
||||
|
||||
if ('' != $this->options['password']) {
|
||||
$this->handler->auth($this->options['password']);
|
||||
}
|
||||
} elseif (class_exists('\Predis\Client')) {
|
||||
$params = [];
|
||||
foreach ($this->options as $key => $val) {
|
||||
if (in_array($key, ['aggregate', 'cluster', 'connections', 'exceptions', 'prefix', 'profile', 'replication', 'parameters'])) {
|
||||
$params[$key] = $val;
|
||||
unset($this->options[$key]);
|
||||
if ($this->options['persistent']) {
|
||||
$this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_' . $this->options['select']);
|
||||
} else {
|
||||
$this->handler->connect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout']);
|
||||
}
|
||||
|
||||
if ('' != $this->options['password']) {
|
||||
$this->handler->auth($this->options['password']);
|
||||
}
|
||||
} elseif (class_exists('\Predis\Client')) {
|
||||
$params = [];
|
||||
foreach ($this->options as $key => $val) {
|
||||
if (in_array($key, ['aggregate', 'cluster', 'connections', 'exceptions', 'prefix', 'profile', 'replication', 'parameters'])) {
|
||||
$params[$key] = $val;
|
||||
unset($this->options[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ('' == $this->options['password']) {
|
||||
unset($this->options['password']);
|
||||
}
|
||||
|
||||
$this->handler = new \Predis\Client($this->options, $params);
|
||||
|
||||
$this->options['prefix'] = '';
|
||||
} else {
|
||||
throw new \BadFunctionCallException('not support: redis');
|
||||
}
|
||||
|
||||
if ('' == $this->options['password']) {
|
||||
unset($this->options['password']);
|
||||
if (0 != $this->options['select']) {
|
||||
$this->handler->select((int) $this->options['select']);
|
||||
}
|
||||
|
||||
$this->handler = new \Predis\Client($this->options, $params);
|
||||
|
||||
$this->options['prefix'] = '';
|
||||
} else {
|
||||
throw new \BadFunctionCallException('not support: redis');
|
||||
}
|
||||
|
||||
if (0 != $this->options['select']) {
|
||||
$this->handler->select((int) $this->options['select']);
|
||||
}
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +103,7 @@ class Redis extends Driver
|
||||
*/
|
||||
public function has($name): bool
|
||||
{
|
||||
return $this->handler->exists($this->getCacheKey($name)) ? true : false;
|
||||
return $this->handler()->exists($this->getCacheKey($name)) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,13 +116,18 @@ class Redis extends Driver
|
||||
public function get($name, $default = null): mixed
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
$value = $this->handler->get($key);
|
||||
$value = $this->handler()->get($key);
|
||||
|
||||
if (false === $value || is_null($value)) {
|
||||
return $default;
|
||||
return $this->getDefaultValue($name, $default);
|
||||
}
|
||||
|
||||
return $this->unserialize($value);
|
||||
try {
|
||||
return $this->unserialize($value);
|
||||
} catch (InvalidCacheException $e) {
|
||||
return $this->getDefaultValue($name, $default, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,9 +149,9 @@ class Redis extends Driver
|
||||
$value = $this->serialize($value);
|
||||
|
||||
if ($expire) {
|
||||
$this->handler->setex($key, $expire, $value);
|
||||
$this->handler()->setex($key, $expire, $value);
|
||||
} else {
|
||||
$this->handler->set($key, $value);
|
||||
$this->handler()->set($key, $value);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -154,7 +168,7 @@ class Redis extends Driver
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
|
||||
return $this->handler->incrby($key, $step);
|
||||
return $this->handler()->incrby($key, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +182,7 @@ class Redis extends Driver
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
|
||||
return $this->handler->decrby($key, $step);
|
||||
return $this->handler()->decrby($key, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,7 +194,7 @@ class Redis extends Driver
|
||||
public function delete($name): bool
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
$result = $this->handler->del($key);
|
||||
$result = $this->handler()->del($key);
|
||||
return $result > 0;
|
||||
}
|
||||
|
||||
@ -191,7 +205,7 @@ class Redis extends Driver
|
||||
*/
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->handler->flushDB();
|
||||
$this->handler()->flushDB();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -204,7 +218,7 @@ class Redis extends Driver
|
||||
public function clearTag($keys): void
|
||||
{
|
||||
// 指定标签清除
|
||||
$this->handler->del($keys);
|
||||
$this->handler()->del($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,7 +231,7 @@ class Redis extends Driver
|
||||
public function append($name, $value): void
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
$this->handler->sAdd($key, $value);
|
||||
$this->handler()->sAdd($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,6 +244,11 @@ class Redis extends Driver
|
||||
{
|
||||
$name = $this->getTagKey($tag);
|
||||
$key = $this->getCacheKey($name);
|
||||
return $this->handler->sMembers($key);
|
||||
return $this->handler()->sMembers($key);
|
||||
}
|
||||
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array([$this->handler(), $method], $args);
|
||||
}
|
||||
}
|
||||
|
||||
19
vendor/topthink/framework/src/think/cache/driver/Wincache.php
vendored
Executable file → Normal file
19
vendor/topthink/framework/src/think/cache/driver/Wincache.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -15,6 +15,7 @@ namespace think\cache\driver;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use think\cache\Driver;
|
||||
use think\exception\InvalidCacheException;
|
||||
|
||||
/**
|
||||
* Wincache缓存驱动
|
||||
@ -26,10 +27,11 @@ class Wincache extends Driver
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
'tag_prefix' => 'tag:',
|
||||
'serialize' => [],
|
||||
'fail_delete' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -74,8 +76,11 @@ class Wincache extends Driver
|
||||
public function get($name, $default = null): mixed
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
|
||||
return wincache_ucache_exists($key) ? $this->unserialize(wincache_ucache_get($key)) : $default;
|
||||
try {
|
||||
return wincache_ucache_exists($key) ? $this->unserialize(wincache_ucache_get($key)) : $this->getDefaultValue($name, $default);
|
||||
} catch (InvalidCacheException $e) {
|
||||
return $this->getDefaultValue($name, $default, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
8
vendor/topthink/framework/src/think/console/Command.php
vendored
Executable file → Normal file
8
vendor/topthink/framework/src/think/console/Command.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -75,7 +75,7 @@ abstract class Command
|
||||
* 设置控制台
|
||||
* @param Console $console
|
||||
*/
|
||||
public function setConsole(Console $console = null): void
|
||||
public function setConsole(?Console $console = null): void
|
||||
{
|
||||
$this->console = $console;
|
||||
}
|
||||
@ -285,7 +285,7 @@ abstract class Command
|
||||
* @param mixed $default 默认值
|
||||
* @return Command
|
||||
*/
|
||||
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
|
||||
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
$this->definition->addArgument(new Argument($name, $mode, $description, $default));
|
||||
|
||||
@ -301,7 +301,7 @@ abstract class Command
|
||||
* @param mixed $default 默认值
|
||||
* @return Command
|
||||
*/
|
||||
public function addOption(string $name, string $shortcut = null, int $mode = null, string $description = '', $default = null)
|
||||
public function addOption(string $name, ?string $shortcut = null, ?int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
$this->definition->addOption(new Option($name, $shortcut, $mode, $description, $default));
|
||||
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/Input.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/Input.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/LICENSE
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/LICENSE
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/Output.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/Output.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2020 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/Table.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/Table.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
1
vendor/topthink/framework/src/think/console/bin/README.md
vendored
Normal file
1
vendor/topthink/framework/src/think/console/bin/README.md
vendored
Normal file
@ -0,0 +1 @@
|
||||
console 工具使用 hiddeninput.exe 在 windows 上隐藏密码输入,该二进制文件由第三方提供,相关源码和其他细节可以在 [Hidden Input](https://github.com/Seldaek/hidden-input) 找到。
|
||||
BIN
vendor/topthink/framework/src/think/console/bin/hiddeninput.exe
vendored
Normal file
BIN
vendor/topthink/framework/src/think/console/bin/hiddeninput.exe
vendored
Normal file
Binary file not shown.
2
vendor/topthink/framework/src/think/console/command/Clear.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/Clear.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006-2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/Help.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/Help.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/Lists.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/Lists.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/command/Make.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/Make.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/console/command/RouteList.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/console/command/RouteList.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006-2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -54,7 +54,7 @@ class RouteList extends Command
|
||||
file_put_contents($filename, 'Route List' . PHP_EOL . $content);
|
||||
}
|
||||
|
||||
protected function getRouteList(string $dir = null): string
|
||||
protected function getRouteList(?string $dir = null): string
|
||||
{
|
||||
$this->app->route->clear();
|
||||
$this->app->route->lazy(false);
|
||||
|
||||
4
vendor/topthink/framework/src/think/console/command/RunServer.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/console/command/RunServer.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2015 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -56,7 +56,7 @@ class RunServer extends Command
|
||||
}
|
||||
|
||||
$command = sprintf(
|
||||
'%s -S %s:%d -t %s %s',
|
||||
'"%s" -S %s:%d -t %s %s',
|
||||
PHP_BINARY,
|
||||
$host,
|
||||
$port,
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/ServiceDiscover.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/ServiceDiscover.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/VendorPublish.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/VendorPublish.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/Version.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/Version.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006-2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Command.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Command.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Controller.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Controller.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Event.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Event.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Listener.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Listener.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Middleware.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Middleware.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Model.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Model.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Service.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Service.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Subscribe.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Subscribe.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/console/command/make/Validate.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/make/Validate.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/command/make/stubs/command.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/command.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.api.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.plain.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.plain.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/controller.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/event.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/event.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/listener.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/listener.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/middleware.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/middleware.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/model.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/model.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/service.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/service.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/subscribe.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/subscribe.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/validate.stub
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/make/stubs/validate.stub
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/optimize/Route.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/command/optimize/Route.php
vendored
Executable file → Normal file
@ -40,7 +40,7 @@ class Route extends Command
|
||||
$output->writeln('<info>Succeed!</info>');
|
||||
}
|
||||
|
||||
protected function buildRouteCache(string $dir = null): string
|
||||
protected function buildRouteCache(?string $dir = null): string
|
||||
{
|
||||
$this->app->route->clear();
|
||||
$this->app->route->lazy(false);
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/command/optimize/Schema.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/command/optimize/Schema.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/input/Argument.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/console/input/Argument.php
vendored
Executable file → Normal file
@ -54,7 +54,7 @@ class Argument
|
||||
* @param mixed $default 默认值 (仅 self::OPTIONAL 类型有效)
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $name, int $mode = null, string $description = '', $default = null)
|
||||
public function __construct(string $name, ?int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
if (null === $mode) {
|
||||
$mode = self::OPTIONAL;
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/input/Definition.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/input/Definition.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/input/Option.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/input/Option.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Ask.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Ask.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Descriptor.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Descriptor.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Formatter.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Formatter.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Question.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/Question.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/descriptor/Console.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/descriptor/Console.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Buffer.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Buffer.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Console.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Console.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Nothing.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/driver/Nothing.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/console/output/formatter/Stack.php
vendored
Executable file → Normal file
4
vendor/topthink/framework/src/think/console/output/formatter/Stack.php
vendored
Executable file → Normal file
@ -28,7 +28,7 @@ class Stack
|
||||
* 构造方法
|
||||
* @param Style|null $emptyStyle
|
||||
*/
|
||||
public function __construct(Style $emptyStyle = null)
|
||||
public function __construct(?Style $emptyStyle = null)
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle ?: new Style();
|
||||
$this->reset();
|
||||
@ -57,7 +57,7 @@ class Stack
|
||||
* @return Style
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function pop(Style $style = null): Style
|
||||
public function pop(?Style $style = null): Style
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return $this->emptyStyle;
|
||||
|
||||
0
vendor/topthink/framework/src/think/console/output/formatter/Style.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/formatter/Style.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/question/Choice.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/question/Choice.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/question/Confirmation.php
vendored
Executable file → Normal file
0
vendor/topthink/framework/src/think/console/output/question/Confirmation.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
2
vendor/topthink/framework/src/think/contract/LogHandlerInterface.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/contract/LogHandlerInterface.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006-2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
14
vendor/topthink/framework/src/think/contract/ModelRelationInterface.php
vendored
Executable file → Normal file
14
vendor/topthink/framework/src/think/contract/ModelRelationInterface.php
vendored
Executable file → Normal file
@ -2,7 +2,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// | Copyright (c) 2006~2025 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -28,7 +28,7 @@ interface ModelRelationInterface
|
||||
* @param Closure $closure 闭包查询条件
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRelation(array $subRelation = [], Closure $closure = null);
|
||||
public function getRelation(array $subRelation = [], ?Closure $closure = null);
|
||||
|
||||
/**
|
||||
* 预载入关联查询
|
||||
@ -39,7 +39,7 @@ interface ModelRelationInterface
|
||||
* @param Closure $closure 闭包条件
|
||||
* @return void
|
||||
*/
|
||||
public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null): void;
|
||||
public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, ?Closure $closure = null): void;
|
||||
|
||||
/**
|
||||
* 预载入关联查询
|
||||
@ -50,7 +50,7 @@ interface ModelRelationInterface
|
||||
* @param Closure $closure 闭包条件
|
||||
* @return void
|
||||
*/
|
||||
public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null): void;
|
||||
public function eagerlyResult(Model $result, string $relation, array $subRelation = [], ?Closure $closure = null): void;
|
||||
|
||||
/**
|
||||
* 关联统计
|
||||
@ -62,7 +62,7 @@ interface ModelRelationInterface
|
||||
* @param string $name 统计字段别名
|
||||
* @return integer
|
||||
*/
|
||||
public function relationCount(Model $result, Closure $closure, string $aggregate = 'count', string $field = '*', string &$name = null);
|
||||
public function relationCount(Model $result, Closure $closure, string $aggregate = 'count', string $field = '*', ?string &$name = null);
|
||||
|
||||
/**
|
||||
* 创建关联统计子查询
|
||||
@ -73,7 +73,7 @@ interface ModelRelationInterface
|
||||
* @param string $name 统计字段别名
|
||||
* @return string
|
||||
*/
|
||||
public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string;
|
||||
public function getRelationCountQuery(?Closure $closure = null, string $aggregate = 'count', string $field = '*', ?string &$name = null): string;
|
||||
|
||||
/**
|
||||
* 根据关联条件查询当前模型
|
||||
@ -84,7 +84,7 @@ interface ModelRelationInterface
|
||||
* @param string $joinType JOIN类型
|
||||
* @return Query
|
||||
*/
|
||||
public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', Query $query = null): Query;
|
||||
public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', ?Query $query = null): Query;
|
||||
|
||||
/**
|
||||
* 根据关联条件查询当前模型
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user