@@ -35,16 +35,16 @@ |
||
35 | 35 | |
36 | 36 | public function read(string $sessionId): string |
37 | 37 | { |
38 | - return (string) $this->handler->get($this->prefix . $sessionId); |
|
38 | + return (string) $this->handler->get($this->prefix.$sessionId); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function delete(string $sessionId): bool |
42 | 42 | { |
43 | - return $this->handler->delete($this->prefix . $sessionId); |
|
43 | + return $this->handler->delete($this->prefix.$sessionId); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function write(string $sessionId, string $data): bool |
47 | 47 | { |
48 | - return $this->handler->set($this->prefix . $sessionId, $data, $this->expire); |
|
48 | + return $this->handler->set($this->prefix.$sessionId, $data, $this->expire); |
|
49 | 49 | } |
50 | 50 | } |
@@ -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 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function getConfig(string $name = null, $default = null) |
42 | 42 | { |
43 | 43 | if (!is_null($name)) { |
44 | - return $this->app->config->get('session.' . $name, $default); |
|
44 | + return $this->app->config->get('session.'.$name, $default); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return $this->app->config->get('session'); |
@@ -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 | //------------------------ |
14 | 14 | // ThinkPHP 助手函数 |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); |
191 | 191 | |
192 | 192 | if (PHP_SAPI == 'cli') { |
193 | - $output = PHP_EOL . $output . PHP_EOL; |
|
193 | + $output = PHP_EOL.$output.PHP_EOL; |
|
194 | 194 | } else { |
195 | 195 | if (!extension_loaded('xdebug')) { |
196 | 196 | $output = htmlspecialchars($output, ENT_SUBSTITUTE); |
197 | 197 | } |
198 | - $output = '<pre>' . $output . '</pre>'; |
|
198 | + $output = '<pre>'.$output.'</pre>'; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | echo $output; |
@@ -274,8 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | return isset($has) ? |
277 | - request()->has($key, $method) : |
|
278 | - request()->$method($key, $default, $filter); |
|
277 | + request()->has($key, $method) : request()->$method($key, $default, $filter); |
|
279 | 278 | } |
280 | 279 | } |
281 | 280 | |
@@ -352,7 +351,7 @@ discard block |
||
352 | 351 | function parse_name(string $name, int $type = 0, bool $ucfirst = true): string |
353 | 352 | { |
354 | 353 | if ($type) { |
355 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
354 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
356 | 355 | return strtoupper($match[1]); |
357 | 356 | }, $name); |
358 | 357 | |
@@ -459,7 +458,7 @@ discard block |
||
459 | 458 | { |
460 | 459 | $token = Request::buildToken($name, $type); |
461 | 460 | |
462 | - return '<input type="hidden" name="' . $name . '" value="' . $token . '" />'; |
|
461 | + return '<input type="hidden" name="'.$name.'" value="'.$token.'" />'; |
|
463 | 462 | } |
464 | 463 | } |
465 | 464 | |
@@ -474,7 +473,7 @@ discard block |
||
474 | 473 | { |
475 | 474 | $token = Request::buildToken($name, $type); |
476 | 475 | |
477 | - return '<meta name="csrf-token" content="' . $token . '">'; |
|
476 | + return '<meta name="csrf-token" content="'.$token.'">'; |
|
478 | 477 | } |
479 | 478 | } |
480 | 479 | |
@@ -599,7 +598,7 @@ discard block |
||
599 | 598 | */ |
600 | 599 | function app_path($path = '') |
601 | 600 | { |
602 | - return app()->getAppPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); |
|
601 | + return app()->getAppPath().($path ? $path.DIRECTORY_SEPARATOR : $path); |
|
603 | 602 | } |
604 | 603 | } |
605 | 604 | |
@@ -612,7 +611,7 @@ discard block |
||
612 | 611 | */ |
613 | 612 | function base_path($path = '') |
614 | 613 | { |
615 | - return app()->getBasePath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); |
|
614 | + return app()->getBasePath().($path ? $path.DIRECTORY_SEPARATOR : $path); |
|
616 | 615 | } |
617 | 616 | } |
618 | 617 | |
@@ -625,7 +624,7 @@ discard block |
||
625 | 624 | */ |
626 | 625 | function config_path($path = '') |
627 | 626 | { |
628 | - return app()->getConfigPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); |
|
627 | + return app()->getConfigPath().($path ? $path.DIRECTORY_SEPARATOR : $path); |
|
629 | 628 | } |
630 | 629 | } |
631 | 630 | |
@@ -638,7 +637,7 @@ discard block |
||
638 | 637 | */ |
639 | 638 | function public_path($path = '') |
640 | 639 | { |
641 | - return app()->getRootPath() . ($path ? ltrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $path); |
|
640 | + return app()->getRootPath().($path ? ltrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path); |
|
642 | 641 | } |
643 | 642 | } |
644 | 643 | |
@@ -651,7 +650,7 @@ discard block |
||
651 | 650 | */ |
652 | 651 | function runtime_path($path = '') |
653 | 652 | { |
654 | - return app()->getRuntimePath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); |
|
653 | + return app()->getRuntimePath().($path ? $path.DIRECTORY_SEPARATOR : $path); |
|
655 | 654 | } |
656 | 655 | } |
657 | 656 | |
@@ -664,6 +663,6 @@ discard block |
||
664 | 663 | */ |
665 | 664 | function root_path($path = '') |
666 | 665 | { |
667 | - return app()->getRootPath() . ($path ? $path . DIRECTORY_SEPARATOR : $path); |
|
666 | + return app()->getRootPath().($path ? $path.DIRECTORY_SEPARATOR : $path); |
|
668 | 667 | } |
669 | 668 | } |
@@ -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\middleware; |
14 | 14 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | if ($this->lang->defaultLangSet() != $langset) { |
49 | 49 | // 加载系统语言包 |
50 | 50 | $this->lang->load([ |
51 | - $this->app->getThinkPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.php', |
|
51 | + $this->app->getThinkPath().'lang'.DIRECTORY_SEPARATOR.$langset.'.php', |
|
52 | 52 | ]); |
53 | 53 | |
54 | 54 | $this->app->LoadLangPack($langset); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $pipeline = array_reduce( |
55 | 55 | array_reverse($this->pipes), |
56 | 56 | $this->carry(), |
57 | - function ($passable) use ($destination) { |
|
57 | + function($passable) use ($destination) { |
|
58 | 58 | try { |
59 | 59 | return $destination($passable); |
60 | 60 | } catch (Throwable | Exception $e) { |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | protected function carry() |
80 | 80 | { |
81 | - return function ($stack, $pipe) { |
|
82 | - return function ($passable) use ($stack, $pipe) { |
|
81 | + return function($stack, $pipe) { |
|
82 | + return function($passable) use ($stack, $pipe) { |
|
83 | 83 | try { |
84 | 84 | return $pipe($passable, $stack); |
85 | 85 | } catch (Throwable | Exception $e) { |
@@ -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 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function getConfig(string $name = '', $default = null) |
69 | 69 | { |
70 | 70 | if ('' !== $name) { |
71 | - return $this->config->get('database.' . $name, $default); |
|
71 | + return $this->config->get('database.'.$name, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $this->config->get('database', []); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function event(string $event, callable $callback): void |
94 | 94 | { |
95 | 95 | if ($this->event) { |
96 | - $this->event->listen('db.' . $event, $callback); |
|
96 | + $this->event->listen('db.'.$event, $callback); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function trigger(string $event, $params = null, bool $once = false) |
109 | 109 | { |
110 | 110 | if ($this->event) { |
111 | - return $this->event->trigger('db.' . $event, $params, $once); |
|
111 | + return $this->event->trigger('db.'.$event, $params, $once); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | $config->shouldReceive('get')->with('database', [])->andReturn([]); |
33 | 33 | $this->assertEquals([], $db->getConfig()); |
34 | 34 | |
35 | - $callback = function () { |
|
35 | + $callback = function() { |
|
36 | 36 | }; |
37 | 37 | $event->shouldReceive('listen')->with('db.some', $callback); |
38 | 38 | $db->event('some', $callback); |
@@ -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 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | */ |
368 | 368 | public function hasScene(string $name): bool |
369 | 369 | { |
370 | - return isset($this->scene[$name]) || method_exists($this, 'scene' . $name); |
|
370 | + return isset($this->scene[$name]) || method_exists($this, 'scene'.$name); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | if (strpos($field, '_confirm')) { |
720 | 720 | $rule = strstr($field, '_confirm', true); |
721 | 721 | } else { |
722 | - $rule = $field . '_confirm'; |
|
722 | + $rule = $field.'_confirm'; |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | if (isset($this->type[$rule])) { |
871 | 871 | // 注册的验证规则 |
872 | 872 | $result = call_user_func_array($this->type[$rule], [$value]); |
873 | - } elseif (function_exists('ctype_' . $rule)) { |
|
873 | + } elseif (function_exists('ctype_'.$rule)) { |
|
874 | 874 | // ctype验证规则 |
875 | - $ctypeFun = 'ctype_' . $rule; |
|
875 | + $ctypeFun = 'ctype_'.$rule; |
|
876 | 876 | $result = $ctypeFun($value); |
877 | 877 | } elseif (isset($this->filter[$rule])) { |
878 | 878 | // Filter_var验证规则 |
@@ -1510,7 +1510,7 @@ discard block |
||
1510 | 1510 | |
1511 | 1511 | if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { |
1512 | 1512 | // 不是正则表达式则两端补上/ |
1513 | - $rule = '/^' . $rule . '$/'; |
|
1513 | + $rule = '/^'.$rule.'$/'; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | return is_scalar($value) && 1 === preg_match($rule, (string) $value); |
@@ -1560,8 +1560,8 @@ discard block |
||
1560 | 1560 | */ |
1561 | 1561 | protected function getRuleMsg(string $attribute, string $title, string $type, $rule) |
1562 | 1562 | { |
1563 | - if (isset($this->message[$attribute . '.' . $type])) { |
|
1564 | - $msg = $this->message[$attribute . '.' . $type]; |
|
1563 | + if (isset($this->message[$attribute.'.'.$type])) { |
|
1564 | + $msg = $this->message[$attribute.'.'.$type]; |
|
1565 | 1565 | } elseif (isset($this->message[$attribute][$type])) { |
1566 | 1566 | $msg = $this->message[$attribute][$type]; |
1567 | 1567 | } elseif (isset($this->message[$attribute])) { |
@@ -1571,7 +1571,7 @@ discard block |
||
1571 | 1571 | } elseif (0 === strpos($type, 'require')) { |
1572 | 1572 | $msg = $this->typeMsg['require']; |
1573 | 1573 | } else { |
1574 | - $msg = $title . $this->lang->get('not conform to the rules'); |
|
1574 | + $msg = $title.$this->lang->get('not conform to the rules'); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | if (is_array($msg)) { |
@@ -1633,8 +1633,8 @@ discard block |
||
1633 | 1633 | { |
1634 | 1634 | $this->only = $this->append = $this->remove = []; |
1635 | 1635 | |
1636 | - if (method_exists($this, 'scene' . $scene)) { |
|
1637 | - call_user_func([$this, 'scene' . $scene]); |
|
1636 | + if (method_exists($this, 'scene'.$scene)) { |
|
1637 | + call_user_func([$this, 'scene'.$scene]); |
|
1638 | 1638 | } elseif (isset($this->scene[$scene])) { |
1639 | 1639 | // 如果设置了验证适用场景 |
1640 | 1640 | $this->only = $this->scene[$scene]; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $this->event->bind(['foo' => 'baz']); |
44 | 44 | |
45 | - $this->event->listen('foo', function ($bar) { |
|
45 | + $this->event->listen('foo', function($bar) { |
|
46 | 46 | $this->assertEquals('bar', $bar); |
47 | 47 | }); |
48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public function testOnceEvent() |
59 | 59 | { |
60 | - $this->event->listen('AppInit', function ($bar) { |
|
60 | + $this->event->listen('AppInit', function($bar) { |
|
61 | 61 | $this->assertEquals('bar', $bar); |
62 | 62 | return 'foo'; |
63 | 63 | }); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $listener = m::mock("overload:SomeListener", TestListener::class); |
83 | 83 | |
84 | - $listener->shouldReceive('subscribe')->andReturnUsing(function (Event $event) use ($listener) { |
|
84 | + $listener->shouldReceive('subscribe')->andReturnUsing(function(Event $event) use ($listener) { |
|
85 | 85 | |
86 | 86 | $listener->shouldReceive('onBar')->once()->andReturnFalse(); |
87 | 87 |