From a9cb0a91612896c88753ce5c2c5636c692667321 Mon Sep 17 00:00:00 2001 From: topnuomi <1130395124@qq.com> Date: Thu, 18 Jul 2024 15:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/library/Annotation.php | 32 ++++++------ framework/library/Application.php | 2 +- framework/library/Config.php | 2 +- framework/library/Controller.php | 20 ++++---- framework/library/Database.php | 60 +++++++++++------------ framework/library/Loader.php | 10 ++-- framework/library/Model.php | 42 ++++++++-------- framework/library/Register.php | 2 +- framework/library/Template.php | 12 ++--- framework/library/View.php | 8 +-- framework/library/template/driver/Top.php | 15 +++--- framework/traits/Magic.php | 2 +- 12 files changed, 105 insertions(+), 102 deletions(-) diff --git a/framework/library/Annotation.php b/framework/library/Annotation.php index 9e18a87..9d851e4 100644 --- a/framework/library/Annotation.php +++ b/framework/library/Annotation.php @@ -22,39 +22,41 @@ class Annotation /** * 获取方法注解 - * @param $className - * @param $methodName - * @param null $annotation - * @return array + * @param object|string $className + * @param string $methodName + * @param string $annotation + * @return array|string */ - public static function getMethodAnnotation($className, $methodName, $annotation = null) + public static function getMethodAnnotation($className, $methodName, $annotation = '') { return self::getAnnotation($className, $methodName, $annotation); } /** * 获取类注解 - * @param $className - * @param null $annotation - * @return array + * @param object|string $className + * @param string $annotation + * @return array|string */ - public static function getClassAnnotation($className, $annotation = null) + public static function getClassAnnotation($className, $annotation = '') { return self::getAnnotation($className, null, $annotation); } /** * 获取注解 - * @param $className - * @param null $methodName - * @param null $annotation - * @return mixed + * @param object|string $className + * @param string $methodName + * @param string $annotation + * @return array|string */ - private static function getAnnotation($className, $methodName = null, $annotation = null) + private static function getAnnotation($className, $methodName = '', $annotation = '') { + if (is_object($className)) { + $className = get_class($className); + } $ident = md5($className . $methodName); if (!isset(self::$annotations[$ident])) { - // echo '获取' . $className . '::' . $methodName . PHP_EOL; $self = self::instance(); $reflectionClass = Application::getReflectionClass($className); if ($methodName) { diff --git a/framework/library/Application.php b/framework/library/Application.php index 95a6c93..fa5cfb0 100644 --- a/framework/library/Application.php +++ b/framework/library/Application.php @@ -94,7 +94,7 @@ class Application /** * 获取一个类反射 - * @param $className + * @param object|string $className * @return mixed */ public static function getReflectionClass($className) diff --git a/framework/library/Config.php b/framework/library/Config.php index 6b1ade5..e4f5624 100644 --- a/framework/library/Config.php +++ b/framework/library/Config.php @@ -50,7 +50,7 @@ class Config * @param string $name * @return array|mixed */ - public function get($name = '') + public function get($name) { // 加载用户配置文件 $file = CONFIG_DIR . 'config.php'; diff --git a/framework/library/Controller.php b/framework/library/Controller.php index 021c278..a7a0e18 100644 --- a/framework/library/Controller.php +++ b/framework/library/Controller.php @@ -27,25 +27,25 @@ abstract class Controller * URI * @var string */ - protected $uri = null; + protected $uri = ''; /** * 控制器 * @var string */ - protected $controller = null; + protected $controller = ''; /** * 控制器全限定名 * @var string */ - protected $controllerFullName = null; + protected $controllerFullName = ''; /** * 方法 * @var string */ - protected $method = null; + protected $method = ''; /** * 控制器基类构造方法 @@ -62,10 +62,10 @@ abstract class Controller /** * 输出JSON数据 - * @param $msg + * @param string $msg * @param int $code * @param array $data - * @return mixed + * @return false|string */ protected function json($msg, $code = 1, $data = []) { @@ -85,8 +85,8 @@ abstract class Controller /** * 赋值到视图 - * @param $name - * @param $value + * @param string $name + * @param mixed $value */ protected function param($name, $value) { @@ -107,7 +107,7 @@ abstract class Controller /** * 跳转 - * @param $url + * @param string $url */ protected function redirect($url) { @@ -116,7 +116,7 @@ abstract class Controller /** * 显示提示页面 - * @param $message + * @param string $message * @param string $url * @param int $sec * @return false|mixed|string diff --git a/framework/library/Database.php b/framework/library/Database.php index 1f00107..82a24c9 100644 --- a/framework/library/Database.php +++ b/framework/library/Database.php @@ -44,21 +44,21 @@ class Database /** * 别名 - * @var null + * @var string */ - private $alias = null; + private $alias = ''; /** * 数据去重 - * @var null + * @var bool */ private $distinct = false; /** * 操作的字段 - * @var null + * @var array|string */ - private $field = null; + private $field = ''; /** * 条件 @@ -68,15 +68,15 @@ class Database /** * 排序 - * @var null + * @var string */ - private $order = null; + private $order = ''; /** * 范围 - * @var null + * @var string */ - private $limit = null; + private $limit = ''; /** * 多表 @@ -86,9 +86,9 @@ class Database /** * Database constructor. - * @param $table - * @param $pk - * @param $prefix + * @param string $table + * @param string $pk + * @param string $prefix * @throws DatabaseException */ private function __construct($table, $pk, $prefix) @@ -112,8 +112,8 @@ class Database /** * 获取表名 - * @param $prefix - * @param $table + * @param string $prefix + * @param string $table * @return string */ private function getTableName($prefix, $table) @@ -131,7 +131,7 @@ class Database /** * 指定表 - * @param $table + * @param string $table * @param string $pk * @param string $prefix * @return $this @@ -147,7 +147,7 @@ class Database /** * 设置表别名 - * @param $name + * @param string $name * @return \top\library\Database */ public function alias($name) @@ -157,7 +157,7 @@ class Database } /** - * @param $flag + * @param bool $flag * @return \top\library\Database */ public function distinct($flag = true) @@ -168,7 +168,7 @@ class Database /** * 设置操作字段 - * @param $field + * @param array|string $field * @return \top\library\Database */ public function field($field) @@ -244,8 +244,8 @@ class Database /** * 多表 * - * @param $table - * @param $on + * @param string $table + * @param string $on * @param string $type * @return \top\library\Database */ @@ -279,7 +279,7 @@ class Database /** * 查询一条记录 - * @param bool $param + * @param mixed $param * @return mixed */ public function find($param = false) @@ -306,7 +306,7 @@ class Database /** * 查询所有记录 * - * @param callable|string|bool $param + * @param mixed $param * @return array|boolean */ public function select($param = false) @@ -337,7 +337,7 @@ class Database * 更新记录 * * @param array $data - * @param callable|string|bool $param + * @param mixed $param * @return int|boolean */ public function update($data, $param = false) @@ -364,7 +364,7 @@ class Database /** * 删除记录 * - * @param callable|string|bool $param + * @param mixed $param * @return int|boolean */ public function delete($param = false) @@ -391,8 +391,8 @@ class Database /** * 公共方法 (sum、avg等等使用函数包裹字段的方法) * - * @param $param - * @param $type + * @param mixed $param + * @param string $type * @return mixed */ public function common($param, $type) @@ -416,7 +416,7 @@ class Database /** * 执行一条SQL - * @param $query + * @param string $query * @param array $params * @return bool|\PDOStatement */ @@ -474,11 +474,11 @@ class Database private function _reset() { $this->distinct = false; - $this->field = null; + $this->field = ''; $this->join = []; $this->where = []; - $this->order = null; - $this->limit = null; + $this->order = ''; + $this->limit = ''; } /** diff --git a/framework/library/Loader.php b/framework/library/Loader.php index 772a746..026a2d9 100644 --- a/framework/library/Loader.php +++ b/framework/library/Loader.php @@ -19,8 +19,8 @@ class Loader /** * 添加命名空间映射 - * @param $name - * @param $path + * @param string $name + * @param string $path */ public function set($name, $path) { @@ -33,7 +33,7 @@ class Loader /** * 尝试根据前缀和类名加载文件 - * @param $class + * @param string $class * @return bool */ private function loadClass($class) @@ -59,8 +59,8 @@ class Loader /** * 加载文件 - * @param $prefix - * @param $class + * @param string $prefix + * @param string $class * @return bool */ private function loadFile($prefix, $class) diff --git a/framework/library/Model.php b/framework/library/Model.php index 5bff797..0c81d60 100644 --- a/framework/library/Model.php +++ b/framework/library/Model.php @@ -124,7 +124,7 @@ class Model /** * 过滤重复值 - * @param $flag + * @param bool $flag * @return $this */ private function _distinct($flag = true) @@ -135,7 +135,7 @@ class Model /** * 指定字段 - * @param $field + * @param array|string $field * @return $this */ private function _field($field) @@ -185,8 +185,8 @@ class Model /** * 多表 - * @param $table - * @param $on + * @param string $table + * @param string $on * @param string $type * @return $this */ @@ -228,8 +228,8 @@ class Model /** * 删除记录 - * @param string|bool $param - * @return number|boolean + * @param mixed $param + * @return int|bool */ public function delete($param = false) { @@ -238,8 +238,8 @@ class Model /** * 更新记录 - * @param $data - * @param string|bool $param + * @param array $data + * @param mixed $param * @return bool */ public function update($data, $param = false) @@ -291,7 +291,7 @@ class Model /** * 计数 - * @param null $param + * @param mixed $param * @return mixed */ public function count($param = null) @@ -301,7 +301,7 @@ class Model /** * 平均值 - * @param null $param + * @param mixed $param * @return mixed */ public function avg($param = null) @@ -311,7 +311,7 @@ class Model /** * 最大值 - * @param null $param + * @param mixed $param * @return mixed */ public function max($param = null) @@ -321,7 +321,7 @@ class Model /** * 最小值 - * @param null $param + * @param mixed $param * @return mixed */ public function min($param = null) @@ -331,7 +331,7 @@ class Model /** * 求和 - * @param null $param + * @param mixed $param * @return mixed */ public function sum($param = null) @@ -341,7 +341,7 @@ class Model /** * 执行一条SQL - * @param $query + * @param string $query * @param array $params * @return mixed */ @@ -352,7 +352,7 @@ class Model /** * MySQL事务 - * @param $action + * @param callable $action * @return bool */ public function transaction($action) @@ -416,7 +416,7 @@ class Model /** * 入库前进行数据处理 - * @param $data + * @param mixed $data * @return array|bool */ private function processData($data) @@ -507,8 +507,8 @@ class Model /** * 调用函数、方法替换值 - * @param $value - * @param $function + * @param string $value + * @param mixed $function * @return mixed */ private function callOutReplaceFunction($value, $function) @@ -528,7 +528,7 @@ class Model /** * 验证表单 - * @param $data + * @param array $data * @return bool */ private function validate($data) @@ -556,8 +556,8 @@ class Model /** * 调用对应验证函数(如果update时不想验证数据,请在之前unset掉对应键值) * @param string $key - * @param $validate - * @param $data + * @param array $validate + * @param array $data * @return bool */ private function validateCallUserFunction($key, $validate, $data) diff --git a/framework/library/Register.php b/framework/library/Register.php index 7a88fc1..8db7343 100644 --- a/framework/library/Register.php +++ b/framework/library/Register.php @@ -38,7 +38,7 @@ class Register /** * 获取类实例 - * @param $name + * @param string $name * @param array $param * @return mixed * @throws \Exception diff --git a/framework/library/Template.php b/framework/library/Template.php index a127375..9631851 100644 --- a/framework/library/Template.php +++ b/framework/library/Template.php @@ -36,7 +36,7 @@ class Template /** * 是否开启页面静态缓存 - * @param $status + * @param bool $status */ public function cache($status) { @@ -45,8 +45,8 @@ class Template /** * 传递参数 - * @param $name - * @param $value + * @param string $name + * @param mixed $value */ public function param($name, $value) { @@ -55,9 +55,9 @@ class Template /** * 获取视图 - * @param $file - * @param $param - * @param $cache + * @param string $file + * @param array $param + * @param int|bool $cache * @return mixed */ public function fetch($file, $param, $cache) diff --git a/framework/library/View.php b/framework/library/View.php index 1c19d8f..1f0ea62 100644 --- a/framework/library/View.php +++ b/framework/library/View.php @@ -28,15 +28,15 @@ class View $this->config = config('view'); $className = '\\top\\library\\template\\driver\\' . $this->config['engine']; if (!class_exists($className)) { - throw new Exception('不存在的模板引擎:' . $className); + throw new \Exception('不存在的模板引擎:' . $className); } $this->template = Template::instance($className::instance()); } /** * 传递参数 - * @param $name - * @param $value + * @param string $name + * @param mixed $value */ public function param($name, $value) { @@ -56,7 +56,7 @@ class View * 获取视图 * @param string $file * @param array $param - * @param bool $cache + * @param int|bool $cache * @return mixed * @throws \Exception */ diff --git a/framework/library/template/driver/Top.php b/framework/library/template/driver/Top.php index 1287163..27721a1 100644 --- a/framework/library/template/driver/Top.php +++ b/framework/library/template/driver/Top.php @@ -36,7 +36,7 @@ class Top implements TemplateIfs /** * 编译文件 - * @param $filename + * @param string $filename * @return string */ private function compile($filename) @@ -59,7 +59,7 @@ class Top implements TemplateIfs /** * 是否开启缓存或设置缓存时间 - * @param $status + * @param bool $status */ public function cache($status) { @@ -68,8 +68,9 @@ class Top implements TemplateIfs /** * 缓存文件 - * @param $filename - * @param $params + * @param string $filename + * @param array $params + * @param int $cacheTime * @return string * @throws \Exception */ @@ -93,9 +94,9 @@ class Top implements TemplateIfs /** * 渲染文件并返回内容 - * @param $file - * @param $params - * @param $cache + * @param string $file + * @param array $params + * @param int|bool $cache * @return bool|false|mixed|string * @throws \Exception */ diff --git a/framework/traits/Magic.php b/framework/traits/Magic.php index 8269b8d..eafe014 100644 --- a/framework/traits/Magic.php +++ b/framework/traits/Magic.php @@ -8,7 +8,7 @@ trait Magic /** * 使用成员变量调用某些类 - * @param $name + * @param string $name * @return mixed */ public function __get($name)