@@ -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 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function fetch(string $template = '', array $vars = []): string |
| 88 | 88 | { |
| 89 | - return $this->getContent(function () use ($vars, $template) { |
|
| 89 | + return $this->getContent(function() use ($vars, $template) { |
|
| 90 | 90 | $this->engine()->fetch($template, array_merge($this->data, $vars)); |
| 91 | 91 | }); |
| 92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function display(string $content, array $vars = []): string |
| 102 | 102 | { |
| 103 | - return $this->getContent(function () use ($vars, $content) { |
|
| 103 | + return $this->getContent(function() use ($vars, $content) { |
|
| 104 | 104 | $this->engine()->display($content, array_merge($this->data, $vars)); |
| 105 | 105 | }); |
| 106 | 106 | } |
@@ -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\view\driver; |
| 14 | 14 | |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // 模板不存在 抛出异常 |
| 80 | 80 | if (!is_file($template)) { |
| 81 | - throw new RuntimeException('template not exists:' . $template); |
|
| 81 | + throw new RuntimeException('template not exists:'.$template); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $this->template = $template; |
| 85 | 85 | |
| 86 | 86 | // 记录视图信息 |
| 87 | 87 | $this->app->log |
| 88 | - ->record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
| 88 | + ->record('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
| 89 | 89 | |
| 90 | 90 | extract($data, EXTR_OVERWRITE); |
| 91 | 91 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $this->content = $content; |
| 105 | 105 | |
| 106 | 106 | extract($data, EXTR_OVERWRITE); |
| 107 | - eval('?>' . $this->content); |
|
| 107 | + eval('?>'.$this->content); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | $appName = isset($app) ? $app : $request->app(); |
| 130 | 130 | $view = $this->config['view_dir_name']; |
| 131 | 131 | |
| 132 | - if (is_dir($this->app->getAppPath() . $view)) { |
|
| 133 | - $path = isset($app) ? $this->app->getBasePath() . ($appName ? $appName . DIRECTORY_SEPARATOR : '') . $view . DIRECTORY_SEPARATOR : $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR; |
|
| 132 | + if (is_dir($this->app->getAppPath().$view)) { |
|
| 133 | + $path = isset($app) ? $this->app->getBasePath().($appName ? $appName.DIRECTORY_SEPARATOR : '').$view.DIRECTORY_SEPARATOR : $this->app->getAppPath().$view.DIRECTORY_SEPARATOR; |
|
| 134 | 134 | } else { |
| 135 | - $path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($appName ? $appName . DIRECTORY_SEPARATOR : ''); |
|
| 135 | + $path = $this->app->getRootPath().$view.DIRECTORY_SEPARATOR.($appName ? $appName.DIRECTORY_SEPARATOR : ''); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $controller = $request->controller(); |
| 144 | 144 | if (strpos($controller, '.')) { |
| 145 | 145 | $pos = strrpos($controller, '.'); |
| 146 | - $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); |
|
| 146 | + $controller = substr($controller, 0, $pos).'.'.Str::snake(substr($controller, $pos + 1)); |
|
| 147 | 147 | } else { |
| 148 | 148 | $controller = Str::snake($controller); |
| 149 | 149 | } |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | $template = Str::snake($request->action()); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 162 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 163 | 163 | } elseif (false === strpos($template, $depr)) { |
| 164 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 164 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } else { |
| 168 | 168 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
| 171 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -43,11 +43,11 @@ |
||
| 43 | 43 | $this->config = m::mock(Config::class)->makePartial(); |
| 44 | 44 | |
| 45 | 45 | $this->app->shouldReceive('get')->with('config')->andReturn($this->config); |
| 46 | - $handlerClass = "\\think\\session\\driver\\Test" . Str::random(10); |
|
| 46 | + $handlerClass = "\\think\\session\\driver\\Test".Str::random(10); |
|
| 47 | 47 | $this->config->shouldReceive("get")->with("session.type", "file")->andReturn($handlerClass); |
| 48 | 48 | $this->session = new Session($this->app); |
| 49 | 49 | |
| 50 | - $this->handler = m::mock('overload:' . $handlerClass, SessionHandlerInterface::class); |
|
| 50 | + $this->handler = m::mock('overload:'.$handlerClass, SessionHandlerInterface::class); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function testLoadData() |
@@ -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\session\driver; |
| 14 | 14 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $this->config = array_merge($this->config, $config); |
| 40 | 40 | |
| 41 | 41 | if (empty($this->config['path'])) { |
| 42 | - $this->config['path'] = $app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . 'session' . DIRECTORY_SEPARATOR; |
|
| 42 | + $this->config['path'] = $app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.'session'.DIRECTORY_SEPARATOR; |
|
| 43 | 43 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
| 44 | 44 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
| 45 | 45 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $lifetime = $this->config['expire']; |
| 77 | 77 | $now = time(); |
| 78 | 78 | |
| 79 | - $files = $this->findFiles($this->config['path'], function (SplFileInfo $item) use ($lifetime, $now) { |
|
| 79 | + $files = $this->findFiles($this->config['path'], function(SplFileInfo $item) use ($lifetime, $now) { |
|
| 80 | 80 | return $now > $item->getMTime() + $lifetime; |
| 81 | 81 | }); |
| 82 | 82 | |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | if ($this->config['prefix']) { |
| 120 | 120 | // 使用子目录 |
| 121 | - $name = $this->config['prefix'] . DIRECTORY_SEPARATOR . 'sess_' . $name; |
|
| 121 | + $name = $this->config['prefix'].DIRECTORY_SEPARATOR.'sess_'.$name; |
|
| 122 | 122 | } else { |
| 123 | - $name = 'sess_' . $name; |
|
| 123 | + $name = 'sess_'.$name; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $filename = $this->config['path'] . $name; |
|
| 126 | + $filename = $this->config['path'].$name; |
|
| 127 | 127 | $dir = dirname($filename); |
| 128 | 128 | |
| 129 | 129 | if ($auto && !is_dir($dir)) { |
@@ -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'); |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | */ |
| 119 | 119 | public function setId($id = null): void |
| 120 | 120 | { |
| 121 | - $this->id = is_string($id) && strlen($id) === 32 ? $id : md5(microtime(true) . uniqid()); |
|
| 121 | + $this->id = is_string($id) && strlen($id) === 32 ? $id : md5(microtime(true).uniqid()); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -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 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $this->middleware->add('foo'); |
| 66 | 66 | $this->assertEquals(4, count($this->middleware->all())); |
| 67 | - $this->middleware->add(function () { |
|
| 67 | + $this->middleware->add(function() { |
|
| 68 | 68 | }); |
| 69 | 69 | $this->assertEquals(5, count($this->middleware->all())); |
| 70 | 70 | } |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | $handle->shouldReceive('report')->with($e)->andReturnNull(); |
| 84 | 84 | $handle->shouldReceive('render')->with($request, $e)->andReturn($response); |
| 85 | 85 | |
| 86 | - $foo->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) { |
|
| 86 | + $foo->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) { |
|
| 87 | 87 | return $next($request); |
| 88 | 88 | }); |
| 89 | - $bar->shouldReceive('handle')->once()->andReturnUsing(function ($request, $next) use ($e) { |
|
| 89 | + $bar->shouldReceive('handle')->once()->andReturnUsing(function($request, $next) use ($e) { |
|
| 90 | 90 | $next($request); |
| 91 | 91 | throw $e; |
| 92 | 92 | }); |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $this->config->shouldReceive('get')->once()->with('middleware.priority', [])->andReturn(['FooMiddleware', 'BarMiddleware']); |
| 99 | 99 | |
| 100 | - $this->middleware->import([function ($request, $next) { |
|
| 100 | + $this->middleware->import([function($request, $next) { |
|
| 101 | 101 | return $next($request); |
| 102 | 102 | }, 'BarMiddleware', 'FooMiddleware']); |
| 103 | 103 | |
| 104 | 104 | $this->assertInstanceOf(Pipeline::class, $pipeline = $this->middleware->pipeline()); |
| 105 | 105 | |
| 106 | - $pipeline->send($request)->then(function ($request) use ($e, $response) { |
|
| 106 | + $pipeline->send($request)->then(function($request) use ($e, $response) { |
|
| 107 | 107 | throw $e; |
| 108 | 108 | }); |
| 109 | 109 | |