diff --git a/library/think/Config.php b/library/think/Config.php index ed1f1e7b..774a58a4 100644 --- a/library/think/Config.php +++ b/library/think/Config.php @@ -177,7 +177,11 @@ class Config */ public static function reset($range = '') { - $range = $range ?: self::$range; - true === $range ? self::$config = [] : self::$config[$range] = []; + $range = $range ?: self::$range; + if (true === $range) { + self::$config = []; + } else { + self::$config[$range] = []; + } } } diff --git a/library/think/config/driver/Json.php b/library/think/config/driver/Json.php new file mode 100644 index 00000000..ec2419f9 --- /dev/null +++ b/library/think/config/driver/Json.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +namespace think\config\driver; + +class Json +{ + public function parse($config) + { + if (is_file($config)) { + $config = file_get_contents($config); + } + $result = json_decode($config, true); + return $result; + } +} diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index cf926f63..e9d22eff 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -13,6 +13,8 @@ namespace think\db; use PDO; use think\Db; +use think\db\Connection; +use think\db\Query; use think\Exception; abstract class Builder @@ -38,9 +40,9 @@ abstract class Builder /** * 架构函数 * @access public - * @param \think\db\Connection $connection 数据库连接对象实例 + * @param Connection $connection 数据库连接对象实例 */ - public function __construct($connection) + public function __construct(Connection $connection) { $this->connection = $connection; } @@ -48,10 +50,10 @@ abstract class Builder /** * 设置当前的Query对象实例 * @access protected - * @param \think\db\Query $query 当前查询对象实例 + * @param Query $query 当前查询对象实例 * @return void */ - public function setQuery($query) + public function setQuery(Query $query) { $this->query = $query; } diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index b3680d0a..ddcfbe4b 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -15,6 +15,7 @@ use PDO; use PDOStatement; use think\Collection; use think\Db; +use think\db\Query; use think\Debug; use think\Exception; use think\exception\DbBindParamException; @@ -128,7 +129,7 @@ abstract class Connection * 创建指定模型的查询对象 * @access public * @param string $model 模型类名称 - * @return \think\db\Query + * @return Query */ public function model($model) { diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index ac88e6a0..03e2a04d 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -45,9 +45,9 @@ class Relation /** * 架构函数 * @access public - * @param \think\Model $model 上级模型对象 + * @param Model $model 上级模型对象 */ - public function __construct($model) + public function __construct(Model $model) { $this->parent = $model; }