@@ -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: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think; |
14 | 14 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | return $this->make($abstract); |
142 | 142 | } |
143 | 143 | |
144 | - throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract); |
|
144 | + throw new ClassNotFoundException('class not exists: '.$abstract, $abstract); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | return call_user_func_array($function, $args); |
301 | 301 | } catch (ReflectionException $e) { |
302 | - throw new Exception('function not exists: ' . $function . '()'); |
|
302 | + throw new Exception('function not exists: '.$function.'()'); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | } catch (ReflectionException $e) { |
328 | 328 | if (is_array($method)) { |
329 | 329 | $class = is_object($method[0]) ? get_class($method[0]) : $method[0]; |
330 | - $callback = $class . '::' . $method[1]; |
|
330 | + $callback = $class.'::'.$method[1]; |
|
331 | 331 | } else { |
332 | 332 | $callback = $method; |
333 | 333 | } |
334 | 334 | |
335 | - throw new Exception('method not exists: ' . $callback . '()'); |
|
335 | + throw new Exception('method not exists: '.$callback.'()'); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | return $reflect->newInstanceArgs($args); |
396 | 396 | } catch (ReflectionException $e) { |
397 | - throw new ClassNotFoundException('class not exists: ' . $class, $class); |
|
397 | + throw new ClassNotFoundException('class not exists: '.$class, $class); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | } elseif ($param->isDefaultValueAvailable()) { |
434 | 434 | $args[] = $param->getDefaultValue(); |
435 | 435 | } else { |
436 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
436 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 |
@@ -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\concern; |
14 | 14 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function setRelation(string $name, $value, array $data = []) |
114 | 114 | { |
115 | 115 | // 检测修改器 |
116 | - $method = 'set' . App::parseName($name, 1) . 'Attr'; |
|
116 | + $method = 'set'.App::parseName($name, 1).'Attr'; |
|
117 | 117 | |
118 | 118 | if (method_exists($this, $method)) { |
119 | 119 | $value = $this->$method($value, array_merge($this->data, $data)); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $value = $this->getOrigin($key); |
313 | 313 | |
314 | 314 | if (!is_null($value)) { |
315 | - throw new Exception('bind attr has exists:' . $key); |
|
315 | + throw new Exception('bind attr has exists:'.$key); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | $this->set($key, $relation ? $relation->$attr : null); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $count = $this->$relation()->relationCount($result, $closure, $aggregate, $field, $name); |
348 | 348 | |
349 | 349 | if (empty($name)) { |
350 | - $name = App::parseName($relation) . '_' . $aggregate; |
|
350 | + $name = App::parseName($relation).'_'.$aggregate; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $result->setAttr($name, $count); |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | // 记录当前关联信息 |
473 | 473 | $model = $this->parseModel($model); |
474 | 474 | $name = App::parseName(App::classBaseName($model)); |
475 | - $table = $table ?: App::parseName($this->name) . '_' . $name; |
|
476 | - $foreignKey = $foreignKey ?: $name . '_id'; |
|
475 | + $table = $table ?: App::parseName($this->name).'_'.$name; |
|
476 | + $foreignKey = $foreignKey ?: $name.'_id'; |
|
477 | 477 | $localKey = $localKey ?: $this->getForeignKey($this->name); |
478 | 478 | |
479 | 479 | return new BelongsToMany($this, $model, $table, $foreignKey, $localKey); |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | if (is_array($morph)) { |
501 | 501 | list($morphType, $foreignKey) = $morph; |
502 | 502 | } else { |
503 | - $morphType = $morph . '_type'; |
|
504 | - $foreignKey = $morph . '_id'; |
|
503 | + $morphType = $morph.'_type'; |
|
504 | + $foreignKey = $morph.'_id'; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $type = $type ?: get_class($this); |
@@ -532,8 +532,8 @@ discard block |
||
532 | 532 | if (is_array($morph)) { |
533 | 533 | list($morphType, $foreignKey) = $morph; |
534 | 534 | } else { |
535 | - $morphType = $morph . '_type'; |
|
536 | - $foreignKey = $morph . '_id'; |
|
535 | + $morphType = $morph.'_type'; |
|
536 | + $foreignKey = $morph.'_id'; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | return new MorphMany($this, $model, $foreignKey, $morphType, $type); |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | if (is_array($morph)) { |
560 | 560 | list($morphType, $foreignKey) = $morph; |
561 | 561 | } else { |
562 | - $morphType = $morph . '_type'; |
|
563 | - $foreignKey = $morph . '_id'; |
|
562 | + $morphType = $morph.'_type'; |
|
563 | + $foreignKey = $morph.'_id'; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | $name = App::classBaseName($name); |
597 | 597 | } |
598 | 598 | |
599 | - return App::parseName($name) . '_id'; |
|
599 | + return App::parseName($name).'_id'; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -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 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return $this->relation[$name]; |
283 | 283 | } |
284 | 284 | |
285 | - throw new InvalidArgumentException('property not exists:' . static::class . '->' . $name); |
|
285 | + throw new InvalidArgumentException('property not exists:'.static::class.'->'.$name); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function getChangedData(): array |
294 | 294 | { |
295 | - $data = $this->force ? $this->data : array_udiff_assoc($this->data, $this->origin, function ($a, $b) { |
|
295 | + $data = $this->force ? $this->data : array_udiff_assoc($this->data, $this->origin, function($a, $b) { |
|
296 | 296 | if ((empty($a) || empty($b)) && $a !== $b) { |
297 | 297 | return 1; |
298 | 298 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $value = $this->autoWriteTimestamp($name); |
360 | 360 | } else { |
361 | 361 | // 检测修改器 |
362 | - $method = 'set' . App::parseName($name, 1) . 'Attr'; |
|
362 | + $method = 'set'.App::parseName($name, 1).'Attr'; |
|
363 | 363 | |
364 | 364 | if (method_exists($this, $method)) { |
365 | 365 | $array = $this->data; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | { |
483 | 483 | // 检测属性获取器 |
484 | 484 | $fieldName = $this->getRealFieldName($name); |
485 | - $method = 'get' . App::parseName($name, 1) . 'Attr'; |
|
485 | + $method = 'get'.App::parseName($name, 1).'Attr'; |
|
486 | 486 | |
487 | 487 | if (isset($this->withAttr[$fieldName])) { |
488 | 488 | if ($relation) { |
@@ -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 | } |