@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think; |
14 | 14 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function create($data = '', string $type = '', int $code = 200): Response |
103 | 103 | { |
104 | - $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); |
|
104 | + $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\'.ucfirst(strtolower($type)); |
|
105 | 105 | |
106 | 106 | if (class_exists($class)) { |
107 | 107 | return Container::getInstance()->invokeClass($class, [$data, $code]); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | http_response_code($this->code); |
151 | 151 | // 发送头部信息 |
152 | 152 | foreach ($this->header as $name => $val) { |
153 | - header($name . (!is_null($val) ? ':' . $val : '')); |
|
153 | + header($name.(!is_null($val) ? ':'.$val : '')); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public function contentType(string $contentType, string $charset = 'utf-8') |
345 | 345 | { |
346 | - $this->header['Content-Type'] = $contentType . '; charset=' . $charset; |
|
346 | + $this->header['Content-Type'] = $contentType.'; charset='.$charset; |
|
347 | 347 | |
348 | 348 | return $this; |
349 | 349 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: zhangyajun <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model; |
14 | 14 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function delete(): bool |
46 | 46 | { |
47 | - $this->each(function (Model $model) { |
|
47 | + $this->each(function(Model $model) { |
|
48 | 48 | $model->delete(); |
49 | 49 | }); |
50 | 50 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function update(array $data, array $allowField = []): bool |
62 | 62 | { |
63 | - $this->each(function (Model $model) use ($data, $allowField) { |
|
63 | + $this->each(function(Model $model) use ($data, $allowField) { |
|
64 | 64 | if (!empty($allowField)) { |
65 | 65 | $model->allowField($allowField); |
66 | 66 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function hidden(array $hidden) |
81 | 81 | { |
82 | - $this->each(function (Model $model) use ($hidden) { |
|
82 | + $this->each(function(Model $model) use ($hidden) { |
|
83 | 83 | $model->hidden($hidden); |
84 | 84 | }); |
85 | 85 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function visible(array $visible) |
96 | 96 | { |
97 | - $this->each(function (Model $model) use ($visible) { |
|
97 | + $this->each(function(Model $model) use ($visible) { |
|
98 | 98 | $model->visible($visible); |
99 | 99 | }); |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function append(array $append) |
111 | 111 | { |
112 | - $this->each(function (Model $model) use ($append) { |
|
112 | + $this->each(function(Model $model) use ($append) { |
|
113 | 113 | $model->append($append); |
114 | 114 | }); |
115 | 115 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function setParent(Model $parent) |
126 | 126 | { |
127 | - $this->each(function (Model $model) use ($parent) { |
|
127 | + $this->each(function(Model $model) use ($parent) { |
|
128 | 128 | $model->setParent($parent); |
129 | 129 | }); |
130 | 130 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function withAttr($name, $callback = null) |
142 | 142 | { |
143 | - $this->each(function (Model $model) use ($name, $callback) { |
|
143 | + $this->each(function(Model $model) use ($name, $callback) { |
|
144 | 144 | $model->withAttribute($name, $callback); |
145 | 145 | }); |
146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function bindAttr(string $relation, array $attrs = []) |
159 | 159 | { |
160 | - $this->each(function (Model $model) use ($relation, $attrs) { |
|
160 | + $this->each(function(Model $model) use ($relation, $attrs) { |
|
161 | 161 | $model->bindAttr($relation, $attrs); |
162 | 162 | }); |
163 | 163 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model\concern; |
14 | 14 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $query->where($data); |
156 | 156 | $data = null; |
157 | 157 | } elseif ($data instanceof \Closure) { |
158 | - call_user_func_array($data, [ & $query]); |
|
158 | + call_user_func_array($data, [& $query]); |
|
159 | 159 | $data = null; |
160 | 160 | } elseif (is_null($data)) { |
161 | 161 | return false; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | if (false === strpos($field, '.')) { |
220 | - $field = '__TABLE__.' . $field; |
|
220 | + $field = '__TABLE__.'.$field; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | if (!$read && strpos($field, '.')) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model\concern; |
14 | 14 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | |
55 | - $call = 'on' . App::parseName($event, 1); |
|
55 | + $call = 'on'.App::parseName($event, 1); |
|
56 | 56 | |
57 | 57 | try { |
58 | 58 | if (method_exists(static::class, $call)) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model\concern; |
14 | 14 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | foreach ($append as $key => $attr) { |
84 | 84 | $key = is_numeric($key) ? $attr : $key; |
85 | 85 | if (isset($this->data[$key])) { |
86 | - throw new Exception('bind attr has exists:' . $key); |
|
86 | + throw new Exception('bind attr has exists:'.$key); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $this->data[$key] = $model->$attr; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $key = is_numeric($key) ? $attr : $key; |
228 | 228 | |
229 | 229 | if (isset($item[$key])) { |
230 | - throw new Exception('bind attr has exists:' . $key); |
|
230 | + throw new Exception('bind attr has exists:'.$key); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $item[$key] = $value ? $value->getAttr($attr) : null; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model; |
14 | 14 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function getRelationQueryFields($fields, string $model) |
141 | 141 | { |
142 | 142 | if (empty($fields) || '*' == $fields) { |
143 | - return $model . '.*'; |
|
143 | + return $model.'.*'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | if (is_string($fields)) { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | foreach ($fields as &$field) { |
151 | 151 | if (false === strpos($field, '.')) { |
152 | - $field = $model . '.' . $field; |
|
152 | + $field = $model.'.'.$field; |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | { |
161 | 161 | foreach ($where as $key => &$val) { |
162 | 162 | if (is_string($key)) { |
163 | - $where[] = [false === strpos($key, '.') ? $relation . '.' . $key : $key, '=', $val]; |
|
163 | + $where[] = [false === strpos($key, '.') ? $relation.'.'.$key : $key, '=', $val]; |
|
164 | 164 | unset($where[$key]); |
165 | 165 | } elseif (isset($val[0]) && false === strpos($val[0], '.')) { |
166 | - $val[0] = $relation . '.' . $val[0]; |
|
166 | + $val[0] = $relation.'.'.$val[0]; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -237,6 +237,6 @@ discard block |
||
237 | 237 | return $result === $this->query ? $this : $result; |
238 | 238 | } |
239 | 239 | |
240 | - throw new Exception('method not exists:' . __CLASS__ . '->' . $method); |
|
240 | + throw new Exception('method not exists:'.__CLASS__.'->'.$method); |
|
241 | 241 | } |
242 | 242 | } |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | $query->via($joinAlias); |
92 | 92 | |
93 | 93 | if ($this instanceof BelongsTo) { |
94 | - $joinOn = $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey; |
|
94 | + $joinOn = $name.'.'.$this->foreignKey.'='.$joinAlias.'.'.$this->localKey; |
|
95 | 95 | } else { |
96 | - $joinOn = $name . '.' . $this->localKey . '=' . $joinAlias . '.' . $this->foreignKey; |
|
96 | + $joinOn = $name.'.'.$this->localKey.'='.$joinAlias.'.'.$this->foreignKey; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | if ($closure) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $query->join([$joinTable => $joinAlias], $joinOn, $joinType) |
109 | - ->tableField($field, $joinTable, $joinAlias, $relation . '__'); |
|
109 | + ->tableField($field, $joinTable, $joinAlias, $relation.'__'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $value = $result->getOrigin($key); |
276 | 276 | |
277 | 277 | if (!is_null($value)) { |
278 | - throw new Exception('bind attr has exists:' . $key); |
|
278 | + throw new Exception('bind attr has exists:'.$key); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | $result->setAttr($key, $model ? $model->$attr : null); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\model\relation; |
14 | 14 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | |
90 | 90 | return $this->query |
91 | - ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->localKey) |
|
91 | + ->whereExp($this->foreignKey, '='.$this->parent->getTable().'.'.$this->localKey) |
|
92 | 92 | ->fetchSql() |
93 | 93 | ->$aggregate($field); |
94 | 94 | } |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | |
140 | 140 | return $this->parent->db() |
141 | 141 | ->alias($model) |
142 | - ->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) { |
|
142 | + ->whereExists(function($query) use ($table, $model, $relation, $localKey, $foreignKey) { |
|
143 | 143 | $query->table([$table => $relation]) |
144 | - ->field($relation . '.' . $foreignKey) |
|
145 | - ->whereExp($model . '.' . $localKey, '=' . $relation . '.' . $foreignKey); |
|
144 | + ->field($relation.'.'.$foreignKey) |
|
145 | + ->whereExp($model.'.'.$localKey, '='.$relation.'.'.$foreignKey); |
|
146 | 146 | }); |
147 | 147 | } |
148 | 148 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return $this->parent->db() |
172 | 172 | ->alias($model) |
173 | 173 | ->field($fields) |
174 | - ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType ?: $this->joinType) |
|
174 | + ->join([$table => $relation], $model.'.'.$this->localKey.'='.$relation.'.'.$this->foreignKey, $joinType ?: $this->joinType) |
|
175 | 175 | ->where($where); |
176 | 176 | } |
177 | 177 |
@@ -231,7 +231,7 @@ |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | return $this->query |
234 | - ->whereExp($this->morphKey, '=' . $this->parent->getTable() . '.' . $this->parent->getPk()) |
|
234 | + ->whereExp($this->morphKey, '='.$this->parent->getTable().'.'.$this->parent->getPk()) |
|
235 | 235 | ->where($this->morphType, '=', $this->type) |
236 | 236 | ->fetchSql() |
237 | 237 | ->$aggregate($field); |