提交 02f36421 编写于 作者: G gongfuxiang

类库更新

上级 921d28f9
......@@ -9,7 +9,7 @@ return array(
'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'),
'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/framework/src/think'),
'app\\' => array($baseDir . '/app'),
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
......
......@@ -81,10 +81,10 @@ class ComposerStaticInit1ed187777399b73a018d9a6af63a57d1
),
'think\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
1 => __DIR__ . '/..' . '/topthink/think-template/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src',
3 => __DIR__ . '/..' . '/topthink/framework/src/think',
),
'app\\' =>
array (
......
......@@ -1441,17 +1441,17 @@
},
{
"name": "topthink/framework",
"version": "v6.0.11",
"version_normalized": "6.0.11.0",
"version": "v6.0.12",
"version_normalized": "6.0.12.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb"
"reference": "e478316ac843c1a884a3b3a7a94db17c4001ff5c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb",
"reference": "d9cadb6971ae92ff85ba5f2be77a40b0ad5718fb",
"url": "https://api.github.com/repos/top-think/framework/zipball/e478316ac843c1a884a3b3a7a94db17c4001ff5c",
"reference": "e478316ac843c1a884a3b3a7a94db17c4001ff5c",
"shasum": "",
"mirrors": [
{
......@@ -1479,7 +1479,7 @@
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.0"
},
"time": "2021-12-31T09:14:28+00:00",
"time": "2022-01-21T06:31:07+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -1511,7 +1511,7 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v6.0.11"
"source": "https://github.com/top-think/framework/tree/v6.0.12"
},
"install-path": "../topthink/framework"
},
......@@ -1623,17 +1623,17 @@
},
{
"name": "topthink/think-orm",
"version": "v2.0.50",
"version_normalized": "2.0.50.0",
"version": "v2.0.51",
"version_normalized": "2.0.51.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/think-orm.git",
"reference": "091ad5e023c15fcce4ceaea2f3814bdf71045cde"
"reference": "149d266acdc4b2f07c6a94f1733b6b97d340e0e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/091ad5e023c15fcce4ceaea2f3814bdf71045cde",
"reference": "091ad5e023c15fcce4ceaea2f3814bdf71045cde",
"url": "https://api.github.com/repos/top-think/think-orm/zipball/149d266acdc4b2f07c6a94f1733b6b97d340e0e2",
"reference": "149d266acdc4b2f07c6a94f1733b6b97d340e0e2",
"shasum": "",
"mirrors": [
{
......@@ -1653,7 +1653,7 @@
"require-dev": {
"phpunit/phpunit": "^7|^8|^9.5"
},
"time": "2022-01-06T02:48:16+00:00",
"time": "2022-01-21T06:25:25+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -1681,7 +1681,7 @@
],
"support": {
"issues": "https://github.com/top-think/think-orm/issues",
"source": "https://github.com/top-think/think-orm/tree/v2.0.50"
"source": "https://github.com/top-think/think-orm/tree/v2.0.51"
},
"install-path": "../topthink/think-orm"
},
......
......@@ -5,7 +5,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '5979814ba42ca1796f517662de1e19f6736a1182',
'reference' => '921d28f9ce7fcc47b9b8312f92080643eddfe75a',
'name' => 'shopxo/shopxo',
'dev' => true,
),
......@@ -160,7 +160,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '5979814ba42ca1796f517662de1e19f6736a1182',
'reference' => '921d28f9ce7fcc47b9b8312f92080643eddfe75a',
'dev_requirement' => false,
),
'symfony/polyfill-mbstring' => array(
......@@ -200,12 +200,12 @@
'dev_requirement' => true,
),
'topthink/framework' => array(
'pretty_version' => 'v6.0.11',
'version' => '6.0.11.0',
'pretty_version' => 'v6.0.12',
'version' => '6.0.12.0',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/framework',
'aliases' => array(),
'reference' => 'd9cadb6971ae92ff85ba5f2be77a40b0ad5718fb',
'reference' => 'e478316ac843c1a884a3b3a7a94db17c4001ff5c',
'dev_requirement' => false,
),
'topthink/think-helper' => array(
......@@ -227,12 +227,12 @@
'dev_requirement' => false,
),
'topthink/think-orm' => array(
'pretty_version' => 'v2.0.50',
'version' => '2.0.50.0',
'pretty_version' => 'v2.0.51',
'version' => '2.0.51.0',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/think-orm',
'aliases' => array(),
'reference' => '091ad5e023c15fcce4ceaea2f3814bdf71045cde',
'reference' => '149d266acdc4b2f07c6a94f1733b6b97d340e0e2',
'dev_requirement' => false,
),
'topthink/think-template' => array(
......
<?php
// This file is automatically generated at:2022-01-10 18:17:36
// This file is automatically generated at:2022-01-24 15:08:07
declare (strict_types = 1);
return array (
0 => 'think\\app\\Service',
......
......@@ -39,7 +39,7 @@ use think\initializer\RegisterService;
*/
class App extends Container
{
const VERSION = '6.0.10LTS';
const VERSION = '6.0.12LTS';
/**
* 应用调试模式
......
......@@ -188,7 +188,7 @@ class Env implements ArrayAccess
}
#[\ReturnTypeWillChange]
public function offsetUnset($name)
public function offsetUnset($name): void
{
throw new Exception('not support: unset');
}
......
......@@ -249,7 +249,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface
* @param string $data 缓存数据
* @return mixed
*/
protected function unserialize(string $data)
protected function unserialize($data)
{
if (is_numeric($data)) {
return $data;
......
......@@ -18,7 +18,7 @@ namespace think\console\input;
class Option
{
// 无需传值
const VALUE_NONE = 1;
const VALUE_NONE = 1;
// 必须传值
const VALUE_REQUIRED = 2;
// 可选传值
......@@ -30,13 +30,13 @@ class Option
* 选项名
* @var string
*/
private $name;
private $name = '';
/**
* 选项短名称
* @var string
*/
private $shortcut;
private $shortcut = '';
/**
* 选项类型
......@@ -54,7 +54,7 @@ class Option
* 选项描述
* @var string
*/
private $description;
private $description = '';
/**
* 构造方法
......@@ -76,10 +76,10 @@ class Option
}
if (empty($shortcut)) {
$shortcut = null;
$shortcut = '';
}
if (null !== $shortcut) {
if ('' !== $shortcut) {
if (is_array($shortcut)) {
$shortcut = implode('|', $shortcut);
}
......@@ -114,7 +114,7 @@ class Option
* 获取短名称
* @return string
*/
public function getShortcut()
public function getShortcut(): string
{
return $this->shortcut;
}
......@@ -123,7 +123,7 @@ class Option
* 获取选项名
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
......@@ -132,7 +132,7 @@ class Option
* 是否可以设置值
* @return bool 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false
*/
public function acceptValue()
public function acceptValue(): bool
{
return $this->isValueRequired() || $this->isValueOptional();
}
......@@ -141,7 +141,7 @@ class Option
* 是否必须
* @return bool 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false
*/
public function isValueRequired()
public function isValueRequired(): bool
{
return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
}
......@@ -150,7 +150,7 @@ class Option
* 是否可选
* @return bool 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false
*/
public function isValueOptional()
public function isValueOptional(): bool
{
return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
}
......@@ -159,7 +159,7 @@ class Option
* 选项值是否接受数组
* @return bool 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false
*/
public function isArray()
public function isArray(): bool
{
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
}
......@@ -199,7 +199,7 @@ class Option
* 获取描述文字
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
......@@ -209,7 +209,7 @@ class Option
* @param Option $option
* @return bool
*/
public function equals(Option $option)
public function equals(Option $option): bool
{
return $option->getName() === $this->getName()
&& $option->getShortcut() === $this->getShortcut()
......
......@@ -213,7 +213,7 @@ class Resource extends RuleGroup
}
/**
* 绑定资源模型
* 绑定资源中间件
* @access public
* @param array|string $name 资源类型或者中间件定义
* @param array|string $middleware 中间件定义
......
......@@ -532,6 +532,17 @@ abstract class Rule
return $this->setOption('view', $view);
}
/**
* 通过闭包检查路由是否匹配
* @access public
* @param callable $match 闭包
* @return $this
*/
public function match(callable $match)
{
return $this->setOption('match', $match);
}
/**
* 设置路由完整匹配
* @access public
......@@ -694,6 +705,13 @@ abstract class Rule
*/
protected function checkOption(array $option, Request $request): bool
{
// 检查当前路由是否匹配
if (isset($option['match']) && is_callable($option['match'])) {
if (false === $option['match']($this, $request)) {
return false;
}
}
// 请求类型检测
if (!empty($option['method'])) {
if (is_string($option['method']) && false === stripos($option['method'], $request->method())) {
......
......@@ -196,7 +196,7 @@ class RuleItem extends Rule
$url = $this->urlSuffixCheck($request, $url, $option);
if (is_null($match)) {
$match = $this->match($url, $option, $pattern, $completeMatch);
$match = $this->checkMatch($url, $option, $pattern, $completeMatch);
}
if (false !== $match) {
......@@ -252,7 +252,7 @@ class RuleItem extends Rule
* @param bool $completeMatch 是否完全匹配
* @return array|false
*/
private function match(string $url, array $option, array $pattern, bool $completeMatch)
private function checkMatch(string $url, array $option, array $pattern, bool $completeMatch)
{
if (isset($option['complete_match'])) {
$completeMatch = $option['complete_match'];
......
......@@ -421,10 +421,8 @@ class Fetch
if (!empty($options['group'])) {
// 支持GROUP
$bind = $this->query->getBind();
$subSql = $this->query->options($options)->field('count(' . $field . ') AS think_count')->bind($bind)->buildSql();
$query = $this->query->newQuery()->table([$subSql => '_group_count_']);
$subSql = $this->query->field('count(' . $field . ') AS think_count')->buildSql();
$query = $this->query->newQuery()->table([$subSql => '_group_count_']);
return $query->fetchsql()->aggregate('COUNT', '*');
} else {
......
......@@ -24,8 +24,8 @@ class Sqlite extends Builder
/**
* limit
* @access public
* @param Query $query 查询对象
* @param mixed $limit
* @param Query $query 查询对象
* @param mixed $limit
* @return string
*/
public function parseLimit(Query $query, string $limit): string
......@@ -47,7 +47,7 @@ class Sqlite extends Builder
/**
* 随机排序
* @access protected
* @param Query $query 查询对象
* @param Query $query 查询对象
* @return string
*/
protected function parseRand(Query $query): string
......@@ -58,9 +58,9 @@ class Sqlite extends Builder
/**
* 字段和表名处理
* @access public
* @param Query $query 查询对象
* @param mixed $key 字段名
* @param bool $strict 严格检测
* @param Query $query 查询对象
* @param mixed $key 字段名
* @param bool $strict 严格检测
* @return string
*/
public function parseKey(Query $query, $key, bool $strict = false): string
......@@ -73,7 +73,7 @@ class Sqlite extends Builder
$key = trim($key);
if (strpos($key, '.')) {
if (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) {
[$table, $key] = explode('.', $key, 2);
$alias = $query->getOptions('alias');
......@@ -88,8 +88,12 @@ class Sqlite extends Builder
}
}
if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
$key = '`' . $key . '`';
}
if (isset($table)) {
$key = $table . '.' . $key;
$key = '`' . $table . '`.' . $key;
}
return $key;
......@@ -98,8 +102,8 @@ class Sqlite extends Builder
/**
* 设置锁机制
* @access protected
* @param Query $query 查询对象
* @param bool|string $lock
* @param Query $query 查询对象
* @param bool|string $lock
* @return string
*/
protected function parseLock(Query $query, $lock = false): string
......
......@@ -42,7 +42,7 @@ class Sqlite extends PDOConnection
public function getFields(string $tableName): array
{
[$tableName] = explode(' ', $tableName);
$sql = 'PRAGMA table_info( ' . $tableName . ' )';
$sql = 'PRAGMA table_info( \'' . $tableName . '\' )';
$pdo = $this->getPDOStatement($sql);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
......
......@@ -382,6 +382,9 @@ trait Attribute
} elseif (isset($this->type[$name])) {
// 类型转换
$value = $this->writeTransform($value, $this->type[$name]);
} elseif (is_object($value) && method_exists($value, '__toString')) {
// 对象类型
$value = $value->__toString();
}
// 设置数据对象属性
......
......@@ -236,12 +236,11 @@ class BelongsTo extends OneToOne
$relationModel->exists(true);
}
// 设置关联属性
$result->setRelation($relation, $relationModel);
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
// 设置关联属性
$result->setRelation($relation, $relationModel);
}
}
}
......@@ -277,12 +276,12 @@ class BelongsTo extends OneToOne
$relationModel->exists(true);
}
// 设置关联属性
$result->setRelation($relation, $relationModel);
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
// 设置关联属性
$result->setRelation($relation, $relationModel);
}
}
......
......@@ -137,6 +137,30 @@ class BelongsToMany extends Relation
->setParent(clone $this->parent);
}
/**
* 组装Pivot模型
* @access public
* @param Model $result 模型对象
* @return array
*/
protected function matchPivot(Model $result): array
{
$pivot = [];
foreach ($result->getData() as $key => $val) {
if (strpos($key, '__')) {
[$name, $attr] = explode('__', $key, 2);
if ('pivot' == $name) {
$pivot[$attr] = $val;
unset($result->$key);
}
}
}
$result->setRelation($this->pivotDataName, $this->newPivot($pivot));
return $pivot;
}
/**
* 根据关联条件查询当前模型
* @access public
......@@ -326,24 +350,13 @@ class BelongsToMany extends Relation
// 组装模型数据
$data = [];
foreach ($list as $set) {
$pivot = [];
foreach ($set->getData() as $key => $val) {
if (strpos($key, '__')) {
[$name, $attr] = explode('__', $key, 2);
if ('pivot' == $name) {
$pivot[$attr] = $val;
unset($set->$key);
}
}
}
$key = $pivot[$this->localKey];
$pivot = $this->matchPivot($set);
$key = $pivot[$this->localKey];
if ($this->withLimit && isset($data[$key]) && count($data[$key]) >= $this->withLimit) {
continue;
}
$set->setRelation($this->pivotDataName, $this->newPivot($pivot));
$data[$key][] = $set;
}
......@@ -594,21 +607,8 @@ class BelongsToMany extends Relation
$foreignKey = $this->foreignKey;
$localKey = $this->localKey;
$this->query->getModel()->filter(function ($result, $options) {
$pivot = [];
foreach ($result->getData() as $key => $val) {
if (strpos($key, '__')) {
[$name, $attr] = explode('__', $key, 2);
if ('pivot' == $name) {
$pivot[$attr] = $val;
unset($result->$key);
}
}
}
$result->setRelation($this->pivotDataName, $this->newPivot($pivot));
$this->query->filter(function ($result, $options) {
$this->matchPivot($result);
});
// 关联查询
......
......@@ -258,8 +258,14 @@ class HasManyThrough extends Relation
$closure($this->getClosureType($closure));
}
$throughKey = $this->throughKey;
if ($this->baseQuery) {
$throughKey = Str::snake(class_basename($this->model)) . "." . $this->throughKey;
}
$list = $this->query
->where($this->throughKey, 'in', $keys)
->where($throughKey, 'in', $keys)
->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null)
->select();
......
......@@ -234,13 +234,12 @@ class HasOne extends OneToOne
$relationModel->setParent(clone $result);
$relationModel->exists(true);
}
// 设置关联属性
$result->setRelation($relation, $relationModel);
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
// 设置关联属性
$result->setRelation($relation, $relationModel);
}
}
}
......@@ -276,11 +275,12 @@ class HasOne extends OneToOne
$relationModel->exists(true);
}
// 设置关联属性
$result->setRelation($relation, $relationModel);
if (!empty($this->bindAttr)) {
// 绑定关联属性
$this->bindAttr($result, $relationModel);
} else {
$result->setRelation($relation, $relationModel);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册