Completed
Push — 6.0 ( 29f665...0391fe )
by liu
07:21
created
src/think/middleware/CheckRequestCache.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 
89 89
         if (isset($key) && 200 == $response->getCode() && $response->isAllowCache()) {
90 90
             $header                  = $response->getHeader();
91
-            $header['Cache-Control'] = 'max-age=' . $expire . ',must-revalidate';
92
-            $header['Last-Modified'] = gmdate('D, d M Y H:i:s') . ' GMT';
93
-            $header['Expires']       = gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT';
91
+            $header['Cache-Control'] = 'max-age='.$expire.',must-revalidate';
92
+            $header['Last-Modified'] = gmdate('D, d M Y H:i:s').' GMT';
93
+            $header['Expires']       = gmdate('D, d M Y H:i:s', time() + $expire).' GMT';
94 94
 
95 95
             $this->cache->tag($tag)->set($key, [$response->getContent(), $header, time()], $expire);
96 96
         }
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
         if (false !== strpos($key, ':')) {
142 142
             $param = $request->param();
143 143
             foreach ($param as $item => $val) {
144
-                if (is_string($val) && false !== strpos($key, ':' . $item)) {
145
-                    $key = str_replace(':' . $item, $val, $key);
144
+                if (is_string($val) && false !== strpos($key, ':'.$item)) {
145
+                    $key = str_replace(':'.$item, $val, $key);
146 146
                 }
147 147
             }
148 148
         } elseif (strpos($key, ']')) {
149
-            if ('[' . $request->ext() . ']' == $key) {
149
+            if ('['.$request->ext().']' == $key) {
150 150
                 // 缓存某个后缀的请求
151 151
                 $key = md5($request->url());
152 152
             } else {
Please login to merge, or discard this patch.
src/think/response/Html.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
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\response;
14 14
 
Please login to merge, or discard this patch.
src/think/Response.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public static function create($data = '', string $type = 'html', int $code = 200): Response
104 104
     {
105
-        $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type));
105
+        $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\'.ucfirst(strtolower($type));
106 106
 
107 107
         return Container::getInstance()->invokeClass($class, [$data, $code]);
108 108
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             http_response_code($this->code);
136 136
             // 发送头部信息
137 137
             foreach ($this->header as $name => $val) {
138
-                header($name . (!is_null($val) ? ':' . $val : ''));
138
+                header($name.(!is_null($val) ? ':'.$val : ''));
139 139
             }
140 140
         }
141 141
         if ($this->cookie) {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
     public function contentType(string $contentType, string $charset = 'utf-8')
346 346
     {
347
-        $this->header['Content-Type'] = $contentType . '; charset=' . $charset;
347
+        $this->header['Content-Type'] = $contentType.'; charset='.$charset;
348 348
 
349 349
         return $this;
350 350
     }
Please login to merge, or discard this patch.
src/think/cache/driver/Redis.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\cache\driver;
14 14
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $this->handler = new \Redis;
59 59
 
60 60
             if ($this->options['persistent']) {
61
-                $this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_' . $this->options['select']);
61
+                $this->handler->pconnect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout'], 'persistent_id_'.$this->options['select']);
62 62
             } else {
63 63
                 $this->handler->connect($this->options['host'], (int) $this->options['port'], (int) $this->options['timeout']);
64 64
             }
Please login to merge, or discard this patch.
src/think/cache/driver/Memcache.php 1 patch
Spacing   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\cache\driver;
14 14
 
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
         foreach ($hosts as $i => $host) {
65 65
             $port = $ports[$i] ?? $ports[0];
66 66
             $this->options['timeout'] > 0 ?
67
-            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) :
68
-            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
67
+            $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1);
69 68
         }
70 69
     }
71 70
 
@@ -177,8 +176,7 @@  discard block
 block discarded – undo
177 176
         $key = $this->getCacheKey($name);
178 177
 
179 178
         return false === $ttl ?
180
-        $this->handler->delete($key) :
181
-        $this->handler->delete($key, $ttl);
179
+        $this->handler->delete($key) : $this->handler->delete($key, $ttl);
182 180
     }
183 181
 
184 182
     /**
Please login to merge, or discard this patch.
src/think/Container.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             return $this->make($abstract);
131 131
         }
132 132
 
133
-        throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract);
133
+        throw new ClassNotFoundException('class not exists: '.$abstract, $abstract);
134 134
     }
135 135
 
136 136
     /**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             $reflect = new ReflectionMethod($class, $method);
316 316
         } catch (ReflectionException $e) {
317 317
             $class = is_object($class) ? get_class($class) : $class;
318
-            throw new FuncNotFoundException('method not exists: ' . $class . '::' . $method . '()', "{$class}::{$method}", $e);
318
+            throw new FuncNotFoundException('method not exists: '.$class.'::'.$method.'()', "{$class}::{$method}", $e);
319 319
         }
320 320
 
321 321
         $args = $this->bindParams($reflect, $vars);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
         try {
374 374
             $reflect = new ReflectionClass($class);
375 375
         } catch (ReflectionException $e) {
376
-            throw new ClassNotFoundException('class not exists: ' . $class, $class, $e);
376
+            throw new ClassNotFoundException('class not exists: '.$class, $class, $e);
377 377
         }
378 378
 
379 379
         if ($reflect->hasMethod('__make')) {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             } elseif ($param->isDefaultValueAvailable()) {
453 453
                 $args[] = $param->getDefaultValue();
454 454
             } else {
455
-                throw new InvalidArgumentException('method param miss:' . $name);
455
+                throw new InvalidArgumentException('method param miss:'.$name);
456 456
             }
457 457
         }
458 458
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      */
471 471
     public static function factory(string $name, string $namespace = '', ...$args)
472 472
     {
473
-        $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name);
473
+        $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name);
474 474
 
475 475
         return Container::getInstance()->invokeClass($class, $args);
476 476
     }
Please login to merge, or discard this patch.
src/think/route/dispatch/Url.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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\route\dispatch;
14 14
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         if ($bind && preg_match('/^[a-z]/is', $bind)) {
48 48
             $bind = str_replace('/', $depr, $bind);
49 49
             // 如果有域名绑定
50
-            $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
50
+            $url = $bind.('.' != substr($bind, -1) ? $depr : '').ltrim($url, $depr);
51 51
         }
52 52
 
53 53
         $path = $this->rule->parseUrlPath($url);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $controller = !empty($path) ? array_shift($path) : null;
60 60
 
61 61
         if ($controller && !preg_match('/^[A-Za-z0-9][\w|\.]*$/', $controller)) {
62
-            throw new HttpException(404, 'controller not exists:' . $controller);
62
+            throw new HttpException(404, 'controller not exists:'.$controller);
63 63
         }
64 64
 
65 65
         // 解析操作
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
         // 解析额外参数
70 70
         if ($path) {
71
-            preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
71
+            preg_replace_callback('/(\w+)\|([^\|]+)/', function($match) use (&$var) {
72 72
                 $var[$match[1]] = strip_tags($match[2]);
73 73
             }, implode('|', $path));
74 74
         }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $route = [$controller, $action];
87 87
 
88 88
         if ($this->hasDefinedRoute($route)) {
89
-            throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url));
89
+            throw new HttpException(404, 'invalid request:'.str_replace('|', $depr, $url));
90 90
         }
91 91
 
92 92
         return $route;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         [$controller, $action] = $route;
104 104
 
105 105
         // 检查地址是否被定义过路由
106
-        $name = strtolower(Str::studly($controller) . '/' . $action);
106
+        $name = strtolower(Str::studly($controller).'/'.$action);
107 107
 
108 108
         $host   = $this->request->host(true);
109 109
         $method = $this->request->method();
Please login to merge, or discard this patch.
tests/CacheTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -126,10 +126,10 @@
 block discarded – undo
126 126
         $redis->shouldReceive("del")->once()->with('baz')->andReturnTrue();
127 127
         $redis->shouldReceive("flushDB")->once()->andReturnTrue();
128 128
         $redis->shouldReceive("set")->once()->with('bar', serialize('foobar'))->andReturnTrue();
129
-        $redis->shouldReceive("sAdd")->once()->with('tag:' . md5('foo'), 'bar')->andReturnTrue();
130
-        $redis->shouldReceive("sMembers")->once()->with('tag:' . md5('foo'))->andReturn(['bar']);
129
+        $redis->shouldReceive("sAdd")->once()->with('tag:'.md5('foo'), 'bar')->andReturnTrue();
130
+        $redis->shouldReceive("sMembers")->once()->with('tag:'.md5('foo'))->andReturn(['bar']);
131 131
         $redis->shouldReceive("del")->once()->with(['bar'])->andReturnTrue();
132
-        $redis->shouldReceive("del")->once()->with('tag:' . md5('foo'))->andReturnTrue();
132
+        $redis->shouldReceive("del")->once()->with('tag:'.md5('foo'))->andReturnTrue();
133 133
 
134 134
         $this->cache->set('foo', 5);
135 135
         $this->cache->inc('foo');
Please login to merge, or discard this patch.
src/think/view/driver/Php.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
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,7 +78,7 @@  discard block
 block discarded – undo
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;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $this->content = $content;
101 101
 
102 102
         extract($data, EXTR_OVERWRITE);
103
-        eval('?>' . $this->content);
103
+        eval('?>'.$this->content);
104 104
     }
105 105
 
106 106
     /**
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
             $appName = isset($app) ? $app : $this->app->http->getName();
126 126
             $view    = $this->config['view_dir_name'];
127 127
 
128
-            if (is_dir($this->app->getAppPath() . $view)) {
129
-                $path = isset($app) ? $this->app->getBasePath() . ($appName ? $appName . DIRECTORY_SEPARATOR : '') . $view . DIRECTORY_SEPARATOR : $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR;
128
+            if (is_dir($this->app->getAppPath().$view)) {
129
+                $path = isset($app) ? $this->app->getBasePath().($appName ? $appName.DIRECTORY_SEPARATOR : '').$view.DIRECTORY_SEPARATOR : $this->app->getAppPath().$view.DIRECTORY_SEPARATOR;
130 130
             } else {
131
-                $path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($appName ? $appName . DIRECTORY_SEPARATOR : '');
131
+                $path = $this->app->getRootPath().$view.DIRECTORY_SEPARATOR.($appName ? $appName.DIRECTORY_SEPARATOR : '');
132 132
             }
133 133
         }
134 134
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             $controller = $request->controller();
140 140
             if (strpos($controller, '.')) {
141 141
                 $pos        = strrpos($controller, '.');
142
-                $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1));
142
+                $controller = substr($controller, 0, $pos).'.'.Str::snake(substr($controller, $pos + 1));
143 143
             } else {
144 144
                 $controller = Str::snake($controller);
145 145
             }
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
                         $template = Str::snake($request->action());
156 156
                     }
157 157
 
158
-                    $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template;
158
+                    $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template;
159 159
                 } elseif (false === strpos($template, $depr)) {
160
-                    $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template;
160
+                    $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template;
161 161
                 }
162 162
             }
163 163
         } else {
164 164
             $template = str_replace(['/', ':'], $depr, substr($template, 1));
165 165
         }
166 166
 
167
-        return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.');
167
+        return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.');
168 168
     }
169 169
 
170 170
     /**
Please login to merge, or discard this patch.