diff --git a/src/lang/zh-cn.php b/src/lang/zh-cn.php index a546330a06..88fbcb628d 100644 --- a/src/lang/zh-cn.php +++ b/src/lang/zh-cn.php @@ -12,137 +12,137 @@ // 核心中文语言包 return [ // 系统错误提示 - 'Undefined variable' => '未定义变量', - 'Undefined index' => '未定义数组索引', - 'Undefined offset' => '未定义数组下标', - 'Parse error' => '语法解析错误', - 'Type error' => '类型错误', - 'Fatal error' => '致命错误', - 'syntax error' => '语法错误', + 'Undefined variable' => '未定义变量', + 'Undefined index' => '未定义数组索引', + 'Undefined offset' => '未定义数组下标', + 'Parse error' => '语法解析错误', + 'Type error' => '类型错误', + 'Fatal error' => '致命错误', + 'syntax error' => '语法错误', // 框架核心错误提示 - 'dispatch type not support' => '不支持的调度类型', - 'method param miss' => '方法参数错误', - 'method not exists' => '方法不存在', - 'function not exists' => '函数不存在', - 'app not exists' => '应用不存在', - 'controller not exists' => '控制器不存在', - 'class not exists' => '类不存在', - 'property not exists' => '类的属性不存在', - 'template not exists' => '模板文件不存在', - 'illegal controller name' => '非法的控制器名称', - 'illegal action name' => '非法的操作名称', - 'url suffix deny' => '禁止的URL后缀访问', - 'Undefined cache config' => '缓存配置未定义', - 'Route Not Found' => '当前访问路由未定义或不匹配', - 'Undefined db config' => '数据库配置未定义', - 'Undefined log config' => '日志配置未定义', - 'Undefined db type' => '未定义数据库类型', - 'variable type error' => '变量类型错误', - 'PSR-4 error' => 'PSR-4 规范错误', - 'not support type' => '不支持的分页索引字段类型', - 'not support total' => '简洁模式下不能获取数据总数', - 'not support last' => '简洁模式下不能获取最后一页', - 'error session handler' => '错误的SESSION处理器类', - 'not allow php tag' => '模板不允许使用PHP语法', - 'not support' => '不支持', - 'database config error' => '数据库配置信息错误', - 'redisd master' => 'Redisd 主服务器错误', - 'redisd slave' => 'Redisd 从服务器错误', - 'must run at sae' => '必须在SAE运行', - 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', - 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', - 'fields not exists' => '数据表字段不存在', - 'where express error' => '查询表达式错误', - 'no data to update' => '没有任何数据需要更新', - 'miss data to insert' => '缺少需要写入的数据', - 'miss complex primary data' => '缺少复合主键数据', - 'miss update condition' => '缺少更新条件', - 'model data Not Found' => '模型数据不存在', - 'table data not Found' => '表数据不存在', - 'delete without condition' => '没有条件不会执行删除操作', - 'miss relation data' => '缺少关联表数据', - 'tag attr must' => '模板标签属性必须', - 'tag error' => '模板标签错误', - 'cache write error' => '缓存写入失败', - 'sae mc write error' => 'SAE mc 写入错误', - 'route name not exists' => '路由标识不存在(或参数不够)', - 'invalid request' => '非法请求', - 'bind attr has exists' => '模型的属性已经存在', - 'relation data not exists' => '关联数据不存在', - 'relation not support' => '关联不支持', - 'chunk not support order' => 'Chunk不支持调用order方法', - 'route pattern error' => '路由变量规则定义错误', - 'route behavior will not support' => '路由行为废弃(使用中间件替代)', - 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', + 'dispatch type not support' => '不支持的调度类型', + 'method param miss' => '方法参数错误', + 'method not exists' => '方法不存在', + 'function not exists' => '函数不存在', + 'app not exists' => '应用不存在', + 'controller not exists' => '控制器不存在', + 'class not exists' => '类不存在', + 'property not exists' => '类的属性不存在', + 'template not exists' => '模板文件不存在', + 'illegal controller name' => '非法的控制器名称', + 'illegal action name' => '非法的操作名称', + 'url suffix deny' => '禁止的URL后缀访问', + 'Undefined cache config' => '缓存配置未定义', + 'Route Not Found' => '当前访问路由未定义或不匹配', + 'Undefined db config' => '数据库配置未定义', + 'Undefined log config' => '日志配置未定义', + 'Undefined db type' => '未定义数据库类型', + 'variable type error' => '变量类型错误', + 'PSR-4 error' => 'PSR-4 规范错误', + 'not support type' => '不支持的分页索引字段类型', + 'not support total' => '简洁模式下不能获取数据总数', + 'not support last' => '简洁模式下不能获取最后一页', + 'error session handler' => '错误的SESSION处理器类', + 'not allow php tag' => '模板不允许使用PHP语法', + 'not support' => '不支持', + 'database config error' => '数据库配置信息错误', + 'redisd master' => 'Redisd 主服务器错误', + 'redisd slave' => 'Redisd 从服务器错误', + 'must run at sae' => '必须在SAE运行', + 'memcache init error' => '未开通Memcache服务,请在SAE管理平台初始化Memcache服务', + 'KVDB init error' => '没有初始化KVDB,请在SAE管理平台初始化KVDB服务', + 'fields not exists' => '数据表字段不存在', + 'where express error' => '查询表达式错误', + 'no data to update' => '没有任何数据需要更新', + 'miss data to insert' => '缺少需要写入的数据', + 'miss complex primary data' => '缺少复合主键数据', + 'miss update condition' => '缺少更新条件', + 'model data Not Found' => '模型数据不存在', + 'table data not Found' => '表数据不存在', + 'delete without condition' => '没有条件不会执行删除操作', + 'miss relation data' => '缺少关联表数据', + 'tag attr must' => '模板标签属性必须', + 'tag error' => '模板标签错误', + 'cache write error' => '缓存写入失败', + 'sae mc write error' => 'SAE mc 写入错误', + 'route name not exists' => '路由标识不存在(或参数不够)', + 'invalid request' => '非法请求', + 'bind attr has exists' => '模型的属性已经存在', + 'relation data not exists' => '关联数据不存在', + 'relation not support' => '关联不支持', + 'chunk not support order' => 'Chunk不支持调用order方法', + 'route pattern error' => '路由变量规则定义错误', + 'route behavior will not support' => '路由行为废弃(使用中间件替代)', + 'closure not support cache(true)' => '使用闭包查询不支持cache(true),请指定缓存Key', // 上传错误信息 - 'unknown upload error' => '未知上传错误!', - 'file write error' => '文件写入失败!', - 'upload temp dir not found' => '找不到临时文件夹!', - 'no file to uploaded' => '没有文件被上传!', - 'only the portion of file is uploaded' => '文件只有部分被上传!', - 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', - 'upload write error' => '文件上传保存错误!', - 'has the same filename: {:filename}' => '存在同名文件:{:filename}', - 'upload illegal files' => '非法上传文件', - 'illegal image files' => '非法图片文件', - 'extensions to upload is not allowed' => '上传文件后缀不允许', - 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', - 'filesize not match' => '上传文件大小不符!', - 'directory {:path} creation failed' => '目录 {:path} 创建失败!', + 'unknown upload error' => '未知上传错误!', + 'file write error' => '文件写入失败!', + 'upload temp dir not found' => '找不到临时文件夹!', + 'no file to uploaded' => '没有文件被上传!', + 'only the portion of file is uploaded' => '文件只有部分被上传!', + 'upload File size exceeds the maximum value' => '上传文件大小超过了最大值!', + 'upload write error' => '文件上传保存错误!', + 'has the same filename: {:filename}' => '存在同名文件:{:filename}', + 'upload illegal files' => '非法上传文件', + 'illegal image files' => '非法图片文件', + 'extensions to upload is not allowed' => '上传文件后缀不允许', + 'mimetype to upload is not allowed' => '上传文件MIME类型不允许!', + 'filesize not match' => '上传文件大小不符!', + 'directory {:path} creation failed' => '目录 {:path} 创建失败!', - 'The middleware must return Response instance' => '中间件方法必须返回Response对象实例', - 'The queue was exhausted, with no response returned' => '中间件队列为空', + 'The middleware must return Response instance' => '中间件方法必须返回Response对象实例', + 'The queue was exhausted, with no response returned' => '中间件队列为空', // Validate Error Message - ':attribute require' => ':attribute不能为空', - ':attribute must' => ':attribute必须', - ':attribute must be numeric' => ':attribute必须是数字', - ':attribute must be integer' => ':attribute必须是整数', - ':attribute must be float' => ':attribute必须是浮点数', - ':attribute must be bool' => ':attribute必须是布尔值', - ':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 not a valid datetime' => ':attribute不是一个有效的日期或时间格式', - ':attribute not a valid file' => ':attribute不是有效的上传文件', - ':attribute not a valid image' => ':attribute不是有效的图像文件', - ':attribute must be alpha' => ':attribute只能是字母', - ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', - ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', - ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', - ':attribute must be chinese' => ':attribute只能是汉字', - ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', - ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', + ':attribute require' => ':attribute不能为空', + ':attribute must' => ':attribute必须', + ':attribute must be numeric' => ':attribute必须是数字', + ':attribute must be integer' => ':attribute必须是整数', + ':attribute must be float' => ':attribute必须是浮点数', + ':attribute must be bool' => ':attribute必须是布尔值', + ':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 not a valid datetime' => ':attribute不是一个有效的日期或时间格式', + ':attribute not a valid file' => ':attribute不是有效的上传文件', + ':attribute not a valid image' => ':attribute不是有效的图像文件', + ':attribute must be alpha' => ':attribute只能是字母', + ':attribute must be alpha-numeric' => ':attribute只能是字母和数字', + ':attribute must be alpha-numeric, dash, underscore' => ':attribute只能是字母、数字和下划线_及破折号-', + ':attribute not a valid domain or ip' => ':attribute不是有效的域名或者IP', + ':attribute must be chinese' => ':attribute只能是汉字', + ':attribute must be chinese or alpha' => ':attribute只能是汉字、字母', + ':attribute must be chinese,alpha-numeric' => ':attribute只能是汉字、字母和数字', ':attribute must be chinese,alpha-numeric,underscore, dash' => ':attribute只能是汉字、字母、数字和下划线_及破折号-', - ':attribute not a valid url' => ':attribute不是有效的URL地址', - ':attribute not a valid ip' => ':attribute不是有效的IP地址', - ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', - ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', - ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', - ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', - ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', - 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', - 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', - 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', - ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', - ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', - ':attribute not within :rule' => '不在有效期内 :rule', - 'access IP is not allowed' => '不允许的IP访问', - 'access IP denied' => '禁止的IP访问', - ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', - ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', - ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', - ':attribute must greater than :rule' => ':attribute必须大于 :rule', - ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', - ':attribute must less than :rule' => ':attribute必须小于 :rule', - ':attribute must equal :rule' => ':attribute必须等于 :rule', - ':attribute has exists' => ':attribute已存在', - ':attribute not conform to the rules' => ':attribute不符合指定规则', - 'invalid Request method' => '无效的请求类型', - 'invalid token' => '令牌数据无效', - 'not conform to the rules' => '规则错误', + ':attribute not a valid url' => ':attribute不是有效的URL地址', + ':attribute not a valid ip' => ':attribute不是有效的IP地址', + ':attribute must be dateFormat of :rule' => ':attribute必须使用日期格式 :rule', + ':attribute must be in :rule' => ':attribute必须在 :rule 范围内', + ':attribute be notin :rule' => ':attribute不能在 :rule 范围内', + ':attribute must between :1 - :2' => ':attribute只能在 :1 - :2 之间', + ':attribute not between :1 - :2' => ':attribute不能在 :1 - :2 之间', + 'size of :attribute must be :rule' => ':attribute长度不符合要求 :rule', + 'max size of :attribute must be :rule' => ':attribute长度不能超过 :rule', + 'min size of :attribute must be :rule' => ':attribute长度不能小于 :rule', + ':attribute cannot be less than :rule' => ':attribute日期不能小于 :rule', + ':attribute cannot exceed :rule' => ':attribute日期不能超过 :rule', + ':attribute not within :rule' => '不在有效期内 :rule', + 'access IP is not allowed' => '不允许的IP访问', + 'access IP denied' => '禁止的IP访问', + ':attribute out of accord with :2' => ':attribute和确认字段:2不一致', + ':attribute cannot be same with :2' => ':attribute和比较字段:2不能相同', + ':attribute must greater than or equal :rule' => ':attribute必须大于等于 :rule', + ':attribute must greater than :rule' => ':attribute必须大于 :rule', + ':attribute must less than or equal :rule' => ':attribute必须小于等于 :rule', + ':attribute must less than :rule' => ':attribute必须小于 :rule', + ':attribute must equal :rule' => ':attribute必须等于 :rule', + ':attribute has exists' => ':attribute已存在', + ':attribute not conform to the rules' => ':attribute不符合指定规则', + 'invalid Request method' => '无效的请求类型', + 'invalid token' => '令牌数据无效', + 'not conform to the rules' => '规则错误', - 'record has update' => '记录已经被更新了', + 'record has update' => '记录已经被更新了', ]; diff --git a/src/think/App.php b/src/think/App.php index 8c19ff040e..b59bfd72be 100644 --- a/src/think/App.php +++ b/src/think/App.php @@ -134,28 +134,28 @@ class App extends Container * @var array */ protected $bind = [ - 'app' => App::class, - 'cache' => Cache::class, - 'config' => Config::class, - 'console' => Console::class, - 'cookie' => Cookie::class, - 'db' => Db::class, - 'env' => Env::class, - 'event' => Event::class, - 'http' => Http::class, - 'lang' => Lang::class, - 'log' => Log::class, - 'middleware' => Middleware::class, - 'request' => Request::class, - 'response' => Response::class, - 'route' => Route::class, - 'session' => Session::class, - 'validate' => Validate::class, - 'view' => View::class, - 'filesystem' => Filesystem::class, - 'think\DbManager' => Db::class, - 'think\LogManager' => Log::class, - 'think\CacheManager' => Cache::class, + 'app' => App::class, + 'cache' => Cache::class, + 'config' => Config::class, + 'console' => Console::class, + 'cookie' => Cookie::class, + 'db' => Db::class, + 'env' => Env::class, + 'event' => Event::class, + 'http' => Http::class, + 'lang' => Lang::class, + 'log' => Log::class, + 'middleware' => Middleware::class, + 'request' => Request::class, + 'response' => Response::class, + 'route' => Route::class, + 'session' => Session::class, + 'validate' => Validate::class, + 'view' => View::class, + 'filesystem' => Filesystem::class, + 'think\DbManager' => Db::class, + 'think\LogManager' => Log::class, + 'think\CacheManager' => Cache::class, // 接口依赖注入 'Psr\Log\LoggerInterface' => Log::class, @@ -168,9 +168,9 @@ class App extends Container */ public function __construct(string $rootPath = '') { - $this->thinkPath = realpath(dirname(__DIR__)) . DIRECTORY_SEPARATOR; - $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); - $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; + $this->thinkPath = realpath(dirname(__DIR__)) . DIRECTORY_SEPARATOR; + $this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath(); + $this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR; $this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR; if (is_file($this->appPath . 'provider.php')) { @@ -439,7 +439,7 @@ public function initialize() $this->initialized = true; $this->beginTime = microtime(true); - $this->beginMem = memory_get_usage(); + $this->beginMem = memory_get_usage(); $this->loadEnv($this->envName); @@ -592,10 +592,10 @@ public function loadEvent(array $event): void */ public function parseClass(string $layer, string $name): string { - $name = str_replace(['/', '.'], '\\', $name); + $name = str_replace(['/', '.'], '\\', $name); $array = explode('\\', $name); $class = Str::studly(array_pop($array)); - $path = $array ? implode('\\', $array) . '\\' : ''; + $path = $array ? implode('\\', $array) . '\\' : ''; return $this->namespace . '\\' . $layer . '\\' . $path . $class; } diff --git a/src/think/Config.php b/src/think/Config.php index 9162e82fd9..cd6eaff150 100644 --- a/src/think/Config.php +++ b/src/think/Config.php @@ -43,13 +43,13 @@ class Config public function __construct(string $path = null, string $ext = '.php') { $this->path = $path ?: ''; - $this->ext = $ext; + $this->ext = $ext; } public static function __make(App $app) { $path = $app->getConfigPath(); - $ext = $app->getConfigExt(); + $ext = $app->getConfigExt(); return new static($path, $ext); } @@ -85,7 +85,7 @@ public function load(string $file, string $name = ''): array */ protected function parse(string $file, string $name): array { - $type = pathinfo($file, PATHINFO_EXTENSION); + $type = pathinfo($file, PATHINFO_EXTENSION); $config = []; switch ($type) { case 'php': @@ -154,9 +154,9 @@ public function get(string $name = null, $default = null) return $this->pull($name); } - $name = explode('.', $name); + $name = explode('.', $name); $name[0] = strtolower($name[0]); - $config = $this->config; + $config = $this->config; // 按.拆分成多维数组进行判断 foreach ($name as $val) { diff --git a/src/think/Console.php b/src/think/Console.php index 27f12baad9..a7bafb7b70 100644 --- a/src/think/Console.php +++ b/src/think/Console.php @@ -55,30 +55,30 @@ class Console protected $wantHelps = false; protected $catchExceptions = true; - protected $autoExit = true; + protected $autoExit = true; protected $definition; - protected $defaultCommand = 'list'; + protected $defaultCommand = 'list'; protected $defaultCommands = [ - 'help' => Help::class, - 'list' => Lists::class, - 'clear' => Clear::class, - 'make:command' => MakeCommand::class, - 'make:controller' => Controller::class, - 'make:model' => Model::class, - 'make:middleware' => Middleware::class, - 'make:validate' => Validate::class, - 'make:event' => Event::class, - 'make:listener' => Listener::class, - 'make:service' => Service::class, - 'make:subscribe' => Subscribe::class, - 'optimize:route' => Route::class, - 'optimize:schema' => Schema::class, - 'run' => RunServer::class, - 'version' => Version::class, - 'route:list' => RouteList::class, + 'help' => Help::class, + 'list' => Lists::class, + 'clear' => Clear::class, + 'make:command' => MakeCommand::class, + 'make:controller' => Controller::class, + 'make:model' => Model::class, + 'make:middleware' => Middleware::class, + 'make:validate' => Validate::class, + 'make:event' => Event::class, + 'make:listener' => Listener::class, + 'make:service' => Service::class, + 'make:subscribe' => Subscribe::class, + 'optimize:route' => Route::class, + 'optimize:schema' => Schema::class, + 'run' => RunServer::class, + 'version' => Version::class, + 'route:list' => RouteList::class, 'service:discover' => ServiceDiscover::class, - 'vendor:publish' => VendorPublish::class, + 'vendor:publish' => VendorPublish::class, ]; /** @@ -126,19 +126,19 @@ protected function makeRequest() if (isset($components['path'])) { $server = array_merge($server, [ 'SCRIPT_FILENAME' => $components['path'], - 'SCRIPT_NAME' => $components['path'], - 'REQUEST_URI' => $components['path'], + 'SCRIPT_NAME' => $components['path'], + 'REQUEST_URI' => $components['path'], ]); } if (isset($components['host'])) { $server['SERVER_NAME'] = $components['host']; - $server['HTTP_HOST'] = $components['host']; + $server['HTTP_HOST'] = $components['host']; } if (isset($components['scheme'])) { if ('https' === $components['scheme']) { - $server['HTTPS'] = 'on'; + $server['HTTPS'] = 'on'; $server['SERVER_PORT'] = 443; } else { unset($server['HTTPS']); @@ -223,7 +223,7 @@ public function call(string $command, array $parameters = [], string $driver = ' { array_unshift($parameters, $command); - $input = new Input($parameters); + $input = new Input($parameters); $output = new Output($driver); $this->setCatchExceptions(false); @@ -241,7 +241,7 @@ public function call(string $command, array $parameters = [], string $driver = ' */ public function run() { - $input = new Input(); + $input = new Input(); $output = new Output(); $this->configureIO($input, $output); @@ -296,7 +296,7 @@ public function doRun(Input $input, Output $output) if (true === $input->hasParameterOption(['--help', '-h'])) { if (!$name) { - $name = 'help'; + $name = 'help'; $input = new Input(['help']); } else { $this->wantHelps = true; @@ -304,7 +304,7 @@ public function doRun(Input $input, Output $output) } if (!$name) { - $name = $this->defaultCommand; + $name = $this->defaultCommand; $input = new Input([$this->defaultCommand]); } @@ -513,10 +513,10 @@ public function getNamespaces(): array public function findNamespace(string $namespace): string { $allNamespaces = $this->getNamespaces(); - $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]) . '[^:]*'; }, $namespace); - $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); + $namespaces = preg_grep('{^' . $expr . '}', $allNamespaces); if (empty($namespaces)) { $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); @@ -719,7 +719,7 @@ public function extractNamespace(string $name, int $limit = 0): string */ private function findAlternatives(string $name, $collection): array { - $threshold = 1e3; + $threshold = 1e3; $alternatives = []; $collectionParts = []; @@ -769,7 +769,7 @@ private function findAlternatives(string $name, $collection): array */ private function extractAllNamespaces(string $name): array { - $parts = explode(':', $name, -1); + $parts = explode(':', $name, -1); $namespaces = []; foreach ($parts as $part) { diff --git a/src/think/Container.php b/src/think/Container.php index f286c73bf7..64b1cbe524 100644 --- a/src/think/Container.php +++ b/src/think/Container.php @@ -381,7 +381,7 @@ public function invokeClass(string $class, array $vars = []) if ($reflect->hasMethod('__make')) { $method = $reflect->getMethod('__make'); if ($method->isPublic() && $method->isStatic()) { - $args = $this->bindParams($method, $vars); + $args = $this->bindParams($method, $vars); $object = $method->invokeArgs(null, $args); $this->invokeAfter($class, $object); return $object; @@ -436,13 +436,13 @@ protected function bindParams(ReflectionFunctionAbstract $reflect, array $vars = // 判断数组类型 数字数组时按顺序绑定参数 reset($vars); - $type = key($vars) === 0 ? 1 : 0; + $type = key($vars) === 0 ? 1 : 0; $params = $reflect->getParameters(); - $args = []; + $args = []; foreach ($params as $param) { - $name = $param->getName(); - $lowerName = Str::snake($name); + $name = $param->getName(); + $lowerName = Str::snake($name); $reflectionType = $param->getType(); if ($param->isVariadic()) { diff --git a/src/think/Cookie.php b/src/think/Cookie.php index 04774a6fd4..27328dbdf9 100644 --- a/src/think/Cookie.php +++ b/src/think/Cookie.php @@ -26,13 +26,13 @@ class Cookie */ protected $config = [ // cookie 保存时间 - 'expire' => 0, + 'expire' => 0, // cookie 保存路径 - 'path' => '/', + 'path' => '/', // cookie 有效域名 - 'domain' => '', + 'domain' => '', // cookie 启用安全传输 - 'secure' => false, + 'secure' => false, // httponly设置 'httponly' => false, // samesite 设置,支持 'strict' 'lax' @@ -58,7 +58,7 @@ class Cookie public function __construct(Request $request, array $config = []) { $this->request = $request; - $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) @@ -217,10 +217,10 @@ protected function saveCookie(string $name, string $value, int $expire, string $ { if (version_compare(PHP_VERSION, '7.3.0', '>=')) { setcookie($name, $value, [ - 'expires' => $expire, - 'path' => $path, - 'domain' => $domain, - 'secure' => $secure, + 'expires' => $expire, + 'path' => $path, + 'domain' => $domain, + 'secure' => $secure, 'httponly' => $httponly, 'samesite' => $samesite, ]); diff --git a/src/think/Env.php b/src/think/Env.php index 9e1b7f4b94..e88dd24e72 100644 --- a/src/think/Env.php +++ b/src/think/Env.php @@ -31,10 +31,10 @@ class Env implements ArrayAccess * @var array */ protected $convert = [ - 'true' => true, + 'true' => true, 'false' => false, - 'off' => false, - 'on' => true, + 'off' => false, + 'on' => true, ]; public function __construct() diff --git a/src/think/Event.php b/src/think/Event.php index 3c70aadf25..3e011b24f9 100644 --- a/src/think/Event.php +++ b/src/think/Event.php @@ -32,12 +32,12 @@ class Event * @var array */ protected $bind = [ - 'AppInit' => event\AppInit::class, - 'HttpRun' => event\HttpRun::class, - 'HttpEnd' => event\HttpEnd::class, + 'AppInit' => event\AppInit::class, + 'HttpRun' => event\HttpRun::class, + 'HttpEnd' => event\HttpEnd::class, 'RouteLoaded' => event\RouteLoaded::class, - 'LogWrite' => event\LogWrite::class, - 'LogRecord' => event\LogRecord::class, + 'LogWrite' => event\LogWrite::class, + 'LogRecord' => event\LogRecord::class, ]; /** @@ -207,14 +207,14 @@ public function trigger($event, $params = null, bool $once = false) { if (is_object($event)) { $params = $event; - $event = get_class($event); + $event = get_class($event); } if (isset($this->bind[$event])) { $event = $this->bind[$event]; } - $result = []; + $result = []; $listeners = $this->listener[$event] ?? []; if (strpos($event, '.')) { @@ -262,7 +262,7 @@ protected function dispatch($event, $params = null) } elseif (strpos($event, '::')) { $call = $event; } else { - $obj = $this->app->make($event); + $obj = $this->app->make($event); $call = [$obj, 'handle']; } diff --git a/src/think/Facade.php b/src/think/Facade.php index 9a0e333949..bb3a7414a8 100644 --- a/src/think/Facade.php +++ b/src/think/Facade.php @@ -84,7 +84,7 @@ public static function make(string $class, $args = [], $newInstance = false) if (true === $args) { // 总是创建新的实例化对象 $newInstance = true; - $args = []; + $args = []; } return self::createFacade($class, $args, $newInstance); diff --git a/src/think/File.php b/src/think/File.php index 087e808ffc..4bf7dc1adc 100644 --- a/src/think/File.php +++ b/src/think/File.php @@ -140,7 +140,7 @@ protected function getTargetFile(string $directory, string $name = null): File protected function getName(string $name): string { $originalName = str_replace('\\', '/', $name); - $pos = strrpos($originalName, '/'); + $pos = strrpos($originalName, '/'); $originalName = false === $pos ? $originalName : substr($originalName, $pos + 1); return $originalName; @@ -169,7 +169,7 @@ public function hashName($rule = ''): string } else { switch (true) { case in_array($rule, hash_algos()): - $hash = $this->hash($rule); + $hash = $this->hash($rule); $this->hashName = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); break; case is_callable($rule): diff --git a/src/think/Lang.php b/src/think/Lang.php index b891084822..bfbcdf2ade 100644 --- a/src/think/Lang.php +++ b/src/think/Lang.php @@ -26,25 +26,25 @@ class Lang */ protected $config = [ // 默认语言 - 'default_lang' => 'zh-cn', + 'default_lang' => 'zh-cn', // 允许的语言列表 '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' => [ 'zh-hans-cn' => 'zh-cn', ], // 是否支持语言分组 - 'allow_group' => false, + 'allow_group' => false, ]; /** @@ -67,8 +67,8 @@ class Lang public function __construct(App $app, array $config = []) { $this->config = array_merge($this->config, array_change_key_case($config)); - $this->range = $this->config['default_lang']; - $this->app = $app; + $this->range = $this->config['default_lang']; + $this->app = $app; } public static function __make(App $app, Config $config) @@ -167,7 +167,7 @@ public function load($file, $range = ''): array foreach ((array) $file as $name) { if (is_file($name)) { $result = $this->parse($name); - $lang = array_change_key_case($result) + $lang; + $lang = array_change_key_case($result) + $lang; } } diff --git a/src/think/Log.php b/src/think/Log.php index c31210ce45..c3159d48fb 100644 --- a/src/think/Log.php +++ b/src/think/Log.php @@ -27,14 +27,14 @@ class Log extends Manager implements LoggerInterface { const EMERGENCY = 'emergency'; - const ALERT = 'alert'; - const CRITICAL = 'critical'; - const ERROR = 'error'; - const WARNING = 'warning'; - const NOTICE = 'notice'; - const INFO = 'info'; - const DEBUG = 'debug'; - const SQL = 'sql'; + const ALERT = 'alert'; + const CRITICAL = 'critical'; + const ERROR = 'error'; + const WARNING = 'warning'; + const NOTICE = 'notice'; + const INFO = 'info'; + const DEBUG = 'debug'; + const SQL = 'sql'; protected $namespace = '\\think\\log\\driver\\'; @@ -102,7 +102,7 @@ public function createDriver(string $name) { $driver = parent::createDriver($name); - $lazy = !$this->getChannelConfig($name, "realtime_write", false) && !$this->app->runningInConsole(); + $lazy = !$this->getChannelConfig($name, "realtime_write", false) && !$this->app->runningInConsole(); $allow = array_merge($this->getConfig("level", []), $this->getChannelConfig($name, "level", [])); return new Channel($name, $driver, $allow, $lazy, $this->app->event); diff --git a/src/think/Middleware.php b/src/think/Middleware.php index a3db0f2f30..8bb93650b4 100644 --- a/src/think/Middleware.php +++ b/src/think/Middleware.php @@ -68,7 +68,7 @@ public function add($middleware, string $type = 'global'): void if (!empty($middleware)) { $this->queue[$type][] = $middleware; - $this->queue[$type] = array_unique($this->queue[$type], SORT_REGULAR); + $this->queue[$type] = array_unique($this->queue[$type], SORT_REGULAR); } } diff --git a/src/think/Request.php b/src/think/Request.php index 99f4f8063a..c83998c57a 100644 --- a/src/think/Request.php +++ b/src/think/Request.php @@ -250,18 +250,18 @@ class Request implements ArrayAccess * @var array */ protected $mimeType = [ - 'xml' => 'application/xml,text/xml,application/x-xml', - 'json' => 'application/json,text/x-json,application/jsonrequest,text/json', - 'js' => 'text/javascript,application/javascript,application/x-javascript', - 'css' => 'text/css', - 'rss' => 'application/rss+xml', - 'yaml' => 'application/x-yaml,text/yaml', - 'atom' => 'application/atom+xml', - 'pdf' => 'application/pdf', - 'text' => 'text/plain', + 'xml' => 'application/xml,text/xml,application/x-xml', + 'json' => 'application/json,text/x-json,application/jsonrequest,text/json', + 'js' => 'text/javascript,application/javascript,application/x-javascript', + 'css' => 'text/css', + 'rss' => 'application/rss+xml', + 'yaml' => 'application/x-yaml,text/yaml', + 'atom' => 'application/atom+xml', + 'pdf' => 'application/pdf', + 'text' => 'text/plain', 'image' => 'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/webp,image/*', - 'csv' => 'text/csv', - 'html' => 'text/html,application/xhtml+xml,*/*', + 'csv' => 'text/csv', + 'html' => 'text/html,application/xhtml+xml,*/*', ]; /** @@ -316,7 +316,7 @@ public static function __make(App $app) $server = $_SERVER; foreach ($server as $key => $val) { if (0 === strpos($key, 'HTTP_')) { - $key = str_replace('_', '-', strtolower(substr($key, 5))); + $key = str_replace('_', '-', strtolower(substr($key, 5))); $header[$key] = $val; } } @@ -330,16 +330,16 @@ public static function __make(App $app) $request->header = array_change_key_case($header); $request->server = $_SERVER; - $request->env = $app->env; + $request->env = $app->env; $inputData = $request->getInputData($request->input); - $request->get = $_GET; - $request->post = $_POST ?: $inputData; - $request->put = $inputData; + $request->get = $_GET; + $request->post = $_POST ?: $inputData; + $request->put = $inputData; $request->request = $_REQUEST; - $request->cookie = $_COOKIE; - $request->file = $_FILES ?? []; + $request->cookie = $_COOKIE; + $request->file = $_FILES ?? []; return $request; } @@ -377,9 +377,9 @@ public function rootDomain(): string $root = $this->rootDomain; if (!$root) { - $item = explode('.', $this->host()); + $item = explode('.', $this->host()); $count = count($item); - $root = $count > 1 ? $item[$count - 2] . '.' . $item[$count - 1] : $item[0]; + $root = $count > 1 ? $item[$count - 2] . '.' . $item[$count - 1] : $item[0]; } return $root; @@ -409,7 +409,7 @@ public function subDomain(): string $rootDomain = $this->rootDomain(); if ($rootDomain) { - $sub = stristr($this->host(), $rootDomain, true); + $sub = stristr($this->host(), $rootDomain, true); $this->subDomain = $sub ? rtrim($sub, '.') : ''; } else { $this->subDomain = ''; @@ -499,7 +499,7 @@ public function setBaseUrl(string $url) public function baseUrl(bool $complete = false): string { if (!$this->baseUrl) { - $str = $this->url(); + $str = $this->url(); $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; } @@ -725,7 +725,7 @@ public function method(bool $origin = false): string if (isset($this->post[$this->varMethod])) { $method = strtolower($this->post[$this->varMethod]); if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) { - $this->method = strtoupper($method); + $this->method = strtoupper($method); $this->{$method} = $this->post; } else { $this->method = 'POST'; @@ -921,7 +921,7 @@ public function rule() */ public function setRoute(array $route) { - $this->route = array_merge($this->route, $route); + $this->route = array_merge($this->route, $route); $this->mergeParam = false; return $this; } @@ -1174,8 +1174,8 @@ protected function dealUploadFile(array $files, string $name): array $array = []; foreach ($files as $key => $file) { if (is_array($file['name'])) { - $item = []; - $keys = array_keys($file); + $item = []; + $keys = array_keys($file); $count = count($file['name']); for ($i = 0; $i < $count; $i++) { @@ -1493,7 +1493,7 @@ public function only(array $name, $data = 'param', $filter = ''): array if (is_int($key)) { $default = null; - $key = $val; + $key = $val; if (!key_exists($key, $data)) { continue; } @@ -1569,7 +1569,7 @@ public function isJson(): bool */ public function isAjax(bool $ajax = false): bool { - $value = $this->server('HTTP_X_REQUESTED_WITH'); + $value = $this->server('HTTP_X_REQUESTED_WITH'); $result = $value && 'xmlhttprequest' == strtolower($value) ? true : false; if (true === $ajax) { @@ -1611,7 +1611,7 @@ public function ip(): string // 如果指定了前端代理服务器IP以及其会发送的IP头 // 则尝试获取前端代理服务器发送过来的真实IP - $proxyIp = $this->proxyServerIp; + $proxyIp = $this->proxyServerIp; $proxyIpHeader = $this->proxyServerIpHeader; if (count($proxyIp) > 0 && count($proxyIpHeader) > 0) { @@ -1642,9 +1642,9 @@ public function ip(): string foreach ($proxyIp as $ip) { $serverIPElements = explode('/', $ip); - $serverIP = $serverIPElements[0]; - $serverIPPrefix = $serverIPElements[1] ?? 128; - $serverIPBin = $this->ip2bin($serverIP); + $serverIP = $serverIPElements[0]; + $serverIPPrefix = $serverIPElements[1] ?? 128; + $serverIPBin = $this->ip2bin($serverIP); // IP类型不符 if (strlen($realIPBin) !== strlen($serverIPBin)) { @@ -1933,7 +1933,7 @@ public function getInput(): string */ public function buildToken(string $name = '__token__', $type = 'md5'): string { - $type = is_callable($type) ? $type : 'md5'; + $type = is_callable($type) ? $type : 'md5'; $token = call_user_func($type, $this->server('REQUEST_TIME_FLOAT')); $this->session->set($name, $token); @@ -2091,7 +2091,7 @@ public function withInput(string $input) $inputData = $this->getInputData($input); if (!empty($inputData)) { $this->post = $inputData; - $this->put = $inputData; + $this->put = $inputData; } } return $this; diff --git a/src/think/Route.php b/src/think/Route.php index e45cb33bd3..205635c994 100644 --- a/src/think/Route.php +++ b/src/think/Route.php @@ -36,11 +36,11 @@ class Route * @var array */ protected $rest = [ - 'index' => ['get', '', 'index'], + 'index' => ['get', '', 'index'], 'create' => ['get', '/create', 'create'], - 'edit' => ['get', '//edit', 'edit'], - 'read' => ['get', '/', 'read'], - 'save' => ['post', '', 'save'], + 'edit' => ['get', '//edit', 'edit'], + 'read' => ['get', '/', 'read'], + 'save' => ['post', '', 'save'], 'update' => ['put', '/', 'update'], 'delete' => ['delete', '/', 'delete'], ]; @@ -51,37 +51,37 @@ class Route */ protected $config = [ // pathinfo分隔符 - 'pathinfo_depr' => '/', + 'pathinfo_depr' => '/', // 是否开启路由延迟解析 - 'url_lazy_route' => false, + 'url_lazy_route' => false, // 是否强制使用路由 - 'url_route_must' => false, + 'url_route_must' => false, // 合并路由规则 - 'route_rule_merge' => false, + 'route_rule_merge' => false, // 路由是否完全匹配 - 'route_complete_match' => false, + 'route_complete_match' => false, // 去除斜杠 - 'remove_slash' => false, + 'remove_slash' => false, // 使用注解路由 - 'route_annotation' => false, + 'route_annotation' => false, // 默认的路由变量规则 'default_route_pattern' => '[\w\.]+', // URL伪静态后缀 - 'url_html_suffix' => 'html', + 'url_html_suffix' => 'html', // 访问控制器层名称 - 'controller_layer' => 'controller', + 'controller_layer' => 'controller', // 空控制器名 - 'empty_controller' => 'Error', + 'empty_controller' => 'Error', // 是否使用控制器后缀 - 'controller_suffix' => false, + 'controller_suffix' => false, // 默认控制器名 - 'default_controller' => 'Index', + 'default_controller' => 'Index', // 默认操作名 - 'default_action' => 'index', + 'default_action' => 'index', // 操作方法后缀 - 'action_suffix' => '', + 'action_suffix' => '', // 非路由变量是否使用普通参数方式(用于URL生成) - 'url_common_param' => true, + 'url_common_param' => true, ]; /** @@ -157,7 +157,7 @@ class Route public function __construct(App $app) { - $this->app = $app; + $this->app = $app; $this->ruleName = new RuleName(); $this->setDefaultDomain(); @@ -179,7 +179,7 @@ protected function init() $this->lazy($this->config['url_lazy_route']); $this->mergeRuleRegex = $this->config['route_rule_merge']; - $this->removeSlash = $this->config['remove_slash']; + $this->removeSlash = $this->config['remove_slash']; $this->group->removeSlash($this->removeSlash); } @@ -551,7 +551,7 @@ public function group($name, $route = null): RuleGroup { if ($name instanceof Closure) { $route = $name; - $name = ''; + $name = ''; } return (new RuleGroup($this, $this->group, $name, $route)) @@ -695,14 +695,14 @@ public function view(string $rule, string $template = '', array $vars = []): Rul public function redirect(string $rule, string $route = '', int $status = 301): RuleItem { return $this->rule($rule, function (Request $request) use ($status, $route) { - $search = $replace = []; + $search = $replace = []; $matches = $request->rule()->getVars(); foreach ($matches as $key => $value) { - $search[] = '<' . $key . '>'; + $search[] = '<' . $key . '>'; $replace[] = $value; - $search[] = ':' . $key; + $search[] = ':' . $key; $replace[] = $value; } @@ -765,7 +765,7 @@ public function miss($route, string $method = '*'): RuleItem public function dispatch(Request $request, $withRoute = true) { $this->request = $request; - $this->host = $this->request->host(true); + $this->host = $this->request->host(true); if ($withRoute) { //加载路由 @@ -822,7 +822,7 @@ public function check() */ protected function path(): string { - $suffix = $this->config['url_html_suffix']; + $suffix = $this->config['url_html_suffix']; $pathinfo = $this->request->pathinfo(); if (false === $suffix) { @@ -870,7 +870,7 @@ protected function checkDomain(): Domain // 获取当前子域名 $subDomain = $this->request->subDomain(); - $domain = $subDomain ? explode('.', $subDomain) : []; + $domain = $subDomain ? explode('.', $subDomain) : []; $domain2 = $domain ? array_pop($domain) : ''; if ($domain) { @@ -885,12 +885,12 @@ protected function checkDomain(): Domain $item = $this->domains[$subDomain]; } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { // 泛三级域名 - $item = $this->domains['*.' . $domain2]; + $item = $this->domains['*.' . $domain2]; $panDomain = $domain3; } elseif (isset($this->domains['*']) && !empty($domain2)) { // 泛二级域名 if ('www' != $domain2) { - $item = $this->domains['*']; + $item = $this->domains['*']; $panDomain = $domain2; } } diff --git a/src/think/Validate.php b/src/think/Validate.php index 0788406415..b461c52f69 100644 --- a/src/think/Validate.php +++ b/src/think/Validate.php @@ -60,56 +60,56 @@ class Validate * @var array */ protected $typeMsg = [ - 'require' => ':attribute require', - 'must' => ':attribute must', - 'number' => ':attribute must be numeric', - 'integer' => ':attribute must be integer', - 'float' => ':attribute must be float', - 'boolean' => ':attribute must be bool', - 'email' => ':attribute not a valid email address', - 'mobile' => ':attribute not a valid mobile', - 'array' => ':attribute must be a array', - 'accepted' => ':attribute must be yes,on or 1', - 'date' => ':attribute not a valid datetime', - 'file' => ':attribute not a valid file', - 'image' => ':attribute not a valid image', - 'alpha' => ':attribute must be alpha', - 'alphaNum' => ':attribute must be alpha-numeric', - 'alphaDash' => ':attribute must be alpha-numeric, dash, underscore', - 'activeUrl' => ':attribute not a valid domain or ip', - 'chs' => ':attribute must be chinese', - 'chsAlpha' => ':attribute must be chinese or alpha', + 'require' => ':attribute require', + 'must' => ':attribute must', + 'number' => ':attribute must be numeric', + 'integer' => ':attribute must be integer', + 'float' => ':attribute must be float', + 'boolean' => ':attribute must be bool', + 'email' => ':attribute not a valid email address', + 'mobile' => ':attribute not a valid mobile', + 'array' => ':attribute must be a array', + 'accepted' => ':attribute must be yes,on or 1', + 'date' => ':attribute not a valid datetime', + 'file' => ':attribute not a valid file', + 'image' => ':attribute not a valid image', + 'alpha' => ':attribute must be alpha', + 'alphaNum' => ':attribute must be alpha-numeric', + 'alphaDash' => ':attribute must be alpha-numeric, dash, underscore', + 'activeUrl' => ':attribute not a valid domain or ip', + 'chs' => ':attribute must be chinese', + 'chsAlpha' => ':attribute must be chinese or alpha', 'chsAlphaNum' => ':attribute must be chinese,alpha-numeric', - 'chsDash' => ':attribute must be chinese,alpha-numeric,underscore, dash', - 'url' => ':attribute not a valid url', - 'ip' => ':attribute not a valid ip', - 'dateFormat' => ':attribute must be dateFormat of :rule', - 'in' => ':attribute must be in :rule', - 'notIn' => ':attribute be notin :rule', - 'between' => ':attribute must between :1 - :2', - 'notBetween' => ':attribute not between :1 - :2', - 'length' => 'size of :attribute must be :rule', - 'max' => 'max size of :attribute must be :rule', - 'min' => 'min size of :attribute must be :rule', - 'after' => ':attribute cannot be less than :rule', - 'before' => ':attribute cannot exceed :rule', - 'expire' => ':attribute not within :rule', - 'allowIp' => 'access IP is not allowed', - 'denyIp' => 'access IP denied', - 'confirm' => ':attribute out of accord with :2', - 'different' => ':attribute cannot be same with :2', - 'egt' => ':attribute must greater than or equal :rule', - 'gt' => ':attribute must greater than :rule', - 'elt' => ':attribute must less than or equal :rule', - 'lt' => ':attribute must less than :rule', - 'eq' => ':attribute must equal :rule', - 'unique' => ':attribute has exists', - 'regex' => ':attribute not conform to the rules', - 'method' => 'invalid Request method', - 'token' => 'invalid token', - 'fileSize' => 'filesize not match', - 'fileExt' => 'extensions to upload is not allowed', - 'fileMime' => 'mimetype to upload is not allowed', + 'chsDash' => ':attribute must be chinese,alpha-numeric,underscore, dash', + 'url' => ':attribute not a valid url', + 'ip' => ':attribute not a valid ip', + 'dateFormat' => ':attribute must be dateFormat of :rule', + 'in' => ':attribute must be in :rule', + 'notIn' => ':attribute be notin :rule', + 'between' => ':attribute must between :1 - :2', + 'notBetween' => ':attribute not between :1 - :2', + 'length' => 'size of :attribute must be :rule', + 'max' => 'max size of :attribute must be :rule', + 'min' => 'min size of :attribute must be :rule', + 'after' => ':attribute cannot be less than :rule', + 'before' => ':attribute cannot exceed :rule', + 'expire' => ':attribute not within :rule', + 'allowIp' => 'access IP is not allowed', + 'denyIp' => 'access IP denied', + 'confirm' => ':attribute out of accord with :2', + 'different' => ':attribute cannot be same with :2', + 'egt' => ':attribute must greater than or equal :rule', + 'gt' => ':attribute must greater than :rule', + 'elt' => ':attribute must less than or equal :rule', + 'lt' => ':attribute must less than :rule', + 'eq' => ':attribute must equal :rule', + 'unique' => ':attribute has exists', + 'regex' => ':attribute not conform to the rules', + 'method' => 'invalid Request method', + 'token' => 'invalid token', + 'fileSize' => 'filesize not match', + 'fileExt' => 'extensions to upload is not allowed', + 'fileMime' => 'mimetype to upload is not allowed', ]; /** @@ -123,16 +123,16 @@ class Validate * @var array */ protected $defaultRegex = [ - 'alpha' => '/^[A-Za-z]+$/', - 'alphaNum' => '/^[A-Za-z0-9]+$/', - 'alphaDash' => '/^[A-Za-z0-9\-\_]+$/', - 'chs' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}]+$/u', - 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z]+$/u', + 'alpha' => '/^[A-Za-z]+$/', + 'alphaNum' => '/^[A-Za-z0-9]+$/', + 'alphaDash' => '/^[A-Za-z0-9\-\_]+$/', + 'chs' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}]+$/u', + 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z]+$/u', 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9]+$/u', - 'chsDash' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9\_\-]+$/u', - 'mobile' => '/^1[3-9]\d{9}$/', - 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', - 'zip' => '/\d{6}/', + 'chsDash' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9\_\-]+$/u', + 'mobile' => '/^1[3-9]\d{9}$/', + 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', + 'zip' => '/\d{6}/', ]; /** @@ -140,12 +140,12 @@ class Validate * @var array */ protected $filter = [ - 'email' => FILTER_VALIDATE_EMAIL, - 'ip' => [FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6], + 'email' => FILTER_VALIDATE_EMAIL, + 'ip' => [FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6], 'integer' => FILTER_VALIDATE_INT, - 'url' => FILTER_VALIDATE_URL, + 'url' => FILTER_VALIDATE_URL, 'macAddr' => FILTER_VALIDATE_MAC, - 'float' => FILTER_VALIDATE_FLOAT, + 'float' => FILTER_VALIDATE_FLOAT, ]; /** @@ -617,7 +617,7 @@ protected function checkItem(string $field, $value, $rules, $data, string $title foreach ($rules as $key => $rule) { if ($rule instanceof Closure) { $result = call_user_func_array($rule, [$value, $data]); - $info = is_numeric($key) ? '' : $key; + $info = is_numeric($key) ? '' : $key; } else { // 判断验证类型 [$type, $rule, $info] = $this->getValidateType($key, $rule); @@ -874,7 +874,7 @@ public function is($value, string $rule, array $data = []): bool } elseif (function_exists('ctype_' . $rule)) { // ctype验证规则 $ctypeFun = 'ctype_' . $rule; - $result = $ctypeFun($value); + $result = $ctypeFun($value); } elseif (isset($this->filter[$rule])) { // Filter_var验证规则 $result = $this->filter($value, $this->filter[$rule]); @@ -1181,7 +1181,7 @@ public function filter($value, $rule): bool [$rule, $param] = explode(',', $rule); } elseif (is_array($rule)) { $param = $rule[1] ?? 0; - $rule = $rule[0]; + $rule = $rule[0]; } else { $param = 0; } diff --git a/src/think/cache/Driver.php b/src/think/cache/Driver.php index 7dc0d30a29..f9e132fa5a 100644 --- a/src/think/cache/Driver.php +++ b/src/think/cache/Driver.php @@ -196,7 +196,7 @@ public function remember(string $name, $value, $expire = null) public function tag($name): TagSet { $name = (array) $name; - $key = implode('-', $name); + $key = implode('-', $name); if (!isset($this->tag[$key])) { $this->tag[$key] = new TagSet($name, $this); diff --git a/src/think/cache/TagSet.php b/src/think/cache/TagSet.php index 5ba20769ac..27ee9cf5e7 100644 --- a/src/think/cache/TagSet.php +++ b/src/think/cache/TagSet.php @@ -37,7 +37,7 @@ class TagSet */ public function __construct(array $tag, Driver $cache) { - $this->tag = $tag; + $this->tag = $tag; $this->handler = $cache; } diff --git a/src/think/cache/driver/File.php b/src/think/cache/driver/File.php index e0c7e5731f..d982c60625 100644 --- a/src/think/cache/driver/File.php +++ b/src/think/cache/driver/File.php @@ -26,14 +26,14 @@ class File extends Driver * @var array */ protected $options = [ - 'expire' => 0, - 'cache_subdir' => true, - 'prefix' => '', - 'path' => '', - 'hash_type' => 'md5', + 'expire' => 0, + 'cache_subdir' => true, + 'prefix' => '', + 'path' => '', + 'hash_type' => 'md5', 'data_compress' => false, - 'tag_prefix' => 'tag:', - 'serialize' => [], + 'tag_prefix' => 'tag:', + 'serialize' => [], ]; /** @@ -155,7 +155,7 @@ public function set($name, $value, $expire = null): bool $expire = $this->options['expire']; } - $expire = $this->getExpireTime($expire); + $expire = $this->getExpireTime($expire); $filename = $this->getCacheKey($name); $dir = dirname($filename); @@ -175,7 +175,7 @@ public function set($name, $value, $expire = null): bool $data = gzcompress($data, 3); } - $data = "\n" . $data; + $data = "\n" . $data; $result = file_put_contents($filename, $data, LOCK_EX); if ($result) { @@ -196,10 +196,10 @@ public function set($name, $value, $expire = null): bool public function inc(string $name, int $step = 1) { if ($raw = $this->getRaw($name)) { - $value = $this->unserialize($raw['content']) + $step; + $value = $this->unserialize($raw['content']) + $step; $expire = $raw['expire']; } else { - $value = $step; + $value = $step; $expire = 0; } diff --git a/src/think/cache/driver/Memcache.php b/src/think/cache/driver/Memcache.php index 2fbbb9c729..deb76664d1 100644 --- a/src/think/cache/driver/Memcache.php +++ b/src/think/cache/driver/Memcache.php @@ -24,14 +24,14 @@ class Memcache extends Driver * @var array */ protected $options = [ - 'host' => '127.0.0.1', - 'port' => 11211, - 'expire' => 0, - 'timeout' => 0, // 超时时间(单位:毫秒) + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, // 超时时间(单位:毫秒) 'persistent' => true, - 'prefix' => '', + 'prefix' => '', 'tag_prefix' => 'tag:', - 'serialize' => [], + 'serialize' => [], ]; /** @@ -114,9 +114,9 @@ public function set($name, $value, $expire = null): bool $expire = $this->options['expire']; } - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $expire = $this->getExpireTime($expire); - $value = $this->serialize($value); + $value = $this->serialize($value); if ($this->handler->set($key, $value, 0, $expire)) { return true; @@ -156,9 +156,9 @@ public function dec(string $name, int $step = 1) { $this->writeTimes++; - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $value = $this->handler->get($key) - $step; - $res = $this->handler->set($key, $value); + $res = $this->handler->set($key, $value); return !$res ? false : $value; } diff --git a/src/think/cache/driver/Memcached.php b/src/think/cache/driver/Memcached.php index 71edb058f6..ff9cc1e6d3 100644 --- a/src/think/cache/driver/Memcached.php +++ b/src/think/cache/driver/Memcached.php @@ -24,16 +24,16 @@ class Memcached extends Driver * @var array */ protected $options = [ - 'host' => '127.0.0.1', - 'port' => 11211, - 'expire' => 0, - 'timeout' => 0, // 超时时间(单位:毫秒) - 'prefix' => '', - 'username' => '', //账号 - 'password' => '', //密码 - 'option' => [], + 'host' => '127.0.0.1', + 'port' => 11211, + 'expire' => 0, + 'timeout' => 0, // 超时时间(单位:毫秒) + 'prefix' => '', + 'username' => '', //账号 + 'password' => '', //密码 + 'option' => [], 'tag_prefix' => 'tag:', - 'serialize' => [], + 'serialize' => [], ]; /** @@ -128,9 +128,9 @@ public function set($name, $value, $expire = null): bool $expire = $this->options['expire']; } - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $expire = $this->getExpireTime($expire); - $value = $this->serialize($value); + $value = $this->serialize($value); if ($this->handler->set($key, $value, $expire)) { return true; @@ -170,9 +170,9 @@ public function dec(string $name, int $step = 1) { $this->writeTimes++; - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $value = $this->handler->get($key) - $step; - $res = $this->handler->set($key, $value); + $res = $this->handler->set($key, $value); return !$res ? false : $value; } diff --git a/src/think/cache/driver/Redis.php b/src/think/cache/driver/Redis.php index 791b27b88f..463e00d043 100644 --- a/src/think/cache/driver/Redis.php +++ b/src/think/cache/driver/Redis.php @@ -31,16 +31,16 @@ class Redis extends Driver * @var array */ protected $options = [ - 'host' => '127.0.0.1', - 'port' => 6379, - 'password' => '', - 'select' => 0, - 'timeout' => 0, - 'expire' => 0, + 'host' => '127.0.0.1', + 'port' => 6379, + 'password' => '', + 'select' => 0, + 'timeout' => 0, + 'expire' => 0, 'persistent' => false, - 'prefix' => '', + 'prefix' => '', 'tag_prefix' => 'tag:', - 'serialize' => [], + 'serialize' => [], ]; /** @@ -112,7 +112,7 @@ public function has($name): bool public function get($name, $default = null) { $this->readTimes++; - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $value = $this->handler->get($key); if (false === $value || is_null($value)) { @@ -138,9 +138,9 @@ public function set($name, $value, $expire = null): bool $expire = $this->options['expire']; } - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $expire = $this->getExpireTime($expire); - $value = $this->serialize($value); + $value = $this->serialize($value); if ($expire) { $this->handler->setex($key, $expire, $value); @@ -191,7 +191,7 @@ public function delete($name): bool { $this->writeTimes++; - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $result = $this->handler->del($key); return $result > 0; } @@ -242,7 +242,7 @@ public function append(string $name, $value): void public function getTagItems(string $tag): array { $name = $this->getTagKey($tag); - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); return $this->handler->sMembers($key); } diff --git a/src/think/cache/driver/Wincache.php b/src/think/cache/driver/Wincache.php index 8b3e8b8631..4a104f74a0 100644 --- a/src/think/cache/driver/Wincache.php +++ b/src/think/cache/driver/Wincache.php @@ -24,10 +24,10 @@ class Wincache extends Driver * @var array */ protected $options = [ - 'prefix' => '', - 'expire' => 0, + 'prefix' => '', + 'expire' => 0, 'tag_prefix' => 'tag:', - 'serialize' => [], + 'serialize' => [], ]; /** @@ -94,9 +94,9 @@ public function set($name, $value, $expire = null): bool $expire = $this->options['expire']; } - $key = $this->getCacheKey($name); + $key = $this->getCacheKey($name); $expire = $this->getExpireTime($expire); - $value = $this->serialize($value); + $value = $this->serialize($value); if (wincache_ucache_set($key, $value, $expire)) { return true; diff --git a/src/think/console/Command.php b/src/think/console/Command.php index bd3fb209b8..32b246f87e 100644 --- a/src/think/console/Command.php +++ b/src/think/console/Command.php @@ -32,11 +32,11 @@ abstract class Command private $definition; private $help; private $description; - private $ignoreValidationErrors = false; - private $consoleDefinitionMerged = false; + private $ignoreValidationErrors = false; + private $consoleDefinitionMerged = false; private $consoleDefinitionMergedWithArgs = false; - private $synopsis = []; - private $usages = []; + private $synopsis = []; + private $usages = []; /** @var Input */ protected $input; @@ -166,7 +166,7 @@ protected function initialize(Input $input, Output $output) */ public function run(Input $input, Output $output): int { - $this->input = $input; + $this->input = $input; $this->output = $output; $this->getSynopsis(true); diff --git a/src/think/console/Input.php b/src/think/console/Input.php index 9ae9077584..e8aef2ebf6 100644 --- a/src/think/console/Input.php +++ b/src/think/console/Input.php @@ -63,8 +63,8 @@ protected function setTokens(array $tokens) */ public function bind(Definition $definition): void { - $this->arguments = []; - $this->options = []; + $this->arguments = []; + $this->options = []; $this->definition = $definition; $this->parse(); diff --git a/src/think/console/Output.php b/src/think/console/Output.php index 294c4b8092..20dd046757 100644 --- a/src/think/console/Output.php +++ b/src/think/console/Output.php @@ -43,19 +43,19 @@ class Output { // 不显示信息(静默) - const VERBOSITY_QUIET = 0; + const VERBOSITY_QUIET = 0; // 正常信息 - const VERBOSITY_NORMAL = 1; + const VERBOSITY_NORMAL = 1; // 详细信息 - const VERBOSITY_VERBOSE = 2; + const VERBOSITY_VERBOSE = 2; // 非常详细的信息 const VERBOSITY_VERY_VERBOSE = 3; // 调试信息 - const VERBOSITY_DEBUG = 4; + const VERBOSITY_DEBUG = 4; const OUTPUT_NORMAL = 0; - const OUTPUT_RAW = 1; - const OUTPUT_PLAIN = 2; + const OUTPUT_RAW = 1; + const OUTPUT_PLAIN = 2; // 输出信息级别 private $verbosity = self::VERBOSITY_NORMAL; @@ -108,7 +108,7 @@ public function confirm(Input $input, $question, $default = true) public function choice(Input $input, $question, array $choices, $default = null) { if (null !== $default) { - $values = array_flip($choices); + $values = array_flip($choices); $default = $values[$default]; } @@ -117,7 +117,7 @@ public function choice(Input $input, $question, array $choices, $default = null) protected function askQuestion(Input $input, Question $question) { - $ask = new Ask($input, $this, $question); + $ask = new Ask($input, $this, $question); $answer = $ask->run(); if ($input->isInteractive()) { @@ -208,7 +208,7 @@ public function isDebug(): bool public function describe($object, array $options = []): void { $descriptor = new Descriptor(); - $options = array_merge([ + $options = array_merge([ 'raw_text' => false, ], $options); diff --git a/src/think/console/Table.php b/src/think/console/Table.php index 5a861d7fe8..f0512a26c8 100644 --- a/src/think/console/Table.php +++ b/src/think/console/Table.php @@ -14,8 +14,8 @@ class Table { - const ALIGN_LEFT = 1; - const ALIGN_RIGHT = 0; + const ALIGN_LEFT = 1; + const ALIGN_RIGHT = 0; const ALIGN_CENTER = 2; /** @@ -59,45 +59,45 @@ class Table * @var array */ protected $format = [ - 'compact' => [], - 'default' => [ - 'top' => ['+', '-', '+', '+'], - 'cell' => ['|', ' ', '|', '|'], - 'middle' => ['+', '-', '+', '+'], - 'bottom' => ['+', '-', '+', '+'], - 'cross-top' => ['+', '-', '-', '+'], + 'compact' => [], + 'default' => [ + 'top' => ['+', '-', '+', '+'], + 'cell' => ['|', ' ', '|', '|'], + 'middle' => ['+', '-', '+', '+'], + 'bottom' => ['+', '-', '+', '+'], + 'cross-top' => ['+', '-', '-', '+'], 'cross-bottom' => ['+', '-', '-', '+'], ], - 'markdown' => [ - 'top' => [' ', ' ', ' ', ' '], - 'cell' => ['|', ' ', '|', '|'], - 'middle' => ['|', '-', '|', '|'], - 'bottom' => [' ', ' ', ' ', ' '], - 'cross-top' => ['|', ' ', ' ', '|'], + 'markdown' => [ + 'top' => [' ', ' ', ' ', ' '], + 'cell' => ['|', ' ', '|', '|'], + 'middle' => ['|', '-', '|', '|'], + 'bottom' => [' ', ' ', ' ', ' '], + 'cross-top' => ['|', ' ', ' ', '|'], 'cross-bottom' => ['|', ' ', ' ', '|'], ], 'borderless' => [ - 'top' => ['=', '=', ' ', '='], - 'cell' => [' ', ' ', ' ', ' '], - 'middle' => ['=', '=', ' ', '='], - 'bottom' => ['=', '=', ' ', '='], - 'cross-top' => ['=', '=', ' ', '='], + 'top' => ['=', '=', ' ', '='], + 'cell' => [' ', ' ', ' ', ' '], + 'middle' => ['=', '=', ' ', '='], + 'bottom' => ['=', '=', ' ', '='], + 'cross-top' => ['=', '=', ' ', '='], 'cross-bottom' => ['=', '=', ' ', '='], ], - 'box' => [ - 'top' => ['┌', '─', '┬', '┐'], - 'cell' => ['│', ' ', '│', '│'], - 'middle' => ['├', '─', '┼', '┤'], - 'bottom' => ['└', '─', '┴', '┘'], - 'cross-top' => ['├', '─', '┴', '┤'], + 'box' => [ + 'top' => ['┌', '─', '┬', '┐'], + 'cell' => ['│', ' ', '│', '│'], + 'middle' => ['├', '─', '┼', '┤'], + 'bottom' => ['└', '─', '┴', '┘'], + 'cross-top' => ['├', '─', '┴', '┤'], 'cross-bottom' => ['├', '─', '┬', '┤'], ], 'box-double' => [ - 'top' => ['╔', '═', '╤', '╗'], - 'cell' => ['║', ' ', '│', '║'], - 'middle' => ['╠', '─', '╪', '╣'], - 'bottom' => ['╚', '═', '╧', '╝'], - 'cross-top' => ['╠', '═', '╧', '╣'], + 'top' => ['╔', '═', '╤', '╗'], + 'cell' => ['║', ' ', '│', '║'], + 'middle' => ['╠', '─', '╪', '╣'], + 'bottom' => ['╚', '═', '╧', '╝'], + 'cross-top' => ['╠', '═', '╧', '╣'], 'cross-bottom' => ['╠', '═', '╤', '╣'], ], ]; @@ -111,7 +111,7 @@ class Table */ public function setHeader(array $header, int $align = 1): void { - $this->header = $header; + $this->header = $header; $this->headerAlign = $align; $this->checkColWidth($header); @@ -126,7 +126,7 @@ public function setHeader(array $header, int $align = 1): void */ public function setRows(array $rows, int $align = 1): void { - $this->rows = $rows; + $this->rows = $rows; $this->cellAlign = $align; foreach ($rows as $row) { @@ -217,7 +217,7 @@ protected function renderSeparator(string $pos): string */ protected function renderHeader(): string { - $style = $this->getStyle('cell'); + $style = $this->getStyle('cell'); $content = $this->renderSeparator('top'); foreach ($this->header as $key => $header) { @@ -260,7 +260,7 @@ public function render(array $dataList = []): string // 输出头部 $content = $this->renderHeader(); - $style = $this->getStyle('cell'); + $style = $this->getStyle('cell'); if (!empty($this->rows)) { foreach ($this->rows as $row) { diff --git a/src/think/console/command/Lists.php b/src/think/console/command/Lists.php index d20fc751be..3e6ef7740b 100644 --- a/src/think/console/command/Lists.php +++ b/src/think/console/command/Lists.php @@ -56,7 +56,7 @@ public function getNativeDefinition(): InputDefinition protected function execute(Input $input, Output $output) { $output->describe($this->getConsole(), [ - 'raw_text' => $input->getOption('raw'), + 'raw_text' => $input->getOption('raw'), 'namespace' => $input->getArgument('namespace'), ]); } diff --git a/src/think/console/command/RouteList.php b/src/think/console/command/RouteList.php index e9d4c5d82c..655eb3b9a1 100644 --- a/src/think/console/command/RouteList.php +++ b/src/think/console/command/RouteList.php @@ -21,10 +21,10 @@ class RouteList extends Command { protected $sortBy = [ - 'rule' => 0, - 'route' => 1, + 'rule' => 0, + 'route' => 1, 'method' => 2, - 'name' => 3, + 'name' => 3, 'domain' => 4, ]; @@ -87,11 +87,11 @@ protected function getRouteList(string $dir = null): string $table->setHeader($header); $routeList = $this->app->route->getRuleList(); - $rows = []; + $rows = []; foreach ($routeList as $item) { $item['route'] = $item['route'] instanceof \Closure ? '' : $item['route']; - $row = [$item['rule'], $item['route'], $item['method'], $item['name']]; + $row = [$item['rule'], $item['route'], $item['method'], $item['name']]; if ($this->input->hasOption('more')) { array_push($row, $item['domain'], json_encode($item['option']), json_encode($item['pattern'])); diff --git a/src/think/console/command/make/Command.php b/src/think/console/command/make/Command.php index 9549a02153..f6278a17e8 100644 --- a/src/think/console/command/make/Command.php +++ b/src/think/console/command/make/Command.php @@ -29,10 +29,10 @@ protected function configure() protected function buildClass(string $name): string { $commandName = $this->input->getArgument('commandName') ?: strtolower(basename($name)); - $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); + $namespace = trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\'); $class = str_replace($namespace . '\\', '', $name); - $stub = file_get_contents($this->getStub()); + $stub = file_get_contents($this->getStub()); return str_replace(['{%commandName%}', '{%className%}', '{%namespace%}', '{%app_namespace%}'], [ $commandName, diff --git a/src/think/console/command/optimize/Schema.php b/src/think/console/command/optimize/Schema.php index 13dbdd50f6..4ec94f02ff 100644 --- a/src/think/console/command/optimize/Schema.php +++ b/src/think/console/command/optimize/Schema.php @@ -53,10 +53,10 @@ protected function execute(Input $input, Output $output) $this->buildDataBaseSchema($connection, (array) $table, $dbName); } else { if ($dir) { - $appPath = $this->app->getBasePath() . $dir . DIRECTORY_SEPARATOR; + $appPath = $this->app->getBasePath() . $dir . DIRECTORY_SEPARATOR; $namespace = 'app\\' . $dir; } else { - $appPath = $this->app->getBasePath(); + $appPath = $this->app->getBasePath(); $namespace = 'app'; } @@ -84,7 +84,7 @@ protected function buildModelSchema(string $class): void if (!$reflect->isAbstract() && $reflect->isSubclassOf('\think\Model')) { try { /** @var \think\Model $model */ - $model = new $class; + $model = new $class; $connection = $model->db()->getConnection(); if ($connection instanceof PDOConnection) { $table = $model->getTable(); diff --git a/src/think/console/input/Argument.php b/src/think/console/input/Argument.php index 86cca36cb4..7a56c2d033 100644 --- a/src/think/console/input/Argument.php +++ b/src/think/console/input/Argument.php @@ -62,8 +62,8 @@ public function __construct(string $name, int $mode = null, string $description throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); } - $this->name = $name; - $this->mode = $mode; + $this->name = $name; + $this->mode = $mode; $this->description = $description; $this->setDefault($default); diff --git a/src/think/console/input/Definition.php b/src/think/console/input/Definition.php index ccf02a0c7a..abd2c63617 100644 --- a/src/think/console/input/Definition.php +++ b/src/think/console/input/Definition.php @@ -46,7 +46,7 @@ public function __construct(array $definition = []) public function setDefinition(array $definition): void { $arguments = []; - $options = []; + $options = []; foreach ($definition as $item) { if ($item instanceof Option) { $options[] = $item; @@ -65,9 +65,9 @@ public function setDefinition(array $definition): void */ public function setArguments(array $arguments = []): void { - $this->arguments = []; - $this->requiredCount = 0; - $this->hasOptional = false; + $this->arguments = []; + $this->requiredCount = 0; + $this->hasOptional = false; $this->hasAnArrayArgument = false; $this->addArguments($arguments); } @@ -195,7 +195,7 @@ public function getArgumentDefaults(): array */ public function setOptions(array $options = []): void { - $this->options = []; + $this->options = []; $this->shortcuts = []; $this->addOptions($options); } @@ -346,7 +346,7 @@ public function getSynopsis(bool $short = false): string $value = sprintf(' %s%s%s', $option->isValueOptional() ? '[' : '', strtoupper($option->getName()), $option->isValueOptional() ? ']' : ''); } - $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; + $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value); } } diff --git a/src/think/console/input/Option.php b/src/think/console/input/Option.php index d7e6514424..e7191470fe 100644 --- a/src/think/console/input/Option.php +++ b/src/think/console/input/Option.php @@ -85,7 +85,7 @@ public function __construct($name, $shortcut = null, $mode = null, $description } $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-')); $shortcuts = array_filter($shortcuts); - $shortcut = implode('|', $shortcuts); + $shortcut = implode('|', $shortcuts); if (empty($shortcut)) { throw new \InvalidArgumentException('An option shortcut cannot be empty.'); @@ -98,9 +98,9 @@ public function __construct($name, $shortcut = null, $mode = null, $description throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); } - $this->name = $name; - $this->shortcut = $shortcut; - $this->mode = $mode; + $this->name = $name; + $this->shortcut = $shortcut; + $this->mode = $mode; $this->description = $description; if ($this->isArray() && !$this->acceptValue()) { diff --git a/src/think/console/output/Ask.php b/src/think/console/output/Ask.php index 0058d052c1..1c3b42cbef 100644 --- a/src/think/console/output/Ask.php +++ b/src/think/console/output/Ask.php @@ -33,8 +33,8 @@ class Ask public function __construct(Input $input, Output $output, Question $question) { - $this->input = $input; - $this->output = $output; + $this->input = $input; + $this->output = $output; $this->question = $question; } @@ -61,7 +61,7 @@ protected function doAsk() { $this->writePrompt(); - $inputStream = STDIN; + $inputStream = STDIN; $autocomplete = $this->question->getAutocompleterValues(); if (null === $autocomplete || !$this->hasSttyAvailable()) { @@ -99,11 +99,11 @@ protected function doAsk() private function autocomplete($inputStream) { $autocomplete = $this->question->getAutocompleterValues(); - $ret = ''; + $ret = ''; - $i = 0; - $ofs = -1; - $matches = $autocomplete; + $i = 0; + $ofs = -1; + $matches = $autocomplete; $numMatches = count($matches); $sttyMode = shell_exec('stty -g'); @@ -120,8 +120,8 @@ private function autocomplete($inputStream) } if ($i === 0) { - $ofs = -1; - $matches = $autocomplete; + $ofs = -1; + $matches = $autocomplete; $numMatches = count($matches); } else { $numMatches = 0; @@ -166,7 +166,7 @@ private function autocomplete($inputStream) ++$i; $numMatches = 0; - $ofs = 0; + $ofs = 0; foreach ($autocomplete as $value) { if (0 === strpos($value, $ret) && $i !== strlen($value)) { @@ -220,7 +220,7 @@ protected function getHiddenResponse($inputStream) if (false !== $shell = $this->getShell()) { $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); - $value = rtrim(shell_exec($command)); + $value = rtrim(shell_exec($command)); $this->output->writeln(''); return $value; @@ -232,7 +232,7 @@ protected function getHiddenResponse($inputStream) protected function validateAttempts($interviewer) { /** @var \Exception $error */ - $error = null; + $error = null; $attempts = $this->question->getMaxAttempts(); while (null === $attempts || $attempts--) { if (null !== $error) { @@ -253,7 +253,7 @@ protected function validateAttempts($interviewer) */ protected function writePrompt() { - $text = $this->question->getQuestion(); + $text = $this->question->getQuestion(); $default = $this->question->getDefault(); switch (true) { @@ -281,7 +281,7 @@ protected function writePrompt() case $this->question instanceof Choice: $choices = $this->question->getChoices(); - $text = sprintf(' %s [%s]:', $text, $choices[$default]); + $text = sprintf(' %s [%s]:', $text, $choices[$default]); break; diff --git a/src/think/console/output/Descriptor.php b/src/think/console/output/Descriptor.php index 84d487c3a1..00db61da45 100644 --- a/src/think/console/output/Descriptor.php +++ b/src/think/console/output/Descriptor.php @@ -82,7 +82,7 @@ protected function describeInputArgument(InputArgument $argument, array $options $default = ''; } - $totalWidth = $options['total_width'] ?? strlen($argument->getName()); + $totalWidth = $options['total_width'] ?? strlen($argument->getName()); $spacingWidth = $totalWidth - strlen($argument->getName()) + 2; $this->writeText(sprintf(" %s%s%s%s", $argument->getName(), str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces @@ -116,7 +116,7 @@ protected function describeInputOption(InputOption $option, array $options = []) } $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]); - $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value)); + $synopsis = sprintf('%s%s', $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', sprintf('--%s%s', $option->getName(), $value)); $spacingWidth = $totalWidth - strlen($synopsis) + 2; @@ -213,7 +213,7 @@ protected function describeCommand(Command $command, array $options = []) protected function describeConsole(Console $console, array $options = []) { $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; - $description = new ConsoleDescription($console, $describedNamespace); + $description = new ConsoleDescription($console, $describedNamespace); if (isset($options['raw_text']) && $options['raw_text']) { $width = $this->getColumnWidth($description->getNamespaces()); diff --git a/src/think/console/output/Formatter.php b/src/think/console/output/Formatter.php index 1b97ca324c..4c176d7496 100644 --- a/src/think/console/output/Formatter.php +++ b/src/think/console/output/Formatter.php @@ -17,7 +17,7 @@ class Formatter { private $decorated = false; - private $styles = []; + private $styles = []; private $styleStack; /** @@ -105,12 +105,12 @@ public function getStyle($name) */ public function format($message) { - $offset = 0; - $output = ''; + $offset = 0; + $output = ''; $tagRegex = '[a-z][a-z0-9_=;-]*'; preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $match) { - $pos = $match[1]; + $pos = $match[1]; $text = $match[0]; if (0 != $pos && '\\' == $message[$pos - 1]) { diff --git a/src/think/console/output/Question.php b/src/think/console/output/Question.php index 03975f2748..a74144bb07 100644 --- a/src/think/console/output/Question.php +++ b/src/think/console/output/Question.php @@ -16,7 +16,7 @@ class Question private $question; private $attempts; - private $hidden = false; + private $hidden = false; private $hiddenFallback = true; private $autocompleterValues; private $validator; @@ -31,7 +31,7 @@ class Question public function __construct($question, $default = null) { $this->question = $question; - $this->default = $default; + $this->default = $default; } /** diff --git a/src/think/console/output/descriptor/Console.php b/src/think/console/output/descriptor/Console.php index ff9f4641e1..6df2d2b5b7 100644 --- a/src/think/console/output/descriptor/Console.php +++ b/src/think/console/output/descriptor/Console.php @@ -51,7 +51,7 @@ class Console */ public function __construct(ThinkConsole $console, $namespace = null) { - $this->console = $console; + $this->console = $console; $this->namespace = $namespace; } @@ -95,7 +95,7 @@ public function getCommand(string $name): Command private function inspectConsole(): void { - $this->commands = []; + $this->commands = []; $this->namespaces = []; $all = $this->console->all($this->namespace ? $this->console->findNamespace($this->namespace) : null); diff --git a/src/think/console/output/driver/Buffer.php b/src/think/console/output/driver/Buffer.php index 576f31ac30..95b4fbcf28 100644 --- a/src/think/console/output/driver/Buffer.php +++ b/src/think/console/output/driver/Buffer.php @@ -27,7 +27,7 @@ public function __construct(Output $output) public function fetch() { - $content = $this->buffer; + $content = $this->buffer; $this->buffer = ''; return $content; } diff --git a/src/think/console/output/driver/Console.php b/src/think/console/output/driver/Console.php index 3061f55765..06f98c7c53 100644 --- a/src/think/console/output/driver/Console.php +++ b/src/think/console/output/driver/Console.php @@ -30,10 +30,10 @@ class Console public function __construct(Output $output) { - $this->output = $output; + $this->output = $output; $this->formatter = new Formatter(); - $this->stdout = $this->openOutputStream(); - $decorated = $this->hasColorSupport($this->stdout); + $this->stdout = $this->openOutputStream(); + $decorated = $this->hasColorSupport($this->stdout); $this->formatter->setDecorated($decorated); } @@ -70,7 +70,7 @@ public function write($messages, bool $newline = false, int $type = 0, $stream = public function renderException(\Throwable $e) { - $stderr = $this->openErrorStream(); + $stderr = $this->openErrorStream(); $decorated = $this->hasColorSupport($stderr); $this->formatter->setDecorated($decorated); @@ -89,13 +89,13 @@ public function renderException(\Throwable $e) foreach ($this->splitStringByWidth($line, $width - 4) as $line) { $lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $line)) + 4; - $lines[] = [$line, $lineLength]; + $lines[] = [$line, $lineLength]; $len = max($lineLength, $len); } } - $messages = ['', '']; + $messages = ['', '']; $messages[] = $emptyLine = sprintf('%s', str_repeat(' ', $len)); $messages[] = sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))); foreach ($lines as $line) { @@ -114,17 +114,17 @@ public function renderException(\Throwable $e) $trace = $e->getTrace(); array_unshift($trace, [ 'function' => '', - 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', - 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', - 'args' => [], + 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', + 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', + 'args' => [], ]); for ($i = 0, $count = count($trace); $i < $count; ++$i) { - $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; - $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; + $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; + $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; $function = $trace[$i]['function']; - $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; - $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; + $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; $this->write(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line), true, Output::OUTPUT_NORMAL, $stderr); } @@ -200,7 +200,7 @@ private function getSttyColumns() } $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; - $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); @@ -223,7 +223,7 @@ private function getMode() } $descriptorspec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; - $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); + $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (is_resource($process)) { $info = stream_get_contents($pipes[1]); fclose($pipes[1]); @@ -262,15 +262,15 @@ private function splitStringByWidth(string $string, int $width): array } $utf8String = mb_convert_encoding($string, 'utf8', $encoding); - $lines = []; - $line = ''; + $lines = []; + $line = ''; foreach (preg_split('//u', $utf8String) as $char) { if (mb_strwidth($line . $char, 'utf8') <= $width) { $line .= $char; continue; } $lines[] = str_pad($line, $width); - $line = $char; + $line = $char; } if (strlen($line)) { $lines[] = count($lines) ? str_pad($line, $width) : $line; diff --git a/src/think/console/output/formatter/Style.php b/src/think/console/output/formatter/Style.php index 2aae768296..f5fe149e0d 100644 --- a/src/think/console/output/formatter/Style.php +++ b/src/think/console/output/formatter/Style.php @@ -14,33 +14,33 @@ class Style { protected static $availableForegroundColors = [ - 'black' => ['set' => 30, 'unset' => 39], - 'red' => ['set' => 31, 'unset' => 39], - 'green' => ['set' => 32, 'unset' => 39], - 'yellow' => ['set' => 33, 'unset' => 39], - 'blue' => ['set' => 34, 'unset' => 39], + 'black' => ['set' => 30, 'unset' => 39], + 'red' => ['set' => 31, 'unset' => 39], + 'green' => ['set' => 32, 'unset' => 39], + 'yellow' => ['set' => 33, 'unset' => 39], + 'blue' => ['set' => 34, 'unset' => 39], 'magenta' => ['set' => 35, 'unset' => 39], - 'cyan' => ['set' => 36, 'unset' => 39], - 'white' => ['set' => 37, 'unset' => 39], + 'cyan' => ['set' => 36, 'unset' => 39], + 'white' => ['set' => 37, 'unset' => 39], ]; protected static $availableBackgroundColors = [ - 'black' => ['set' => 40, 'unset' => 49], - 'red' => ['set' => 41, 'unset' => 49], - 'green' => ['set' => 42, 'unset' => 49], - 'yellow' => ['set' => 43, 'unset' => 49], - 'blue' => ['set' => 44, 'unset' => 49], + 'black' => ['set' => 40, 'unset' => 49], + 'red' => ['set' => 41, 'unset' => 49], + 'green' => ['set' => 42, 'unset' => 49], + 'yellow' => ['set' => 43, 'unset' => 49], + 'blue' => ['set' => 44, 'unset' => 49], 'magenta' => ['set' => 45, 'unset' => 49], - 'cyan' => ['set' => 46, 'unset' => 49], - 'white' => ['set' => 47, 'unset' => 49], + 'cyan' => ['set' => 46, 'unset' => 49], + 'white' => ['set' => 47, 'unset' => 49], ]; protected static $availableOptions = [ - 'bold' => ['set' => 1, 'unset' => 22], + 'bold' => ['set' => 1, 'unset' => 22], 'underscore' => ['set' => 4, 'unset' => 24], - 'blink' => ['set' => 5, 'unset' => 25], - 'reverse' => ['set' => 7, 'unset' => 27], - 'conceal' => ['set' => 8, 'unset' => 28], + 'blink' => ['set' => 5, 'unset' => 25], + 'reverse' => ['set' => 7, 'unset' => 27], + 'conceal' => ['set' => 8, 'unset' => 28], ]; private $foreground; @@ -163,20 +163,20 @@ public function setOptions(array $options) */ public function apply(string $text): string { - $setCodes = []; + $setCodes = []; $unsetCodes = []; if (null !== $this->foreground) { - $setCodes[] = $this->foreground['set']; + $setCodes[] = $this->foreground['set']; $unsetCodes[] = $this->foreground['unset']; } if (null !== $this->background) { - $setCodes[] = $this->background['set']; + $setCodes[] = $this->background['set']; $unsetCodes[] = $this->background['unset']; } if (count($this->options)) { foreach ($this->options as $option) { - $setCodes[] = $option['set']; + $setCodes[] = $option['set']; $unsetCodes[] = $option['unset']; } } diff --git a/src/think/console/output/question/Choice.php b/src/think/console/output/question/Choice.php index 1da1750ccd..302dd489c1 100644 --- a/src/think/console/output/question/Choice.php +++ b/src/think/console/output/question/Choice.php @@ -17,8 +17,8 @@ class Choice extends Question { private $choices; - private $multiselect = false; - private $prompt = ' > '; + private $multiselect = false; + private $prompt = ' > '; private $errorMessage = 'Value "%s" is invalid'; /** @@ -103,10 +103,10 @@ public function setErrorMessage(string $errorMessage) */ private function getDefaultValidator() { - $choices = $this->choices; + $choices = $this->choices; $errorMessage = $this->errorMessage; - $multiselect = $this->multiselect; - $isAssoc = $this->isAssoc($choices); + $multiselect = $this->multiselect; + $isAssoc = $this->isAssoc($choices); return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) { // Collapse all spaces. diff --git a/src/think/console/output/question/Confirmation.php b/src/think/console/output/question/Confirmation.php index bf71b5d6da..791c859fe9 100644 --- a/src/think/console/output/question/Confirmation.php +++ b/src/think/console/output/question/Confirmation.php @@ -39,7 +39,7 @@ public function __construct(string $question, bool $default = true, string $true private function getDefaultNormalizer() { $default = $this->getDefault(); - $regex = $this->trueAnswerRegex; + $regex = $this->trueAnswerRegex; return function ($answer) use ($default, $regex) { if (is_bool($answer)) { diff --git a/src/think/event/LogRecord.php b/src/think/event/LogRecord.php index 237468dd5e..1b75652fa4 100644 --- a/src/think/event/LogRecord.php +++ b/src/think/event/LogRecord.php @@ -23,7 +23,7 @@ class LogRecord public function __construct($type, $message) { - $this->type = $type; + $this->type = $type; $this->message = $message; } } diff --git a/src/think/event/LogWrite.php b/src/think/event/LogWrite.php index a7873018d8..11f56f017f 100644 --- a/src/think/event/LogWrite.php +++ b/src/think/event/LogWrite.php @@ -26,6 +26,6 @@ class LogWrite public function __construct($channel, $log) { $this->channel = $channel; - $this->log = $log; + $this->log = $log; } } diff --git a/src/think/exception/ClassNotFoundException.php b/src/think/exception/ClassNotFoundException.php index c4cda77d5a..4b13efee8c 100644 --- a/src/think/exception/ClassNotFoundException.php +++ b/src/think/exception/ClassNotFoundException.php @@ -22,7 +22,7 @@ class ClassNotFoundException extends RuntimeException implements NotFoundExcepti public function __construct(string $message, string $class = '', Throwable $previous = null) { $this->message = $message; - $this->class = $class; + $this->class = $class; parent::__construct($message, 0, $previous); } diff --git a/src/think/exception/ErrorException.php b/src/think/exception/ErrorException.php index d1a237803a..e617952eee 100644 --- a/src/think/exception/ErrorException.php +++ b/src/think/exception/ErrorException.php @@ -39,10 +39,10 @@ class ErrorException extends Exception public function __construct(int $severity, string $message, string $file, int $line) { $this->severity = $severity; - $this->message = $message; - $this->file = $file; - $this->line = $line; - $this->code = 0; + $this->message = $message; + $this->file = $file; + $this->line = $line; + $this->code = 0; } /** diff --git a/src/think/exception/FuncNotFoundException.php b/src/think/exception/FuncNotFoundException.php index ee2bcad2e0..988659a43e 100644 --- a/src/think/exception/FuncNotFoundException.php +++ b/src/think/exception/FuncNotFoundException.php @@ -13,7 +13,7 @@ class FuncNotFoundException extends RuntimeException implements NotFoundExceptio public function __construct(string $message, string $func = '', Throwable $previous = null) { $this->message = $message; - $this->func = $func; + $this->func = $func; parent::__construct($message, 0, $previous); } diff --git a/src/think/exception/Handle.php b/src/think/exception/Handle.php index 1f783bc52e..5823f06914 100644 --- a/src/think/exception/Handle.php +++ b/src/think/exception/Handle.php @@ -57,15 +57,15 @@ public function report(Throwable $exception): void // 收集异常数据 if ($this->app->isDebug()) { $data = [ - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), 'message' => $this->getMessage($exception), - 'code' => $this->getCode($exception), + 'code' => $this->getCode($exception), ]; $log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]"; } else { $data = [ - 'code' => $this->getCode($exception), + 'code' => $this->getCode($exception), 'message' => $this->getMessage($exception), ]; $log = "[{$data['code']}]{$data['message']}"; @@ -133,7 +133,7 @@ public function renderForConsole(Output $output, Throwable $e): void */ protected function renderHttpException(HttpException $e): Response { - $status = $e->getStatusCode(); + $status = $e->getStatusCode(); $template = $this->app->config->get('app.http_exception_template'); if (!$this->app->isDebug() && !empty($template[$status])) { @@ -152,37 +152,37 @@ protected function convertExceptionToArray(Throwable $exception): array { if ($this->app->isDebug()) { // 调试模式,获取详细的错误信息 - $traces = []; + $traces = []; $nextException = $exception; do { $traces[] = [ - 'name' => get_class($nextException), - 'file' => $nextException->getFile(), - 'line' => $nextException->getLine(), - 'code' => $this->getCode($nextException), + 'name' => get_class($nextException), + 'file' => $nextException->getFile(), + 'line' => $nextException->getLine(), + 'code' => $this->getCode($nextException), 'message' => $this->getMessage($nextException), - 'trace' => $nextException->getTrace(), - 'source' => $this->getSourceCode($nextException), + 'trace' => $nextException->getTrace(), + 'source' => $this->getSourceCode($nextException), ]; } while ($nextException = $nextException->getPrevious()); $data = [ - 'code' => $this->getCode($exception), + 'code' => $this->getCode($exception), 'message' => $this->getMessage($exception), - 'traces' => $traces, - 'datas' => $this->getExtendData($exception), - 'tables' => [ - 'GET Data' => $this->app->request->get(), - 'POST Data' => $this->app->request->post(), - 'Files' => $this->app->request->file(), - 'Cookies' => $this->app->request->cookie(), - 'Session' => $this->app->exists('session') ? $this->app->session->all() : [], + 'traces' => $traces, + 'datas' => $this->getExtendData($exception), + 'tables' => [ + 'GET Data' => $this->app->request->get(), + 'POST Data' => $this->app->request->post(), + 'Files' => $this->app->request->file(), + 'Cookies' => $this->app->request->cookie(), + 'Session' => $this->app->exists('session') ? $this->app->session->all() : [], 'Server/Request Data' => $this->app->request->server(), ], ]; } else { // 部署模式仅显示 Code 和 Message $data = [ - 'code' => $this->getCode($exception), + 'code' => $this->getCode($exception), 'message' => $this->getMessage($exception), ]; @@ -262,10 +262,10 @@ protected function getMessage(Throwable $exception): string $lang = $this->app->lang; if (strpos($message, ':')) { - $name = strstr($message, ':', true); + $name = strstr($message, ':', true); $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message; } elseif (strpos($message, ',')) { - $name = strstr($message, ',', true); + $name = strstr($message, ',', true); $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message; } elseif ($lang->has($message)) { $message = $lang->get($message); @@ -284,13 +284,13 @@ protected function getMessage(Throwable $exception): string protected function getSourceCode(Throwable $exception): array { // 读取前9行和后9行 - $line = $exception->getLine(); + $line = $exception->getLine(); $first = ($line - 9 > 0) ? $line - 9 : 1; try { $contents = file($exception->getFile()) ?: []; - $source = [ - 'first' => $first, + $source = [ + 'first' => $first, 'source' => array_slice($contents, $first - 1, 19), ]; } catch (Exception $e) { diff --git a/src/think/exception/HttpException.php b/src/think/exception/HttpException.php index 45302e587c..9a3edd03dd 100644 --- a/src/think/exception/HttpException.php +++ b/src/think/exception/HttpException.php @@ -25,7 +25,7 @@ class HttpException extends \RuntimeException public function __construct(int $statusCode, string $message = '', Exception $previous = null, array $headers = [], $code = 0) { $this->statusCode = $statusCode; - $this->headers = $headers; + $this->headers = $headers; parent::__construct($message, $code, $previous); } diff --git a/src/think/exception/ValidateException.php b/src/think/exception/ValidateException.php index 89b4e4d584..16ac9f2098 100644 --- a/src/think/exception/ValidateException.php +++ b/src/think/exception/ValidateException.php @@ -21,7 +21,7 @@ class ValidateException extends \RuntimeException public function __construct($error) { - $this->error = $error; + $this->error = $error; $this->message = is_array($error) ? implode(PHP_EOL, $error) : $error; } diff --git a/src/think/file/UploadedFile.php b/src/think/file/UploadedFile.php index 7dff766e13..adad481b39 100644 --- a/src/think/file/UploadedFile.php +++ b/src/think/file/UploadedFile.php @@ -26,9 +26,9 @@ class UploadedFile extends File public function __construct(string $path, string $originalName, string $mimeType = null, int $error = null, bool $test = false) { $this->originalName = $originalName; - $this->mimeType = $mimeType ?: 'application/octet-stream'; - $this->test = $test; - $this->error = $error ?: UPLOAD_ERR_OK; + $this->mimeType = $mimeType ?: 'application/octet-stream'; + $this->test = $test; + $this->error = $error ?: UPLOAD_ERR_OK; parent::__construct($path, UPLOAD_ERR_OK === $this->error); } diff --git a/src/think/filesystem/CacheStore.php b/src/think/filesystem/CacheStore.php index 0a62399e05..fd3a82d605 100644 --- a/src/think/filesystem/CacheStore.php +++ b/src/think/filesystem/CacheStore.php @@ -25,8 +25,8 @@ class CacheStore extends AbstractCache public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null) { - $this->key = $key; - $this->store = $store; + $this->key = $key; + $this->store = $store; $this->expire = $expire; } diff --git a/src/think/filesystem/Driver.php b/src/think/filesystem/Driver.php index 0e61cf4394..55f73a4d80 100644 --- a/src/think/filesystem/Driver.php +++ b/src/think/filesystem/Driver.php @@ -43,10 +43,10 @@ abstract class Driver public function __construct(Cache $cache, array $config) { - $this->cache = $cache; + $this->cache = $cache; $this->config = array_merge($this->config, $config); - $adapter = $this->createAdapter(); + $adapter = $this->createAdapter(); $this->filesystem = $this->createFilesystem($adapter); } @@ -126,7 +126,7 @@ public function putFile(string $path, File $file, $rule = null, array $options = public function putFileAs(string $path, File $file, string $name, array $options = []) { $stream = fopen($file->getRealPath(), 'r'); - $path = trim($path . '/' . $name, '/'); + $path = trim($path . '/' . $name, '/'); $result = $this->putStream($path, $stream, $options); diff --git a/src/think/log/Channel.php b/src/think/log/Channel.php index 1de96f1a51..64653805e5 100644 --- a/src/think/log/Channel.php +++ b/src/think/log/Channel.php @@ -45,11 +45,11 @@ class Channel implements LoggerInterface public function __construct(string $name, LogHandlerInterface $logger, array $allow, bool $lazy = true, Event $event = null) { - $this->name = $name; + $this->name = $name; $this->logger = $logger; - $this->allow = $allow; - $this->lazy = $lazy; - $this->event = $event; + $this->allow = $allow; + $this->lazy = $lazy; + $this->event = $event; } /** diff --git a/src/think/log/ChannelSet.php b/src/think/log/ChannelSet.php index 6dcb0bdb0e..01d18da61e 100644 --- a/src/think/log/ChannelSet.php +++ b/src/think/log/ChannelSet.php @@ -26,7 +26,7 @@ class ChannelSet public function __construct(Log $log, array $channels) { - $this->log = $log; + $this->log = $log; $this->channels = $channels; } diff --git a/src/think/log/driver/File.php b/src/think/log/driver/File.php index 1f726b00d0..21de63e805 100644 --- a/src/think/log/driver/File.php +++ b/src/think/log/driver/File.php @@ -25,15 +25,15 @@ class File implements LogHandlerInterface * @var array */ protected $config = [ - 'time_format' => 'c', - 'single' => false, - 'file_size' => 2097152, - 'path' => '', - 'apart_level' => [], - 'max_files' => 0, - 'json' => false, + 'time_format' => 'c', + 'single' => false, + 'file_size' => 2097152, + 'path' => '', + 'apart_level' => [], + 'max_files' => 0, + 'json' => false, 'json_options' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, - 'format' => '[%s][%s] %s', + 'format' => '[%s][%s] %s', ]; // 实例化并传入参数 @@ -149,7 +149,7 @@ protected function getMasterLogFile(): string } if ($this->config['single']) { - $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; + $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; $destination = $this->config['path'] . $name . '.log'; } else { diff --git a/src/think/log/driver/Socket.php b/src/think/log/driver/Socket.php index 2cfb943392..563e66385a 100644 --- a/src/think/log/driver/Socket.php +++ b/src/think/log/driver/Socket.php @@ -26,34 +26,34 @@ class Socket implements LogHandlerInterface protected $config = [ // socket服务器地址 - 'host' => 'localhost', + 'host' => 'localhost', // socket服务器端口 - 'port' => 1116, + 'port' => 1116, // 是否显示加载的文件列表 'show_included_files' => false, // 日志强制记录到配置的client_id - 'force_client_ids' => [], + 'force_client_ids' => [], // 限制允许读取日志的client_id - 'allow_client_ids' => [], + 'allow_client_ids' => [], // 调试开关 - 'debug' => false, + 'debug' => false, // 输出到浏览器时默认展开的日志级别 - 'expand_level' => ['debug'], + 'expand_level' => ['debug'], // 日志头渲染回调 - 'format_head' => null, + 'format_head' => null, // curl opt - 'curl_opt' => [ + 'curl_opt' => [ CURLOPT_CONNECTTIMEOUT => 1, - CURLOPT_TIMEOUT => 10, + CURLOPT_TIMEOUT => 10, ], ]; protected $css = [ - 'sql' => 'color:#009bb4;', + 'sql' => 'color:#009bb4;', 'sql_warn' => 'color:#009bb4;font-size:14px;', - 'error' => 'color:#f4006b;font-size:14px;', - 'page' => 'color:#40e2ff;background:#171717;', - 'big' => 'font-size:20px;color:red;', + 'error' => 'color:#f4006b;font-size:14px;', + 'page' => 'color:#40e2ff;background:#171717;', + 'big' => 'font-size:20px;color:red;', ]; protected $allowForceClientIds = []; //配置强制推送且被授权的client_id @@ -111,8 +111,8 @@ public function save(array $log = []): bool // 基本信息 $trace[] = [ 'type' => 'group', - 'msg' => $currentUri, - 'css' => $this->css['page'], + 'msg' => $currentUri, + 'css' => $this->css['page'], ]; } @@ -121,8 +121,8 @@ public function save(array $log = []): bool foreach ($log as $type => $val) { $trace[] = [ 'type' => isset($expandLevel[$type]) ? 'group' : 'groupCollapsed', - 'msg' => '[ ' . $type . ' ]', - 'css' => $this->css[$type] ?? '', + 'msg' => '[ ' . $type . ' ]', + 'css' => $this->css[$type] ?? '', ]; foreach ($val as $msg) { @@ -131,42 +131,42 @@ public function save(array $log = []): bool } $trace[] = [ 'type' => 'log', - 'msg' => $msg, - 'css' => '', + 'msg' => $msg, + 'css' => '', ]; } $trace[] = [ 'type' => 'groupEnd', - 'msg' => '', - 'css' => '', + 'msg' => '', + 'css' => '', ]; } if ($this->config['show_included_files']) { $trace[] = [ 'type' => 'groupCollapsed', - 'msg' => '[ file ]', - 'css' => '', + 'msg' => '[ file ]', + 'css' => '', ]; $trace[] = [ 'type' => 'log', - 'msg' => implode("\n", get_included_files()), - 'css' => '', + 'msg' => implode("\n", get_included_files()), + 'css' => '', ]; $trace[] = [ 'type' => 'groupEnd', - 'msg' => '', - 'css' => '', + 'msg' => '', + 'css' => '', ]; } $trace[] = [ 'type' => 'groupEnd', - 'msg' => '', - 'css' => '', + 'msg' => '', + 'css' => '', ]; $tabid = $this->getClientArg('tabid'); @@ -200,13 +200,13 @@ public function save(array $log = []): bool protected function sendToClient($tabid, $clientId, $logs, $forceClientId) { $logs = [ - 'tabid' => $tabid, - 'client_id' => $clientId, - 'logs' => $logs, + 'tabid' => $tabid, + 'client_id' => $clientId, + 'logs' => $logs, 'force_client_id' => $forceClientId, ]; - $msg = json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); + $msg = json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); $address = '/' . $clientId; //将client_id作为地址, server端通过地址判断将日志发布给谁 $this->send($this->config['host'], $this->config['port'], $msg, $address); @@ -291,7 +291,7 @@ protected function getClientArg(string $name) protected function send($host, $port, $message = '', $address = '/') { $url = 'http://' . $host . ':' . $port . $address; - $ch = curl_init(); + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); diff --git a/src/think/middleware/AllowCrossDomain.php b/src/think/middleware/AllowCrossDomain.php index b7ab842c4c..6ce59e6872 100644 --- a/src/think/middleware/AllowCrossDomain.php +++ b/src/think/middleware/AllowCrossDomain.php @@ -26,9 +26,9 @@ class AllowCrossDomain protected $header = [ 'Access-Control-Allow-Credentials' => 'true', - 'Access-Control-Max-Age' => 1800, - 'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, DELETE, OPTIONS', - 'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With', + 'Access-Control-Max-Age' => 1800, + 'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With', ]; public function __construct(Config $config) diff --git a/src/think/middleware/CheckRequestCache.php b/src/think/middleware/CheckRequestCache.php index b1143519c8..a4897b1b19 100644 --- a/src/think/middleware/CheckRequestCache.php +++ b/src/think/middleware/CheckRequestCache.php @@ -35,18 +35,18 @@ class CheckRequestCache */ protected $config = [ // 请求缓存规则 true为自动规则 - 'request_cache_key' => true, + 'request_cache_key' => true, // 请求缓存有效期 'request_cache_expire' => null, // 全局请求缓存排除规则 'request_cache_except' => [], // 请求缓存的Tag - 'request_cache_tag' => '', + 'request_cache_tag' => '', ]; public function __construct(Cache $cache, Config $config) { - $this->cache = $cache; + $this->cache = $cache; $this->config = array_merge($this->config, $config->get('route')); } @@ -72,9 +72,9 @@ public function handle($request, Closure $next, $cache = null) if (is_array($cache)) { [$key, $expire, $tag] = array_pad($cache, 3, null); } else { - $key = md5($request->url(true)); + $key = md5($request->url(true)); $expire = $cache; - $tag = null; + $tag = null; } $key = $this->parseCacheKey($request, $key); @@ -94,10 +94,10 @@ public function handle($request, Closure $next, $cache = null) $response = $next($request); if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) { - $header = $response->getHeader(); + $header = $response->getHeader(); $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate'; $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT'; - $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; + $header['Expires'] = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'; $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire); } @@ -113,10 +113,10 @@ public function handle($request, Closure $next, $cache = null) */ protected function getRequestCache($request) { - $key = $this->config['request_cache_key']; + $key = $this->config['request_cache_key']; $expire = $this->config['request_cache_expire']; $except = $this->config['request_cache_except']; - $tag = $this->config['request_cache_tag']; + $tag = $this->config['request_cache_tag']; foreach ($except as $rule) { if (0 === stripos($request->url(), $rule)) { diff --git a/src/think/middleware/LoadLangPack.php b/src/think/middleware/LoadLangPack.php index af0324b83c..aadd5229ee 100644 --- a/src/think/middleware/LoadLangPack.php +++ b/src/think/middleware/LoadLangPack.php @@ -31,8 +31,8 @@ class LoadLangPack public function __construct(App $app, Lang $lang, Config $config) { - $this->app = $app; - $this->lang = $lang; + $this->app = $app; + $this->lang = $lang; $this->config = $lang->getConfig(); } diff --git a/src/think/middleware/SessionInit.php b/src/think/middleware/SessionInit.php index 55cea3b6de..911e08ded6 100644 --- a/src/think/middleware/SessionInit.php +++ b/src/think/middleware/SessionInit.php @@ -32,7 +32,7 @@ class SessionInit public function __construct(App $app, Session $session) { - $this->app = $app; + $this->app = $app; $this->session = $session; } @@ -47,7 +47,7 @@ public function handle($request, Closure $next) { // Session初始化 $varSessionId = $this->app->config->get('session.var_session_id'); - $cookieName = $this->session->getName(); + $cookieName = $this->session->getName(); if ($varSessionId && $request->request($varSessionId)) { $sessionId = $request->request($varSessionId); diff --git a/src/think/response/File.php b/src/think/response/File.php index 1e45f2f488..85821be32a 100644 --- a/src/think/response/File.php +++ b/src/think/response/File.php @@ -24,7 +24,7 @@ class File extends Response protected $name; protected $mimeType; protected $isContent = false; - protected $force = true; + protected $force = true; public function __construct($data = '', int $code = 200) { @@ -56,19 +56,19 @@ protected function output($data) if ($this->isContent) { $mimeType = $this->mimeType; - $size = strlen($data); + $size = strlen($data); } else { $mimeType = $this->getMimeType($data); - $size = filesize($data); + $size = filesize($data); } - $this->header['Pragma'] = 'public'; - $this->header['Content-Type'] = $mimeType ?: 'application/octet-stream'; - $this->header['Cache-control'] = 'max-age=' . $this->expire; - $this->header['Content-Disposition'] = ($this->force ? 'attachment; ' : '') . 'filename="' . $name . '"'; - $this->header['Content-Length'] = $size; + $this->header['Pragma'] = 'public'; + $this->header['Content-Type'] = $mimeType ?: 'application/octet-stream'; + $this->header['Cache-control'] = 'max-age=' . $this->expire; + $this->header['Content-Disposition'] = ($this->force ? 'attachment; ' : '') . 'filename="' . $name . '"'; + $this->header['Content-Length'] = $size; $this->header['Content-Transfer-Encoding'] = 'binary'; - $this->header['Expires'] = gmdate("D, d M Y H:i:s", time() + $this->expire) . ' GMT'; + $this->header['Expires'] = gmdate("D, d M Y H:i:s", time() + $this->expire) . ' GMT'; $this->lastModified(gmdate('D, d M Y H:i:s', time()) . ' GMT'); diff --git a/src/think/response/Jsonp.php b/src/think/response/Jsonp.php index 81d3a06e18..cb08c0a9a9 100644 --- a/src/think/response/Jsonp.php +++ b/src/think/response/Jsonp.php @@ -23,9 +23,9 @@ class Jsonp extends Response { // 输出参数 protected $options = [ - 'var_jsonp_handler' => 'callback', + 'var_jsonp_handler' => 'callback', 'default_jsonp_handler' => 'jsonpReturn', - 'json_encode_param' => JSON_UNESCAPED_UNICODE, + 'json_encode_param' => JSON_UNESCAPED_UNICODE, ]; protected $contentType = 'application/javascript'; @@ -36,7 +36,7 @@ public function __construct(Cookie $cookie, Request $request, $data = '', int $c { $this->init($data, $code); - $this->cookie = $cookie; + $this->cookie = $cookie; $this->request = $request; } @@ -52,7 +52,7 @@ protected function output($data): string try { // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的,故使用Request来获取] $varJsonpHandler = $this->request->param($this->options['var_jsonp_handler'], ""); - $handler = !empty($varJsonpHandler) ? $varJsonpHandler : $this->options['default_jsonp_handler']; + $handler = !empty($varJsonpHandler) ? $varJsonpHandler : $this->options['default_jsonp_handler']; $data = json_encode($data, $this->options['json_encode_param']); diff --git a/src/think/response/Redirect.php b/src/think/response/Redirect.php index ee067be007..96f81f8cf3 100644 --- a/src/think/response/Redirect.php +++ b/src/think/response/Redirect.php @@ -29,7 +29,7 @@ public function __construct(Cookie $cookie, Request $request, Session $session, { $this->init((string) $data, $code); - $this->cookie = $cookie; + $this->cookie = $cookie; $this->request = $request; $this->session = $session; diff --git a/src/think/response/View.php b/src/think/response/View.php index 2c116c778a..4a97c26d67 100644 --- a/src/think/response/View.php +++ b/src/think/response/View.php @@ -62,7 +62,7 @@ public function __construct(Cookie $cookie, BaseView $view, $data = '', int $cod $this->init($data, $code); $this->cookie = $cookie; - $this->view = $view; + $this->view = $view; } /** diff --git a/src/think/response/Xml.php b/src/think/response/Xml.php index bddbb48b5e..377596d68d 100644 --- a/src/think/response/Xml.php +++ b/src/think/response/Xml.php @@ -31,9 +31,9 @@ class Xml extends Response //数字索引的子节点名 'item_node' => 'item', // 数字索引子节点key转换的属性名 - 'item_key' => 'id', + 'item_key' => 'id', // 数据编码 - 'encoding' => 'utf-8', + 'encoding' => 'utf-8', ]; protected $contentType = 'text/xml'; @@ -55,8 +55,8 @@ protected function output($data): string if (is_string($data)) { if (0 !== strpos($data, 'options['encoding']; - $xml = ""; - $data = $xml . $data; + $xml = ""; + $data = $xml . $data; } return $data; } @@ -88,7 +88,7 @@ protected function xmlEncode($data, string $root, string $item, $attr, string $i $attr = trim($attr); $attr = empty($attr) ? '' : " {$attr}"; - $xml = ""; + $xml = ""; $xml .= "<{$root}{$attr}>"; $xml .= $this->dataToXml($data, $item, $id); $xml .= ""; @@ -115,7 +115,7 @@ protected function dataToXml($data, string $item, string $id): string foreach ($data as $key => $val) { if (is_numeric($key)) { $id && $attr = " {$id}=\"{$key}\""; - $key = $item; + $key = $item; } $xml .= "<{$key}{$attr}>"; $xml .= (is_array($val) || is_object($val)) ? $this->dataToXml($val, $item, $id) : $val; diff --git a/src/think/route/Dispatch.php b/src/think/route/Dispatch.php index 58666b50c9..f71c257c71 100644 --- a/src/think/route/Dispatch.php +++ b/src/think/route/Dispatch.php @@ -56,10 +56,10 @@ abstract class Dispatch public function __construct(Request $request, Rule $rule, $dispatch, array $param = []) { - $this->request = $request; - $this->rule = $rule; + $this->request = $request; + $this->rule = $rule; $this->dispatch = $dispatch; - $this->param = $param; + $this->param = $param; } public function init(App $app) @@ -103,13 +103,13 @@ protected function autoResponse($data): Response } } elseif (!is_null($data)) { // 默认自动识别响应输出类型 - $type = $this->request->isJson() ? 'json' : 'html'; + $type = $this->request->isJson() ? 'json' : 'html'; $response = Response::create($data, $type); } else { $data = ob_get_clean(); - $content = false === $data ? '' : $data; - $status = '' === $content && $this->request->isJson() ? 204 : 200; + $content = false === $data ? '' : $data; + $status = '' === $content && $this->request->isJson() ? 204 : 200; $response = Response::create($content, 'html', $status); } @@ -169,7 +169,7 @@ protected function createBindModel(array $bindModel, array $matches): void if (is_array($val)) { [$model, $exception] = $val; } else { - $model = $val; + $model = $val; $exception = true; } @@ -249,7 +249,7 @@ public function __sleep() public function __wakeup() { - $this->app = Container::pull('app'); + $this->app = Container::pull('app'); $this->request = $this->app->request; } @@ -257,8 +257,8 @@ public function __debugInfo() { return [ 'dispatch' => $this->dispatch, - 'param' => $this->param, - 'rule' => $this->rule, + 'param' => $this->param, + 'rule' => $this->rule, ]; } } diff --git a/src/think/route/Domain.php b/src/think/route/Domain.php index 84f1d463b4..cf9536d712 100644 --- a/src/think/route/Domain.php +++ b/src/think/route/Domain.php @@ -34,7 +34,7 @@ public function __construct(Route $router, string $name = null, $rule = null) { $this->router = $router; $this->domain = $name; - $this->rule = $rule; + $this->rule = $rule; } /** @@ -95,8 +95,8 @@ private function checkUrlBind(Request $request, string $url) $bindTo = [ '\\' => 'bindToClass', - '@' => 'bindToController', - ':' => 'bindToNamespace', + '@' => 'bindToController', + ':' => 'bindToNamespace', ]; if (isset($bindTo[$type])) { @@ -126,9 +126,9 @@ protected function parseBindAppendParam(string &$bind): void */ protected function bindToClass(Request $request, string $url, string $class): CallbackDispatch { - $array = explode('|', $url, 2); + $array = explode('|', $url, 2); $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); - $param = []; + $param = []; if (!empty($array[1])) { $this->parseUrlParams($array[1], $param); @@ -147,10 +147,10 @@ protected function bindToClass(Request $request, string $url, string $class): Ca */ protected function bindToNamespace(Request $request, string $url, string $namespace): CallbackDispatch { - $array = explode('|', $url, 3); - $class = !empty($array[0]) ? $array[0] : $this->router->config('default_controller'); + $array = explode('|', $url, 3); + $class = !empty($array[0]) ? $array[0] : $this->router->config('default_controller'); $method = !empty($array[1]) ? $array[1] : $this->router->config('default_action'); - $param = []; + $param = []; if (!empty($array[2])) { $this->parseUrlParams($array[2], $param); @@ -169,9 +169,9 @@ protected function bindToNamespace(Request $request, string $url, string $namesp */ protected function bindToController(Request $request, string $url, string $controller): ControllerDispatch { - $array = explode('|', $url, 2); + $array = explode('|', $url, 2); $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); - $param = []; + $param = []; if (!empty($array[1])) { $this->parseUrlParams($array[1], $param); diff --git a/src/think/route/Resource.php b/src/think/route/Resource.php index 5185cdc352..1b7a58a804 100644 --- a/src/think/route/Resource.php +++ b/src/think/route/Resource.php @@ -66,12 +66,12 @@ class Resource extends RuleGroup */ public function __construct(Route $router, RuleGroup $parent = null, string $name = '', string $route = '', array $rest = []) { - $name = ltrim($name, '/'); - $this->router = $router; - $this->parent = $parent; + $name = ltrim($name, '/'); + $this->router = $router; + $this->parent = $parent; $this->resource = $name; - $this->route = $route; - $this->name = strpos($name, '.') ? strstr($name, '.', true) : $name; + $this->route = $route; + $this->name = strpos($name, '.') ? strstr($name, '.', true) : $name; $this->setFullName(); @@ -97,7 +97,7 @@ public function __construct(Route $router, RuleGroup $parent = null, string $nam */ protected function buildResourceRule(): void { - $rule = $this->resource; + $rule = $this->resource; $option = $this->option; $origin = $this->router->getGroup(); $this->router->setGroup($this); @@ -105,8 +105,8 @@ protected function buildResourceRule(): void if (strpos($rule, '.')) { // 注册嵌套资源路由 $array = explode('.', $rule); - $last = array_pop($array); - $item = []; + $last = array_pop($array); + $item = []; foreach ($array as $val) { $item[] = $val . '/<' . ($option['var'][$val] ?? $val . '_id') . '>'; diff --git a/src/think/route/Rule.php b/src/think/route/Rule.php index 2d864cd256..d93c5f616f 100644 --- a/src/think/route/Rule.php +++ b/src/think/route/Rule.php @@ -603,13 +603,13 @@ public function parseRule(Request $request, string $rule, $route, string $url, a // 替换路由地址中的变量 $extraParams = true; - $search = $replace = []; - $depr = $this->router->config('pathinfo_depr'); + $search = $replace = []; + $depr = $this->router->config('pathinfo_depr'); foreach ($matches as $key => $value) { - $search[] = '<' . $key . '>'; + $search[] = '<' . $key . '>'; $replace[] = $value; - $search[] = ':' . $key; + $search[] = ':' . $key; $replace[] = $value; if (strpos($value, $depr)) { @@ -624,7 +624,7 @@ public function parseRule(Request $request, string $rule, $route, string $url, a // 解析额外参数 if ($extraParams) { $count = substr_count($rule, '/'); - $url = array_slice(explode('|', $url), $count + 1); + $url = array_slice(explode('|', $url), $count + 1); $this->parseUrlParams(implode('|', $url), $matches); } @@ -651,7 +651,7 @@ protected function dispatch(Request $request, $route, array $option): Dispatch $result = new CallbackDispatch($request, $this, $route, $this->vars); } elseif (false !== strpos($route, '@') || false !== strpos($route, '::') || false !== strpos($route, '\\')) { // 路由到类的方法 - $route = str_replace('::', '@', $route); + $route = str_replace('::', '@', $route); $result = $this->dispatchMethod($request, $route); } else { // 路由到控制器/操作 @@ -672,7 +672,7 @@ protected function dispatchMethod(Request $request, string $route): CallbackDisp { $path = $this->parseUrlPath($route); - $route = str_replace('/', '@', implode('/', $path)); + $route = str_replace('/', '@', implode('/', $path)); $method = strpos($route, '@') ? explode('@', $route) : $route; return new CallbackDispatch($request, $this, $method, $this->vars); @@ -689,7 +689,7 @@ protected function dispatchController(Request $request, string $route): Controll { $path = $this->parseUrlPath($route); - $action = array_pop($path); + $action = array_pop($path); $controller = !empty($path) ? array_pop($path) : null; // 路由到模块/控制器/操作 @@ -812,7 +812,7 @@ protected function buildRuleRegex(string $rule, array $match, array $pattern = [ foreach ($match as $name) { $value = $this->buildNameRegex($name, $pattern, $suffix); if ($value) { - $origin[] = $name; + $origin[] = $name; $replace[] = $value; } } @@ -822,7 +822,7 @@ protected function buildRuleRegex(string $rule, array $match, array $pattern = [ if (!empty($option['remove_slash'])) { $rule = rtrim($rule, '/'); } elseif (substr($rule, -1) == '/') { - $rule = rtrim($rule, '/'); + $rule = rtrim($rule, '/'); $hasSlash = true; } } @@ -848,12 +848,12 @@ protected function buildRuleRegex(string $rule, array $match, array $pattern = [ protected function buildNameRegex(string $name, array $pattern, string $suffix): string { $optional = ''; - $slash = substr($name, 0, 1); + $slash = substr($name, 0, 1); if (in_array($slash, ['/', '-'])) { $prefix = $slash; - $name = substr($name, 1); - $slash = substr($name, 0, 1); + $name = substr($name, 1); + $slash = substr($name, 0, 1); } else { $prefix = ''; } @@ -863,7 +863,7 @@ protected function buildNameRegex(string $name, array $pattern, string $suffix): } if (strpos($name, '?')) { - $name = substr($name, 1, -2); + $name = substr($name, 1, -2); $optional = '?'; } elseif (strpos($name, '>')) { $name = substr($name, 1, -1); @@ -911,12 +911,12 @@ public function __wakeup() public function __debugInfo() { return [ - 'name' => $this->name, - 'rule' => $this->rule, - 'route' => $this->route, - 'method' => $this->method, - 'vars' => $this->vars, - 'option' => $this->option, + 'name' => $this->name, + 'rule' => $this->rule, + 'route' => $this->route, + 'method' => $this->method, + 'vars' => $this->vars, + 'option' => $this->option, 'pattern' => $this->pattern, ]; } diff --git a/src/think/route/RuleGroup.php b/src/think/route/RuleGroup.php index cd9ddbd1b4..d989ea4a28 100644 --- a/src/think/route/RuleGroup.php +++ b/src/think/route/RuleGroup.php @@ -65,8 +65,8 @@ public function __construct(Route $router, RuleGroup $parent = null, string $nam { $this->router = $router; $this->parent = $parent; - $this->rule = $rule; - $this->name = trim($name, '/'); + $this->rule = $rule; + $this->name = trim($name, '/'); $this->setFullName(); @@ -146,7 +146,7 @@ public function check(Request $request, string $url, bool $completeMatch = false // 获取当前路由规则 $method = strtolower($request->method()); - $rules = $this->getRules($method); + $rules = $this->getRules($method); $option = $this->getOption(); if (isset($option['complete_match'])) { @@ -274,8 +274,8 @@ public function parseGroupRule($rule): void */ protected function checkMergeRuleRegex(Request $request, array &$rules, string $url, bool $completeMatch) { - $depr = $this->router->config('pathinfo_depr'); - $url = $depr . str_replace('|', $depr, $url); + $depr = $this->router->config('pathinfo_depr'); + $url = $depr . str_replace('|', $depr, $url); $regex = []; $items = []; @@ -311,7 +311,7 @@ protected function checkMergeRuleRegex(Request $request, array &$rules, string $ if (preg_match_all('/[' . $slash . ']??/', $rule, $matches)) { unset($rules[$key]); $pattern = array_merge($this->getPattern(), $item->getPattern()); - $option = array_merge($this->getOption(), $item->getOption()); + $option = array_merge($this->getOption(), $item->getOption()); $regex[$key] = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $complete, '_THINK_' . $key); $items[$key] = $item; @@ -348,7 +348,7 @@ protected function checkMergeRuleRegex(Request $request, array &$rules, string $ } } - $rule = $items[$pos]->getRule(); + $rule = $items[$pos]->getRule(); $array = $this->router->getRule($rule); foreach ($array as $item) { diff --git a/src/think/route/RuleItem.php b/src/think/route/RuleItem.php index e4e3246898..222b8664ab 100644 --- a/src/think/route/RuleItem.php +++ b/src/think/route/RuleItem.php @@ -47,8 +47,8 @@ public function __construct(Route $router, RuleGroup $parent, string $name = nul { $this->router = $router; $this->parent = $parent; - $this->name = $name; - $this->route = $route; + $this->name = $name; + $this->route = $route; $this->method = $method; $this->setRule($rule); @@ -191,9 +191,9 @@ public function checkRule(Request $request, string $url, $match = null, bool $co } // 合并分组参数 - $option = $this->getOption(); + $option = $this->getOption(); $pattern = $this->getPattern(); - $url = $this->urlSuffixCheck($request, $url, $option); + $url = $this->urlSuffixCheck($request, $url, $option); if (is_null($match)) { $match = $this->checkMatch($url, $option, $pattern, $completeMatch); @@ -232,7 +232,7 @@ protected function urlSuffixCheck(Request $request, string $url, array $option = // 是否区分 / 地址访问 if (!empty($option['remove_slash']) && '/' != $this->rule) { $this->rule = rtrim($this->rule, '/'); - $url = rtrim($url, '|'); + $url = rtrim($url, '|'); } if (isset($option['ext'])) { @@ -265,8 +265,8 @@ private function checkMatch(string $url, array $option, array $pattern, bool $co return false; } - $var = []; - $url = $depr . str_replace('|', $depr, $url); + $var = []; + $url = $depr . str_replace('|', $depr, $url); $rule = $depr . str_replace('/', $depr, $this->rule); if ($depr == $rule && $depr != $url) { diff --git a/src/think/route/RuleName.php b/src/think/route/RuleName.php index 0684367cd9..f10f829834 100644 --- a/src/think/route/RuleName.php +++ b/src/think/route/RuleName.php @@ -131,7 +131,7 @@ public function getRuleList(): array $val = []; foreach (['method', 'rule', 'name', 'route', 'domain', 'pattern', 'option'] as $param) { - $call = 'get' . $param; + $call = 'get' . $param; $val[$param] = $item->$call(); } @@ -171,7 +171,7 @@ public function getName(string $name = null, string $domain = null, string $meth return $this->item; } - $name = strtolower($name); + $name = strtolower($name); $method = strtolower($method); $result = []; @@ -202,7 +202,7 @@ public function getName(string $name = null, string $domain = null, string $meth protected function getRuleItemInfo(RuleItem $item): array { return [ - 'rule' => $item->getRule(), + 'rule' => $item->getRule(), 'domain' => $item->getDomain(), 'method' => $item->getMethod(), 'suffix' => $item->getSuffix(), diff --git a/src/think/route/Url.php b/src/think/route/Url.php index 9e60fca304..0d02713e06 100644 --- a/src/think/route/Url.php +++ b/src/think/route/Url.php @@ -77,9 +77,9 @@ class Url public function __construct(Route $route, App $app, string $url = '', array $vars = []) { $this->route = $route; - $this->app = $app; - $this->url = $url; - $this->vars = $vars; + $this->app = $app; + $this->url = $url; + $this->vars = $vars; } /** @@ -155,12 +155,12 @@ protected function parseDomain(string &$url, $domain): string return ''; } - $request = $this->app->request; + $request = $this->app->request; $rootDomain = $request->rootDomain(); if (true === $domain) { // 自动判断域名 - $domain = $request->host(); + $domain = $request->host(); $domains = $this->route->getDomains(); if (!empty($domains)) { @@ -170,7 +170,7 @@ protected function parseDomain(string &$url, $domain): string foreach ($domains as $key => $rule) { $rule = is_array($rule) ? $rule[0] : $rule; if (is_string($rule) && false === strpos($key, '*') && 0 === strpos($url, $rule)) { - $url = ltrim($url, $rule); + $url = ltrim($url, $rule); $domain = $key; // 生成对应子域名 @@ -246,8 +246,8 @@ protected function parseUrl(string $url, &$domain): string } else { $controller = $request->controller(); - $path = explode('/', $url); - $action = array_pop($path); + $path = explode('/', $url); + $action = array_pop($path); $controller = empty($path) ? $controller : array_pop($path); $url = $controller . '/' . $action; @@ -272,7 +272,7 @@ protected function parseVar(string $rule): array $optional = false; if (strpos($name, '?')) { - $name = substr($name, 1, -2); + $name = substr($name, 1, -2); $optional = true; } else { $name = substr($name, 1, -1); @@ -302,10 +302,10 @@ protected function getRuleUrl(array $rule, array &$vars = [], $allowDomain = '') $port = $request->port(); foreach ($rule as $item) { - $url = $item['rule']; + $url = $item['rule']; $pattern = $this->parseVar($url); - $domain = $item['domain']; - $suffix = $item['suffix']; + $domain = $item['domain']; + $suffix = $item['suffix']; if ('-' == $domain) { $domain = is_string($allowDomain) ? $allowDomain : $request->host(true); @@ -328,17 +328,17 @@ protected function getRuleUrl(array $rule, array &$vars = [], $allowDomain = '') foreach ($pattern as $key => $val) { if (isset($vars[$key])) { - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? (string) $vars[$key] : urlencode((string) $vars[$key]), $url); + $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? (string) $vars[$key] : urlencode((string) $vars[$key]), $url); $keys[] = $key; - $url = str_replace(['/?', '-?'], ['/', '-'], $url); + $url = str_replace(['/?', '-?'], ['/', '-'], $url); $result = [rtrim($url, '?-'), $domain, $suffix]; } elseif (2 == $val) { - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); - $url = str_replace(['/?', '-?'], ['/', '-'], $url); + $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); + $url = str_replace(['/?', '-?'], ['/', '-'], $url); $result = [rtrim($url, '?-'), $domain, $suffix]; } else { $result = null; - $keys = []; + $keys = []; break; } } @@ -361,21 +361,21 @@ protected function getRuleUrl(array $rule, array &$vars = [], $allowDomain = '') public function build(): string { // 解析URL - $url = $this->url; - $suffix = $this->suffix; - $domain = $this->domain; + $url = $this->url; + $suffix = $this->suffix; + $domain = $this->domain; $request = $this->app->request; - $vars = $this->vars; + $vars = $this->vars; if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { // [name] 表示使用路由命名标识生成URL $name = substr($url, 1, $pos - 1); - $url = 'name' . substr($url, $pos + 1); + $url = 'name' . substr($url, $pos + 1); } if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { $info = parse_url($url); - $url = !empty($info['path']) ? $info['path'] : ''; + $url = !empty($info['path']) ? $info['path'] : ''; if (isset($info['fragment'])) { // 解析锚点 @@ -397,7 +397,7 @@ public function build(): string } if ($url) { - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); + $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); $checkDomain = $domain && is_string($domain) ? $domain : null; $rule = $this->route->getName($checkName, $checkDomain); @@ -435,7 +435,7 @@ public function build(): string foreach ($binds as $key => $val) { if (is_string($val) && 0 === strpos($url, $val) && substr_count($val, '/') > 1) { - $url = substr($url, strlen($val) + 1); + $url = substr($url, strlen($val) + 1); $domain = $key; break; } @@ -454,7 +454,7 @@ public function build(): string // 还原URL分隔符 $depr = $this->route->config('pathinfo_depr'); - $url = str_replace('/', $depr, $url); + $url = str_replace('/', $depr, $url); $file = $request->baseFile(); if ($file && 0 !== strpos($request->url(), $file)) { @@ -508,8 +508,8 @@ public function __toString() public function __debugInfo() { return [ - 'url' => $this->url, - 'vars' => $this->vars, + 'url' => $this->url, + 'vars' => $this->vars, 'suffix' => $this->suffix, 'domain' => $this->domain, ]; diff --git a/src/think/route/dispatch/Controller.php b/src/think/route/dispatch/Controller.php index f18512cb0b..79c843bbc7 100644 --- a/src/think/route/dispatch/Controller.php +++ b/src/think/route/dispatch/Controller.php @@ -52,7 +52,7 @@ public function init(App $app) $controller = strip_tags($result[0] ?: $this->rule->config('default_controller')); if (strpos($controller, '.')) { - $pos = strrpos($controller, '.'); + $pos = strrpos($controller, '.'); $this->controller = substr($controller, 0, $pos) . '.' . Str::studly(substr($controller, $pos + 1)); } else { $this->controller = Str::studly($controller); @@ -99,7 +99,7 @@ public function exec() $this->request->setAction($actionName); } catch (ReflectionException $e) { $reflect = new ReflectionMethod($instance, '__call'); - $vars = [$action, $vars]; + $vars = [$action, $vars]; $this->request->setAction($action); } } else { @@ -135,18 +135,18 @@ protected function registerControllerMiddleware($controller): void $reflectionProperty->setAccessible(true); $middlewares = $reflectionProperty->getValue($controller); - $action = $this->request->action(true); + $action = $this->request->action(true); foreach ($middlewares as $key => $val) { if (!is_int($key)) { $middleware = $key; - $options = $val; + $options = $val; } elseif (isset($val['middleware'])) { $middleware = $val['middleware']; - $options = $val['options'] ?? []; + $options = $val['options'] ?? []; } else { $middleware = $val; - $options = []; + $options = []; } if (isset($options['only']) && !in_array($action, $this->parseActions($options['only']))) { diff --git a/src/think/route/dispatch/Url.php b/src/think/route/dispatch/Url.php index 147f5cb75a..6daea4dd18 100644 --- a/src/think/route/dispatch/Url.php +++ b/src/think/route/dispatch/Url.php @@ -26,7 +26,7 @@ class Url extends Controller public function __construct(Request $request, Rule $rule, $dispatch) { $this->request = $request; - $this->rule = $rule; + $this->rule = $rule; // 解析默认的URL规则 $dispatch = $this->parseUrl($dispatch); @@ -64,7 +64,7 @@ protected function parseUrl(string $url): array // 解析操作 $action = !empty($path) ? array_shift($path) : null; - $var = []; + $var = []; // 解析额外参数 if ($path) { @@ -105,7 +105,7 @@ protected function hasDefinedRoute(array $route): bool // 检查地址是否被定义过路由 $name = strtolower(Str::studly($controller) . '/' . $action); - $host = $this->request->host(true); + $host = $this->request->host(true); $method = $this->request->method(); if ($this->rule->getRouter()->getName($name, $host, $method)) { diff --git a/src/think/session/Store.php b/src/think/session/Store.php index 49e1ba9099..4ff0837bd7 100644 --- a/src/think/session/Store.php +++ b/src/think/session/Store.php @@ -51,7 +51,7 @@ class Store public function __construct($name, SessionHandlerInterface $handler, array $serialize = null) { - $this->name = $name; + $this->name = $name; $this->handler = $handler; if (!empty($serialize)) { @@ -289,7 +289,7 @@ public function flash(string $name, $value): void */ public function reflash(): void { - $keys = $this->get('__flash__.__current__', []); + $keys = $this->get('__flash__.__current__', []); $values = array_unique(array_merge($this->get('__flash__.__next__', []), $keys)); $this->set('__flash__.__next__', $values); $this->set('__flash__.__current__', []); diff --git a/src/think/session/driver/Cache.php b/src/think/session/driver/Cache.php index 4fabc799ae..e9dab3f4f0 100644 --- a/src/think/session/driver/Cache.php +++ b/src/think/session/driver/Cache.php @@ -29,8 +29,8 @@ class Cache implements SessionHandlerInterface public function __construct(\think\Cache $cache, array $config = []) { $this->handler = $cache->store(Arr::get($config, 'store')); - $this->expire = Arr::get($config, 'expire', 1440); - $this->prefix = Arr::get($config, 'prefix', ''); + $this->expire = Arr::get($config, 'expire', 1440); + $this->prefix = Arr::get($config, 'prefix', ''); } public function read(string $sessionId): string diff --git a/src/think/session/driver/File.php b/src/think/session/driver/File.php index 788f3230e6..428ff316c6 100644 --- a/src/think/session/driver/File.php +++ b/src/think/session/driver/File.php @@ -26,12 +26,12 @@ class File implements SessionHandlerInterface { protected $config = [ - 'path' => '', - 'expire' => 1440, - 'prefix' => '', - 'data_compress' => false, + 'path' => '', + 'expire' => 1440, + 'prefix' => '', + 'data_compress' => false, 'gc_probability' => 1, - 'gc_divisor' => 100, + 'gc_divisor' => 100, ]; public function __construct(App $app, array $config = []) @@ -74,7 +74,7 @@ protected function init(): void public function gc(): void { $lifetime = $this->config['expire']; - $now = time(); + $now = time(); $files = $this->findFiles($this->config['path'], function (SplFileInfo $item) use ($lifetime, $now) { return $now - $lifetime > $item->getMTime(); @@ -124,7 +124,7 @@ protected function getFileName(string $name, bool $auto = false): string } $filename = $this->config['path'] . $name; - $dir = dirname($filename); + $dir = dirname($filename); if ($auto && !is_dir($dir)) { try { @@ -210,7 +210,7 @@ protected function readFile($path): string public function write(string $sessID, string $sessData): bool { $filename = $this->getFileName($sessID, true); - $data = $sessData; + $data = $sessData; if ($this->config['data_compress'] && function_exists('gzcompress')) { //数据压缩 diff --git a/src/think/view/driver/Php.php b/src/think/view/driver/Php.php index 9e6e54aa3e..ba9e7ec95c 100644 --- a/src/think/view/driver/Php.php +++ b/src/think/view/driver/Php.php @@ -29,20 +29,20 @@ class Php implements TemplateHandlerInterface // 模板引擎参数 protected $config = [ // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 - 'auto_rule' => 1, + 'auto_rule' => 1, // 视图目录名 'view_dir_name' => 'view', // 应用模板路径 - 'view_path' => '', + 'view_path' => '', // 模板文件后缀 - 'view_suffix' => 'php', + 'view_suffix' => 'php', // 模板文件名分隔符 - 'view_depr' => DIRECTORY_SEPARATOR, + 'view_depr' => DIRECTORY_SEPARATOR, ]; public function __construct(App $app, array $config = []) { - $this->app = $app; + $this->app = $app; $this->config = array_merge($this->config, (array) $config); } @@ -123,7 +123,7 @@ private function parseTemplate(string $template): string $path = $this->config['view_path']; } else { $appName = isset($app) ? $app : $this->app->http->getName(); - $view = $this->config['view_dir_name']; + $view = $this->config['view_dir_name']; if (is_dir($this->app->getAppPath() . $view)) { $path = isset($app) ? $this->app->getBasePath() . ($appName ? $appName . DIRECTORY_SEPARATOR : '') . $view . DIRECTORY_SEPARATOR : $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR; @@ -135,10 +135,10 @@ private function parseTemplate(string $template): string $depr = $this->config['view_depr']; if (0 !== strpos($template, '/')) { - $template = str_replace(['/', ':'], $depr, $template); + $template = str_replace(['/', ':'], $depr, $template); $controller = $request->controller(); if (strpos($controller, '.')) { - $pos = strrpos($controller, '.'); + $pos = strrpos($controller, '.'); $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); } else { $controller = Str::snake($controller); diff --git a/tests/AppTest.php b/tests/AppTest.php index 6b8601521a..2c62ce35a4 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -173,10 +173,10 @@ protected function prepareAppForInitialize(vfsStreamDirectory $root, $debug = tr public function testInitialize() { $root = vfsStream::setup('rootDir', null, [ - '.env' => '', - 'app' => [ - 'common.php' => '', - 'event.php' => '[],"listen"=>[],"subscribe"=>[]];', + '.env' => '', + 'app' => [ + 'common.php' => '', + 'event.php' => '[],"listen"=>[],"subscribe"=>[]];', 'provider.php' => ' [ diff --git a/tests/DbTest.php b/tests/DbTest.php index 3bd0c1e9dd..d2a94a47e9 100644 --- a/tests/DbTest.php +++ b/tests/DbTest.php @@ -20,11 +20,11 @@ protected function tearDown(): void public function testMake() { - $event = m::mock(Event::class); + $event = m::mock(Event::class); $config = m::mock(Config::class); - $log = m::mock(Log::class); - $cache = m::mock(Cache::class); - $store = m::mock(Driver::class); + $log = m::mock(Log::class); + $cache = m::mock(Cache::class); + $store = m::mock(Driver::class); $config->shouldReceive('get')->with('database.cache_store', null)->andReturn(null); $cache->shouldReceive('store')->with(null)->andReturn($store); diff --git a/tests/EnvTest.php b/tests/EnvTest.php index 9b3b615c26..93612d91bf 100644 --- a/tests/EnvTest.php +++ b/tests/EnvTest.php @@ -11,7 +11,7 @@ class EnvTest extends TestCase { public function testEnvFile() { - $root = vfsStream::setup(); + $root = vfsStream::setup(); $envFile = vfsStream::newFile('.env')->setContent("key1=value1\nkey2=value2"); $root->addChild($envFile); diff --git a/tests/FilesystemTest.php b/tests/FilesystemTest.php index df5ffe209c..fab242bb88 100644 --- a/tests/FilesystemTest.php +++ b/tests/FilesystemTest.php @@ -70,16 +70,16 @@ public function testDisk() public function testCache() { $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), + 'type' => 'local', + 'root' => $this->root->url(), 'cache' => true, ]); $this->assertInstanceOf(Local::class, $this->filesystem->disk()); $this->config->shouldReceive('get')->with('filesystem.disks.cache', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $this->root->url(), + 'type' => NullDriver::class, + 'root' => $this->root->url(), 'cache' => [ 'store' => 'flysystem', ], @@ -107,8 +107,8 @@ public function testPutFile() ]); $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $root->url(), + 'type' => NullDriver::class, + 'root' => $root->url(), 'cache' => true, ]); diff --git a/tests/HttpTest.php b/tests/HttpTest.php index c3e0abd33e..fcc0aa94a6 100644 --- a/tests/HttpTest.php +++ b/tests/HttpTest.php @@ -68,8 +68,8 @@ protected function prepareApp($request, $response) public function testRun() { $root = vfsStream::setup('rootDir', null, [ - 'app' => [ - 'controller' => [], + 'app' => [ + 'controller' => [], 'middleware.php' => ' [ @@ -80,7 +80,7 @@ public function testRun() $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); - $request = m::mock(Request::class)->makePartial(); + $request = m::mock(Request::class)->makePartial(); $response = m::mock(Response::class)->makePartial(); $this->prepareApp($request, $response); @@ -119,7 +119,7 @@ public function multiAppRunProvider() public function testRunWithException() { - $request = m::mock(Request::class); + $request = m::mock(Request::class); $response = m::mock(Response::class); $this->app->shouldReceive('instance')->once()->with('request', $request); @@ -142,7 +142,7 @@ public function testRunWithException() public function testEnd() { $response = m::mock(Response::class); - $event = m::mock(Event::class); + $event = m::mock(Event::class); $event->shouldReceive('trigger')->once()->with(HttpEnd::class, $response); $this->app->shouldReceive('get')->once()->with('event')->andReturn($event); $log = m::mock(Log::class); diff --git a/tests/MiddlewareTest.php b/tests/MiddlewareTest.php index aa53059c08..1022523fe3 100644 --- a/tests/MiddlewareTest.php +++ b/tests/MiddlewareTest.php @@ -63,7 +63,7 @@ public function testPipelineAndEnd() $bar = m::mock("overload:BarMiddleware"); $foo = m::mock("overload:FooMiddleware", Foo::class); - $request = m::mock(Request::class); + $request = m::mock(Request::class); $response = m::mock(Response::class); $e = new Exception(); diff --git a/tests/RouteTest.php b/tests/RouteTest.php index 6a7f8ee245..948eecb352 100644 --- a/tests/RouteTest.php +++ b/tests/RouteTest.php @@ -62,12 +62,12 @@ public function testSimpleRequest() }); }); - $request = $this->makeRequest('foo', 'post'); + $request = $this->makeRequest('foo', 'post'); $response = $this->route->dispatch($request); $this->assertEquals(200, $response->getCode()); $this->assertEquals('post-foo', $response->getContent()); - $request = $this->makeRequest('foo', 'get'); + $request = $this->makeRequest('foo', 'get'); $response = $this->route->dispatch($request); $this->assertEquals(200, $response->getCode()); $this->assertEquals('get-foo', $response->getContent()); @@ -100,22 +100,22 @@ public function testOptionsRequest() $this->route->resource('bar', 'SomeClass'); - $request = $this->makeRequest('foo', 'options'); + $request = $this->makeRequest('foo', 'options'); $response = $this->route->dispatch($request); $this->assertEquals(204, $response->getCode()); $this->assertEquals('GET, PUT, POST', $response->getHeader('Allow')); - $request = $this->makeRequest('bar', 'options'); + $request = $this->makeRequest('bar', 'options'); $response = $this->route->dispatch($request); $this->assertEquals(204, $response->getCode()); $this->assertEquals('GET, POST', $response->getHeader('Allow')); - $request = $this->makeRequest('bar/1', 'options'); + $request = $this->makeRequest('bar/1', 'options'); $response = $this->route->dispatch($request); $this->assertEquals(204, $response->getCode()); $this->assertEquals('GET, PUT, DELETE', $response->getHeader('Allow')); - $request = $this->makeRequest('xxxx', 'options'); + $request = $this->makeRequest('xxxx', 'options'); $response = $this->route->dispatch($request); $this->assertEquals(204, $response->getCode()); $this->assertEquals('GET, POST, PUT, DELETE', $response->getHeader('Allow')); @@ -127,13 +127,13 @@ public function testAllowCrossDomain() return 'get-foo'; })->allowCrossDomain(['some' => 'bar']); - $request = $this->makeRequest('foo', 'get'); + $request = $this->makeRequest('foo', 'get'); $response = $this->route->dispatch($request); $this->assertEquals('bar', $response->getHeader('some')); $this->assertArrayHasKey('Access-Control-Allow-Credentials', $response->getHeader()); - $request = $this->makeRequest('foo2', 'options'); + $request = $this->makeRequest('foo2', 'options'); $response = $this->route->dispatch($request); $this->assertEquals(204, $response->getCode()); @@ -152,7 +152,7 @@ public function testControllerDispatch() $controller->shouldReceive('bar')->andReturn('bar'); - $request = $this->makeRequest('foo'); + $request = $this->makeRequest('foo'); $response = $this->route->dispatch($request); $this->assertEquals('bar', $response->getContent()); } @@ -168,7 +168,7 @@ public function testEmptyControllerDispatch() $controller->shouldReceive('bar')->andReturn('bar'); - $request = $this->makeRequest('foo'); + $request = $this->makeRequest('foo'); $response = $this->route->dispatch($request); $this->assertEquals('bar', $response->getContent()); } @@ -193,10 +193,10 @@ public function testControllerWithMiddleware() $controller->middleware = [ $this->createMiddleware()->mockery_getName() . ":params1:params2", $this->createMiddleware(0)->mockery_getName() => ['except' => 'bar'], - $this->createMiddleware()->mockery_getName() => ['only' => 'bar'], + $this->createMiddleware()->mockery_getName() => ['only' => 'bar'], [ 'middleware' => [$this->createMiddleware()->mockery_getName(), [new \stdClass()]], - 'options' => ['only' => 'bar'], + 'options' => ['only' => 'bar'], ], ]; @@ -205,7 +205,7 @@ public function testControllerWithMiddleware() $controller->shouldReceive('bar')->once()->andReturn('bar'); - $request = $this->makeRequest('foo'); + $request = $this->makeRequest('foo'); $response = $this->route->dispatch($request); $this->assertEquals('bar', $response->getContent()); } @@ -219,7 +219,7 @@ public function testUrlDispatch() ->andReturn($controller->mockery_getName()); $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); - $request = $this->makeRequest('foo'); + $request = $this->makeRequest('foo'); $response = $this->route->dispatch($request); $this->assertEquals('bar', $response->getContent()); } @@ -241,7 +241,7 @@ public function testViewDispatch() { $this->route->view('foo', 'index/hello', ['city' => 'shanghai']); - $request = $this->makeRequest('foo'); + $request = $this->makeRequest('foo'); $response = $this->route->dispatch($request); $this->assertInstanceOf(View::class, $response); @@ -256,7 +256,7 @@ public function testResponseDispatch() ->code(200) ->contentType('text/plain')); - $request = $this->makeRequest('hello/some'); + $request = $this->makeRequest('hello/some'); $response = $this->route->dispatch($request); $this->assertEquals('Hello,ThinkPHP', $response->getContent()); @@ -271,7 +271,7 @@ public function testDomainBindResponse() }); }); - $request = $this->makeRequest('', 'get', 'test.domain.com'); + $request = $this->makeRequest('', 'get', 'test.domain.com'); $response = $this->route->dispatch($request); $this->assertEquals('Hello,ThinkPHP', $response->getContent()); diff --git a/tests/SessionTest.php b/tests/SessionTest.php index b3b48a70da..b8ff940da4 100644 --- a/tests/SessionTest.php +++ b/tests/SessionTest.php @@ -173,9 +173,9 @@ public function testFileHandler() $this->assertTrue($root->hasChild("foo/bar")); $handler = new TestFileHandle($this->app, [ - 'path' => $root->url(), + 'path' => $root->url(), 'gc_probability' => 1, - 'gc_divisor' => 1, + 'gc_divisor' => 1, ]); $this->assertTrue($root->hasChild("bar"));