提交的内容
This commit is contained in:
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;
|
||||
|
||||
558
vendor/topthink/framework/src/think/Container.php
vendored
558
vendor/topthink/framework/src/think/Container.php
vendored
@ -1,558 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace think;
|
||||
|
||||
use ArrayAccess;
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use Countable;
|
||||
use InvalidArgumentException;
|
||||
use IteratorAggregate;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionFunction;
|
||||
use ReflectionFunctionAbstract;
|
||||
use ReflectionMethod;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\exception\FuncNotFoundException;
|
||||
use think\helper\Str;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* 容器管理类 支持PSR-11
|
||||
*/
|
||||
class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, Countable
|
||||
{
|
||||
/**
|
||||
* 容器对象实例
|
||||
* @var Container|Closure
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* 容器中的对象实例
|
||||
* @var array
|
||||
*/
|
||||
protected $instances = [];
|
||||
|
||||
/**
|
||||
* 容器绑定标识
|
||||
* @var array
|
||||
*/
|
||||
protected $bind = [];
|
||||
|
||||
/**
|
||||
* 容器回调
|
||||
* @var array
|
||||
*/
|
||||
protected $invokeCallback = [];
|
||||
|
||||
/**
|
||||
* 获取当前容器的实例(单例)
|
||||
* @access public
|
||||
* @return static
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(static::$instance)) {
|
||||
static::$instance = new static;
|
||||
}
|
||||
|
||||
if (static::$instance instanceof Closure) {
|
||||
return (static::$instance)();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前容器的实例
|
||||
* @access public
|
||||
* @param object|Closure $instance
|
||||
* @return void
|
||||
*/
|
||||
public static function setInstance($instance): void
|
||||
{
|
||||
static::$instance = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个容器对象回调
|
||||
*
|
||||
* @param string|Closure $abstract
|
||||
* @param Closure|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function resolving(string|Closure $abstract, Closure $callback = null): void
|
||||
{
|
||||
if ($abstract instanceof Closure) {
|
||||
$this->invokeCallback['*'][] = $abstract;
|
||||
return;
|
||||
}
|
||||
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
$this->invokeCallback[$abstract][] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取容器中的对象实例 不存在则创建
|
||||
* @template T
|
||||
* @param string|class-string<T> $abstract 类名或者标识
|
||||
* @param array $vars 变量
|
||||
* @param bool $newInstance 是否每次创建新的实例
|
||||
* @return T|object
|
||||
*/
|
||||
public static function pull(string $abstract, array $vars = [], bool $newInstance = false)
|
||||
{
|
||||
return static::getInstance()->make($abstract, $vars, $newInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取容器中的对象实例
|
||||
* @template T
|
||||
* @param string|class-string<T> $abstract 类名或者标识
|
||||
* @return T|object
|
||||
*/
|
||||
public function get(string $abstract)
|
||||
{
|
||||
if ($this->has($abstract)) {
|
||||
return $this->make($abstract);
|
||||
}
|
||||
|
||||
throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定一个类、闭包、实例、接口实现到容器
|
||||
* @access public
|
||||
* @param string|array $abstract 类标识、接口
|
||||
* @param mixed $concrete 要绑定的类、闭包或者实例
|
||||
* @return $this
|
||||
*/
|
||||
public function bind(string|array $abstract, $concrete = null)
|
||||
{
|
||||
if (is_array($abstract)) {
|
||||
foreach ($abstract as $key => $val) {
|
||||
$this->bind($key, $val);
|
||||
}
|
||||
} elseif ($concrete instanceof Closure) {
|
||||
$this->bind[$abstract] = $concrete;
|
||||
} elseif (is_object($concrete)) {
|
||||
$this->instance($abstract, $concrete);
|
||||
} else {
|
||||
$abstract = $this->getAlias($abstract);
|
||||
if ($abstract != $concrete) {
|
||||
$this->bind[$abstract] = $concrete;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据别名获取真实类名
|
||||
* @param string $abstract
|
||||
* @return string
|
||||
*/
|
||||
public function getAlias(string $abstract): string
|
||||
{
|
||||
if (isset($this->bind[$abstract])) {
|
||||
$bind = $this->bind[$abstract];
|
||||
|
||||
if (is_string($bind)) {
|
||||
return $this->getAlias($bind);
|
||||
}
|
||||
}
|
||||
|
||||
return $abstract;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定一个类实例到容器
|
||||
* @access public
|
||||
* @param string $abstract 类名或者标识
|
||||
* @param object $instance 类的实例
|
||||
* @return $this
|
||||
*/
|
||||
public function instance(string $abstract, $instance)
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
$this->instances[$abstract] = $instance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断容器中是否存在类及标识
|
||||
* @access public
|
||||
* @param string $abstract 类名或者标识
|
||||
* @return bool
|
||||
*/
|
||||
public function bound(string $abstract): bool
|
||||
{
|
||||
return isset($this->bind[$abstract]) || isset($this->instances[$abstract]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断容器中是否存在类及标识
|
||||
* @access public
|
||||
* @param string $name 类名或者标识
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return $this->bound($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断容器中是否存在对象实例
|
||||
* @access public
|
||||
* @param string $abstract 类名或者标识
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $abstract): bool
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
return isset($this->instances[$abstract]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类的实例 已经存在则直接获取
|
||||
* @template T
|
||||
* @param string|class-string<T> $abstract 类名或者标识
|
||||
* @param array $vars 变量
|
||||
* @param bool $newInstance 是否每次创建新的实例
|
||||
* @return T|object
|
||||
*/
|
||||
public function make(string $abstract, array $vars = [], bool $newInstance = false)
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
if (isset($this->instances[$abstract]) && !$newInstance) {
|
||||
return $this->instances[$abstract];
|
||||
}
|
||||
|
||||
if (isset($this->bind[$abstract]) && $this->bind[$abstract] instanceof Closure) {
|
||||
$object = $this->invokeFunction($this->bind[$abstract], $vars);
|
||||
} else {
|
||||
$object = $this->invokeClass($abstract, $vars);
|
||||
}
|
||||
|
||||
if (!$newInstance) {
|
||||
$this->instances[$abstract] = $object;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除容器中的对象实例
|
||||
* @access public
|
||||
* @param string $name 类名或者标识
|
||||
* @return void
|
||||
*/
|
||||
public function delete(string $name)
|
||||
{
|
||||
$name = $this->getAlias($name);
|
||||
|
||||
if (isset($this->instances[$name])) {
|
||||
unset($this->instances[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行函数或者闭包方法 支持参数调用
|
||||
* @access public
|
||||
* @param string|Closure $function 函数或者闭包
|
||||
* @param array $vars 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function invokeFunction(string|Closure $function, array $vars = [])
|
||||
{
|
||||
try {
|
||||
$reflect = new ReflectionFunction($function);
|
||||
} catch (ReflectionException $e) {
|
||||
throw new FuncNotFoundException("function not exists: {$function}()", $function, $e);
|
||||
}
|
||||
|
||||
$args = $this->bindParams($reflect, $vars);
|
||||
|
||||
return $function(...$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用反射执行类的方法 支持参数绑定
|
||||
* @access public
|
||||
* @param mixed $method 方法
|
||||
* @param array $vars 参数
|
||||
* @param bool $accessible 设置是否可访问
|
||||
* @return mixed
|
||||
*/
|
||||
public function invokeMethod($method, array $vars = [], bool $accessible = false)
|
||||
{
|
||||
if (is_array($method)) {
|
||||
[$class, $method] = $method;
|
||||
|
||||
$class = is_object($class) ? $class : $this->invokeClass($class);
|
||||
} else {
|
||||
// 静态方法
|
||||
[$class, $method] = explode('::', $method);
|
||||
}
|
||||
|
||||
try {
|
||||
$reflect = new ReflectionMethod($class, $method);
|
||||
} catch (ReflectionException $e) {
|
||||
$class = is_object($class) ? $class::class : $class;
|
||||
throw new FuncNotFoundException('method not exists: ' . $class . '::' . $method . '()', "{$class}::{$method}", $e);
|
||||
}
|
||||
|
||||
$args = $this->bindParams($reflect, $vars);
|
||||
|
||||
if ($accessible) {
|
||||
$reflect->setAccessible($accessible);
|
||||
}
|
||||
|
||||
return $reflect->invokeArgs(is_object($class) ? $class : null, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用反射执行类的方法 支持参数绑定
|
||||
* @access public
|
||||
* @param object $instance 对象实例
|
||||
* @param mixed $reflect 反射类
|
||||
* @param array $vars 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function invokeReflectMethod($instance, $reflect, array $vars = [])
|
||||
{
|
||||
$args = $this->bindParams($reflect, $vars);
|
||||
|
||||
return $reflect->invokeArgs($instance, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用反射执行callable 支持参数绑定
|
||||
* @access public
|
||||
* @param mixed $callable
|
||||
* @param array $vars 参数
|
||||
* @param bool $accessible 设置是否可访问
|
||||
* @return mixed
|
||||
*/
|
||||
public function invoke($callable, array $vars = [], bool $accessible = false)
|
||||
{
|
||||
if ($callable instanceof Closure) {
|
||||
return $this->invokeFunction($callable, $vars);
|
||||
} elseif (is_string($callable) && !str_contains($callable, '::')) {
|
||||
return $this->invokeFunction($callable, $vars);
|
||||
} else {
|
||||
return $this->invokeMethod($callable, $vars, $accessible);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用反射执行类的实例化 支持依赖注入
|
||||
* @access public
|
||||
* @param string $class 类名
|
||||
* @param array $vars 参数
|
||||
* @return mixed
|
||||
*/
|
||||
public function invokeClass(string $class, array $vars = [])
|
||||
{
|
||||
try {
|
||||
$reflect = new ReflectionClass($class);
|
||||
} catch (ReflectionException $e) {
|
||||
throw new ClassNotFoundException('class not exists: ' . $class, $class, $e);
|
||||
}
|
||||
|
||||
if ($reflect->hasMethod('__make')) {
|
||||
$method = $reflect->getMethod('__make');
|
||||
if ($method->isPublic() && $method->isStatic()) {
|
||||
$args = $this->bindParams($method, $vars);
|
||||
$object = $method->invokeArgs(null, $args);
|
||||
$this->invokeAfter($class, $object);
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
$constructor = $reflect->getConstructor();
|
||||
|
||||
$args = $constructor ? $this->bindParams($constructor, $vars) : [];
|
||||
|
||||
$object = $reflect->newInstanceArgs($args);
|
||||
|
||||
$this->invokeAfter($class, $object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行invokeClass回调
|
||||
* @access protected
|
||||
* @param string $class 对象类名
|
||||
* @param object $object 容器对象实例
|
||||
* @return void
|
||||
*/
|
||||
protected function invokeAfter(string $class, $object): void
|
||||
{
|
||||
if (isset($this->invokeCallback['*'])) {
|
||||
foreach ($this->invokeCallback['*'] as $callback) {
|
||||
$callback($object, $this);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->invokeCallback[$class])) {
|
||||
foreach ($this->invokeCallback[$class] as $callback) {
|
||||
$callback($object, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定参数
|
||||
* @access protected
|
||||
* @param ReflectionFunctionAbstract $reflect 反射类
|
||||
* @param array $vars 参数
|
||||
* @return array
|
||||
*/
|
||||
protected function bindParams(ReflectionFunctionAbstract $reflect, array $vars = []): array
|
||||
{
|
||||
if ($reflect->getNumberOfParameters() == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 判断数组类型 数字数组时按顺序绑定参数
|
||||
reset($vars);
|
||||
$type = key($vars) === 0 ? 1 : 0;
|
||||
$params = $reflect->getParameters();
|
||||
$args = [];
|
||||
|
||||
foreach ($params as $param) {
|
||||
$name = $param->getName();
|
||||
$lowerName = Str::snake($name);
|
||||
$reflectionType = $param->getType();
|
||||
|
||||
if ($param->isVariadic()) {
|
||||
return array_merge($args, array_values($vars));
|
||||
} elseif ($reflectionType && $reflectionType instanceof ReflectionNamedType && $reflectionType->isBuiltin() === false) {
|
||||
$args[] = $this->getObjectParam($reflectionType->getName(), $vars);
|
||||
} elseif (1 == $type && !empty($vars)) {
|
||||
$args[] = array_shift($vars);
|
||||
} elseif (0 == $type && array_key_exists($name, $vars)) {
|
||||
$args[] = $vars[$name];
|
||||
} elseif (0 == $type && array_key_exists($lowerName, $vars)) {
|
||||
$args[] = $vars[$lowerName];
|
||||
} elseif ($param->isDefaultValueAvailable()) {
|
||||
$args[] = $param->getDefaultValue();
|
||||
} else {
|
||||
throw new InvalidArgumentException('method param miss:' . $name);
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建工厂对象实例
|
||||
* @param string $name 工厂类名
|
||||
* @param string $namespace 默认命名空间
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
* @deprecated
|
||||
* @access public
|
||||
*/
|
||||
public static function factory(string $name, string $namespace = '', ...$args)
|
||||
{
|
||||
$class = str_contains($name, '\\') ? $name : $namespace . ucwords($name);
|
||||
|
||||
return Container::getInstance()->invokeClass($class, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象类型的参数值
|
||||
* @access protected
|
||||
* @param string $className 类名
|
||||
* @param array $vars 参数
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getObjectParam(string $className, array &$vars)
|
||||
{
|
||||
$array = $vars;
|
||||
$value = array_shift($array);
|
||||
|
||||
if ($value instanceof $className) {
|
||||
$result = $value;
|
||||
array_shift($vars);
|
||||
} else {
|
||||
$result = $this->make($className);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->bind($name, $value);
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
public function __isset($name): bool
|
||||
{
|
||||
return $this->exists($name);
|
||||
}
|
||||
|
||||
public function __unset($name)
|
||||
{
|
||||
$this->delete($name);
|
||||
}
|
||||
|
||||
public function offsetExists(mixed $key): bool
|
||||
{
|
||||
return $this->exists($key);
|
||||
}
|
||||
|
||||
public function offsetGet(mixed $key): mixed
|
||||
{
|
||||
return $this->make($key);
|
||||
}
|
||||
|
||||
public function offsetSet(mixed $key, mixed $value): void
|
||||
{
|
||||
$this->bind($key, $value);
|
||||
}
|
||||
|
||||
public function offsetUnset(mixed $key): void
|
||||
{
|
||||
$this->delete($key);
|
||||
}
|
||||
|
||||
//Countable
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->instances);
|
||||
}
|
||||
|
||||
//IteratorAggregate
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return new ArrayIterator($this->instances);
|
||||
}
|
||||
}
|
||||
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 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
99
vendor/topthink/framework/src/think/Facade.php
vendored
99
vendor/topthink/framework/src/think/Facade.php
vendored
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: liu21st <liu21st@gmail.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace think;
|
||||
|
||||
/**
|
||||
* Facade管理类
|
||||
*/
|
||||
class Facade
|
||||
{
|
||||
/**
|
||||
* 始终创建新的对象实例
|
||||
* @var bool
|
||||
*/
|
||||
protected static $alwaysNewInstance;
|
||||
|
||||
/**
|
||||
* 创建Facade实例
|
||||
* @static
|
||||
* @access protected
|
||||
* @param string $class 类名或标识
|
||||
* @param array $args 变量
|
||||
* @param bool $newInstance 是否每次创建新的实例
|
||||
* @return object
|
||||
*/
|
||||
protected static function createFacade(string $class = '', array $args = [], bool $newInstance = false)
|
||||
{
|
||||
$class = $class ?: static::class;
|
||||
|
||||
$facadeClass = static::getFacadeClass();
|
||||
|
||||
if ($facadeClass) {
|
||||
$class = $facadeClass;
|
||||
}
|
||||
|
||||
if (static::$alwaysNewInstance) {
|
||||
$newInstance = true;
|
||||
}
|
||||
|
||||
return Container::getInstance()->make($class, $args, $newInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前Facade对应类名
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeClass()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 带参数实例化当前Facade类
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function instance(...$args)
|
||||
{
|
||||
if (__CLASS__ != static::class) {
|
||||
return self::createFacade('', $args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用类的实例
|
||||
* @access public
|
||||
* @param string $class 类名或者标识
|
||||
* @param array|true $args 变量
|
||||
* @param bool $newInstance 是否每次创建新的实例
|
||||
* @return object
|
||||
*/
|
||||
public static function make(string $class, $args = [], $newInstance = false)
|
||||
{
|
||||
if (__CLASS__ != static::class) {
|
||||
return self::__callStatic('make', func_get_args());
|
||||
}
|
||||
|
||||
if (true === $args) {
|
||||
// 总是创建新的实例化对象
|
||||
$newInstance = true;
|
||||
$args = [];
|
||||
}
|
||||
|
||||
return self::createFacade($class, $args, $newInstance);
|
||||
}
|
||||
|
||||
// 调用实际类的方法
|
||||
public static function __callStatic($method, $params)
|
||||
{
|
||||
return call_user_func_array([static::createFacade(), $method], $params);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
1702
vendor/topthink/framework/src/think/Validate.php
vendored
1702
vendor/topthink/framework/src/think/Validate.php
vendored
File diff suppressed because it is too large
Load Diff
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;
|
||||
|
||||
/**
|
||||
* 根据关联条件查询当前模型
|
||||
|
||||
2
vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/contract/SessionHandlerInterface.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 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
9
vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php
vendored
Executable file → Normal file
9
vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.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 )
|
||||
// +----------------------------------------------------------------------
|
||||
@ -19,7 +19,6 @@ interface TemplateHandlerInterface
|
||||
{
|
||||
/**
|
||||
* 检测是否存在模板文件
|
||||
* @access public
|
||||
* @param string $template 模板文件或者模板规则
|
||||
* @return bool
|
||||
*/
|
||||
@ -27,7 +26,6 @@ interface TemplateHandlerInterface
|
||||
|
||||
/**
|
||||
* 渲染模板文件
|
||||
* @access public
|
||||
* @param string $template 模板文件
|
||||
* @param array $data 模板变量
|
||||
* @return void
|
||||
@ -36,7 +34,6 @@ interface TemplateHandlerInterface
|
||||
|
||||
/**
|
||||
* 渲染模板内容
|
||||
* @access public
|
||||
* @param string $content 模板内容
|
||||
* @param array $data 模板变量
|
||||
* @return void
|
||||
@ -45,7 +42,6 @@ interface TemplateHandlerInterface
|
||||
|
||||
/**
|
||||
* 配置模板引擎
|
||||
* @access private
|
||||
* @param array $config 参数
|
||||
* @return void
|
||||
*/
|
||||
@ -53,9 +49,8 @@ interface TemplateHandlerInterface
|
||||
|
||||
/**
|
||||
* 获取模板引擎配置
|
||||
* @access public
|
||||
* @param string $name 参数名
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(string $name);
|
||||
}
|
||||
|
||||
2
vendor/topthink/framework/src/think/event/AppInit.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/AppInit.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/event/HttpEnd.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/HttpEnd.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/event/HttpRun.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/HttpRun.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/event/LogRecord.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/LogRecord.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/event/LogWrite.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/LogWrite.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/event/RouteLoaded.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/event/RouteLoaded.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/exception/ClassNotFoundException.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/exception/ClassNotFoundException.php
vendored
Executable file → Normal file
@ -17,7 +17,7 @@ use Throwable;
|
||||
|
||||
class ClassNotFoundException extends RuntimeException implements NotFoundExceptionInterface
|
||||
{
|
||||
public function __construct(string $message, protected string $class = '', Throwable $previous = null)
|
||||
public function __construct(string $message, protected string $class = '', ?Throwable $previous = null)
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
|
||||
2
vendor/topthink/framework/src/think/exception/ErrorException.php
vendored
Executable file → Normal file
2
vendor/topthink/framework/src/think/exception/ErrorException.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 )
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user