Completed
Push — 6.0 ( 40cdd9...30a204 )
by liu
06:40
created
src/think/response/Json.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/cache/Driver.php 1 patch
Spacing   +8 added lines, -8 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;
14 14
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function getCacheKey(string $name): string
86 86
     {
87
-        return $this->options['prefix'] . $name;
87
+        return $this->options['prefix'].$name;
88 88
     }
89 89
 
90 90
     /**
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 
146 146
         $time = time();
147 147
 
148
-        while ($time + 5 > time() && $this->has($name . '_lock')) {
148
+        while ($time + 5 > time() && $this->has($name.'_lock')) {
149 149
             // 存在锁定则等待
150 150
             usleep(200000);
151 151
         }
152 152
 
153 153
         try {
154 154
             // 锁定
155
-            $this->set($name . '_lock', true);
155
+            $this->set($name.'_lock', true);
156 156
 
157 157
             if ($value instanceof Closure) {
158 158
                 // 获取缓存数据
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
             $this->set($name, $value, $expire);
164 164
 
165 165
             // 解锁
166
-            $this->delete($name . '_lock');
166
+            $this->delete($name.'_lock');
167 167
         } catch (Exception | throwable $e) {
168
-            $this->delete($name . '_lock');
168
+            $this->delete($name.'_lock');
169 169
             throw $e;
170 170
         }
171 171
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $key  = implode('-', $name);
185 185
 
186 186
         if (!isset($this->tag[$key])) {
187
-            $name = array_map(function ($val) {
187
+            $name = array_map(function($val) {
188 188
                 return $this->getTagKey($val);
189 189
             }, $name);
190 190
             $this->tag[$key] = new TagSet($name, $this);
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function getTagKey(string $tag): string
214 214
     {
215
-        return $this->options['tag_prefix'] . md5($tag);
215
+        return $this->options['tag_prefix'].md5($tag);
216 216
     }
217 217
 
218 218
     /**
Please login to merge, or discard this patch.
src/think/Console.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 // +----------------------------------------------------------------------
7 7
 // | Author: zhangyajun <[email protected]>
8 8
 // +----------------------------------------------------------------------
9
-declare (strict_types = 1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace think;
12 12
 
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
     public function findNamespace(string $namespace): string
462 462
     {
463 463
         $allNamespaces = $this->getNamespaces();
464
-        $expr          = preg_replace_callback('{([^:]+|)}', function ($matches) {
465
-            return preg_quote($matches[1]) . '[^:]*';
464
+        $expr          = preg_replace_callback('{([^:]+|)}', function($matches) {
465
+            return preg_quote($matches[1]).'[^:]*';
466 466
         }, $namespace);
467
-        $namespaces    = preg_grep('{^' . $expr . '}', $allNamespaces);
467
+        $namespaces    = preg_grep('{^'.$expr.'}', $allNamespaces);
468 468
 
469 469
         if (empty($namespaces)) {
470 470
             $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
@@ -501,13 +501,13 @@  discard block
 block discarded – undo
501 501
     {
502 502
         $allCommands = array_keys($this->commands);
503 503
 
504
-        $expr = preg_replace_callback('{([^:]+|)}', function ($matches) {
505
-            return preg_quote($matches[1]) . '[^:]*';
504
+        $expr = preg_replace_callback('{([^:]+|)}', function($matches) {
505
+            return preg_quote($matches[1]).'[^:]*';
506 506
         }, $name);
507 507
 
508
-        $commands = preg_grep('{^' . $expr . '}', $allCommands);
508
+        $commands = preg_grep('{^'.$expr.'}', $allCommands);
509 509
 
510
-        if (empty($commands) || count(preg_grep('{^' . $expr . '$}', $commands)) < 1) {
510
+        if (empty($commands) || count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
511 511
             if (false !== $pos = strrpos($name, ':')) {
512 512
                 $this->findNamespace(substr($name, 0, $pos));
513 513
             }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
             }
702 702
         }
703 703
 
704
-        $alternatives = array_filter($alternatives, function ($lev) use ($threshold) {
704
+        $alternatives = array_filter($alternatives, function($lev) use ($threshold) {
705 705
             return $lev < 2 * $threshold;
706 706
         });
707 707
         asort($alternatives);
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 
723 723
         foreach ($parts as $part) {
724 724
             if (count($namespaces)) {
725
-                $namespaces[] = end($namespaces) . ':' . $part;
725
+                $namespaces[] = end($namespaces).':'.$part;
726 726
             } else {
727 727
                 $namespaces[] = $part;
728 728
             }
Please login to merge, or discard this patch.
tests/ContainerTest.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         Container::setInstance($container);
59 59
 
60
-        $container->bind('name', function () {
60
+        $container->bind('name', function() {
61 61
             return 'Taylor';
62 62
         });
63 63
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $this->expectExceptionMessage('class not exists: name');
75 75
         $container->get('name');
76 76
 
77
-        $container->bind('name', function () {
77
+        $container->bind('name', function() {
78 78
             return 'Taylor';
79 79
         });
80 80
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $container = new Container;
87 87
 
88
-        $container->bind('name', function () {
88
+        $container->bind('name', function() {
89 89
             return 'Taylor';
90 90
         });
91 91
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $container = new Container;
102 102
 
103
-        $container->bind('name', function () {
103
+        $container->bind('name', function() {
104 104
             return 'Taylor';
105 105
         });
106 106
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
         $this->assertSame($object, Container::getInstance());
194 194
 
195
-        Container::setInstance(function () {
195
+        Container::setInstance(function() {
196 196
             return $this;
197 197
         });
198 198
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $this->expectException(Exception::class);
213 213
         $this->expectExceptionMessageRegExp('/function not exists: {Closure}@.+#L\d+-\d+/');
214 214
         $container = new Container;
215
-        $container->invokeFunction(function () {
215
+        $container->invokeFunction(function() {
216 216
             throw new \ReflectionException('test exception');
217 217
         });
218 218
     }
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
 
232 232
         $container->invokeMethod([$stub, 'some']);
233 233
 
234
-        $this->assertSame($container, $container->invokeMethod(Taylor::class . '::test'));
234
+        $this->assertSame($container, $container->invokeMethod(Taylor::class.'::test'));
235 235
 
236 236
         $reflect = new ReflectionMethod($container, 'exists');
237 237
 
238 238
         $this->assertTrue($container->invokeReflectMethod($container, $reflect, [Container::class]));
239 239
 
240
-        $this->assertSame($container, $container->invoke(function (Container $container) {
240
+        $this->assertSame($container, $container->invoke(function(Container $container) {
241 241
             return $container;
242 242
         }));
243 243
 
244
-        $this->assertSame($container, $container->invoke(Taylor::class . '::test'));
244
+        $this->assertSame($container, $container->invoke(Taylor::class.'::test'));
245 245
 
246 246
         $object = $container->invokeClass(SomeClass::class);
247 247
         $this->assertInstanceOf(SomeClass::class, $object);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
         $stdClass = new stdClass();
251 251
 
252
-        $container->invoke(function (Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) {
252
+        $container->invoke(function(Container $container, stdClass $stdObject, $key1, $lowKey, $key2 = 'default') use ($stdClass) {
253 253
             $this->assertEquals('value1', $key1);
254 254
             $this->assertEquals('default', $key2);
255 255
             $this->assertEquals('value2', $lowKey);
Please login to merge, or discard this patch.
src/think/route/Domain.php 1 patch
Spacing   +3 added lines, -3 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;
14 14
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             $this->parseUrlParams($array[2], $param);
157 157
         }
158 158
 
159
-        return new CallbackDispatch($request, $this, [$namespace . '\\' . Str::studly($class), $method], $param);
159
+        return new CallbackDispatch($request, $this, [$namespace.'\\'.Str::studly($class), $method], $param);
160 160
     }
161 161
 
162 162
     /**
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             $this->parseUrlParams($array[1], $param);
178 178
         }
179 179
 
180
-        return new ControllerDispatch($request, $this, $controller . '/' . $action, $param);
180
+        return new ControllerDispatch($request, $this, $controller.'/'.$action, $param);
181 181
     }
182 182
 
183 183
 }
Please login to merge, or discard this patch.
src/think/service/ModelService.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: yunwuxin <[email protected]>
10 10
 // +----------------------------------------------------------------------
11
-declare (strict_types = 1);
11
+declare(strict_types=1);
12 12
 
13 13
 namespace think\service;
14 14
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         Model::setDb($this->app->db);
26 26
         Model::setEvent($this->app->event);
27 27
         Model::setInvoker([$this->app, 'invoke']);
28
-        Model::maker(function (Model $model) {
28
+        Model::maker(function(Model $model) {
29 29
             $config = $this->app->config;
30 30
 
31 31
             $isAutoWriteTimestamp = $model->getAutoWriteTimestamp();
Please login to merge, or discard this patch.
src/think/Container.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             return $this->make($abstract);
132 132
         }
133 133
 
134
-        throw new ClassNotFoundException('class not exists: ' . $abstract, $abstract);
134
+        throw new ClassNotFoundException('class not exists: '.$abstract, $abstract);
135 135
     }
136 136
 
137 137
     /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             } else {
302 302
                 $function .= '()';
303 303
             }
304
-            throw new Exception('function not exists: ' . $function, 0, $e);
304
+            throw new Exception('function not exists: '.$function, 0, $e);
305 305
         }
306 306
     }
307 307
 
@@ -334,12 +334,12 @@  discard block
 block discarded – undo
334 334
         } catch (ReflectionException $e) {
335 335
             if (is_array($method)) {
336 336
                 $class    = is_object($method[0]) ? get_class($method[0]) : $method[0];
337
-                $callback = $class . '::' . $method[1];
337
+                $callback = $class.'::'.$method[1];
338 338
             } else {
339 339
                 $callback = $method;
340 340
             }
341 341
 
342
-            throw new Exception('method not exists: ' . $callback . '()', 0, $e);
342
+            throw new Exception('method not exists: '.$callback.'()', 0, $e);
343 343
         }
344 344
     }
345 345
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 
407 407
             return $object;
408 408
         } catch (ReflectionException $e) {
409
-            throw new ClassNotFoundException('class not exists: ' . $class, $class, $e);
409
+            throw new ClassNotFoundException('class not exists: '.$class, $class, $e);
410 410
         }
411 411
     }
412 412
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             } elseif ($param->isDefaultValueAvailable()) {
468 468
                 $args[] = $param->getDefaultValue();
469 469
             } else {
470
-                throw new InvalidArgumentException('method param miss:' . $name);
470
+                throw new InvalidArgumentException('method param miss:'.$name);
471 471
             }
472 472
         }
473 473
 
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
      */
486 486
     public static function factory(string $name, string $namespace = '', ...$args)
487 487
     {
488
-        $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name);
488
+        $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name);
489 489
 
490 490
         if (class_exists($class)) {
491 491
             return Container::getInstance()->invokeClass($class, $args);
492 492
         }
493 493
 
494
-        throw new ClassNotFoundException('class not exists:' . $class, $class);
494
+        throw new ClassNotFoundException('class not exists:'.$class, $class);
495 495
     }
496 496
 
497 497
     /**
Please login to merge, or discard this patch.
src/think/console/command/optimize/Schema.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             $tables = $this->app->db->getConnection()->getTables($dbName);
50 50
         } else {
51 51
             if ($app) {
52
-                $appPath   = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR;
53
-                $namespace = 'app\\' . $app;
52
+                $appPath   = $this->app->getBasePath().$app.DIRECTORY_SEPARATOR;
53
+                $namespace = 'app\\'.$app;
54 54
             } else {
55 55
                 $appPath   = $this->app->getBasePath();
56 56
                 $namespace = 'app';
57 57
             }
58 58
 
59
-            $path = $appPath . 'model';
59
+            $path = $appPath.'model';
60 60
             $list = is_dir($path) ? scandir($path) : [];
61 61
 
62 62
             foreach ($list as $file) {
63 63
                 if (0 === strpos($file, '.')) {
64 64
                     continue;
65 65
                 }
66
-                $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME);
66
+                $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME);
67 67
                 $this->buildModelSchema($class);
68 68
             }
69 69
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             return;
72 72
         }
73 73
 
74
-        $db = isset($dbName) ? $dbName . '.' : '';
74
+        $db = isset($dbName) ? $dbName.'.' : '';
75 75
         $this->buildDataBaseSchema($schemaPath, $tables, $db);
76 76
 
77 77
         $output->writeln('<info>Succeed!</info>');
@@ -90,27 +90,27 @@  discard block
 block discarded – undo
90 90
             if (!is_dir($path)) {
91 91
                 mkdir($path, 0755, true);
92 92
             }
93
-            $content = '<?php ' . PHP_EOL . 'return ';
93
+            $content = '<?php '.PHP_EOL.'return ';
94 94
             $info    = $model->db()->getConnection()->getTableFieldsInfo($table);
95
-            $content .= var_export($info, true) . ';';
95
+            $content .= var_export($info, true).';';
96 96
 
97
-            file_put_contents($path . $dbName . '.' . $table . '.php', $content);
97
+            file_put_contents($path.$dbName.'.'.$table.'.php', $content);
98 98
         }
99 99
     }
100 100
 
101 101
     protected function buildDataBaseSchema(string $path, array $tables, string $db): void
102 102
     {
103 103
         if ('' == $db) {
104
-            $dbName = $this->app->db->getConnection()->getConfig('database') . '.';
104
+            $dbName = $this->app->db->getConnection()->getConfig('database').'.';
105 105
         } else {
106 106
             $dbName = $db;
107 107
         }
108 108
 
109 109
         foreach ($tables as $table) {
110
-            $content = '<?php ' . PHP_EOL . 'return ';
111
-            $info    = $this->app->db->getConnection()->getTableFieldsInfo($db . $table);
112
-            $content .= var_export($info, true) . ';';
113
-            file_put_contents($path . $dbName . $table . '.php', $content);
110
+            $content = '<?php '.PHP_EOL.'return ';
111
+            $info    = $this->app->db->getConnection()->getTableFieldsInfo($db.$table);
112
+            $content .= var_export($info, true).';';
113
+            file_put_contents($path.$dbName.$table.'.php', $content);
114 114
         }
115 115
     }
116 116
 }
Please login to merge, or discard this patch.
src/think/route/RuleItem.php 1 patch
Spacing   +11 added lines, -11 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;
14 14
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $rule = '/' != $rule ? ltrim($rule, '/') : '';
135 135
 
136 136
         if ($this->parent && $prefix = $this->parent->getFullName()) {
137
-            $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : '');
137
+            $rule = $prefix.($rule ? '/'.ltrim($rule, '/') : '');
138 138
         }
139 139
 
140 140
         if (false !== strpos($rule, ':')) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         if (isset($option['ext'])) {
239 239
             // 路由ext参数 优先于系统配置的URL伪静态后缀参数
240
-            $url = preg_replace('/\.(' . $request->ext() . ')$/i', '', $url);
240
+            $url = preg_replace('/\.('.$request->ext().')$/i', '', $url);
241 241
         }
242 242
 
243 243
         return $url;
@@ -261,38 +261,38 @@  discard block
 block discarded – undo
261 261
         $pattern = array_merge($this->parent->getPattern(), $this->pattern);
262 262
 
263 263
         // 检查完整规则定义
264
-        if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . ($completeMatch ? '$' : '') . '/', str_replace('|', $depr, $url))) {
264
+        if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^'.$pattern['__url__'].($completeMatch ? '$' : '').'/', str_replace('|', $depr, $url))) {
265 265
             return false;
266 266
         }
267 267
 
268 268
         $var  = [];
269
-        $url  = $depr . str_replace('|', $depr, $url);
270
-        $rule = $depr . str_replace('/', $depr, $this->rule);
269
+        $url  = $depr.str_replace('|', $depr, $url);
270
+        $rule = $depr.str_replace('/', $depr, $this->rule);
271 271
 
272 272
         if ($depr == $rule && $depr != $url) {
273 273
             return false;
274 274
         }
275 275
 
276 276
         if (false === strpos($rule, '<')) {
277
-            if (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule . $depr, $url . $depr, strlen($rule . $depr)))) {
277
+            if (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule.$depr, $url.$depr, strlen($rule.$depr)))) {
278 278
                 return $var;
279 279
             }
280 280
             return false;
281 281
         }
282 282
 
283
-        $slash = preg_quote('/-' . $depr, '/');
283
+        $slash = preg_quote('/-'.$depr, '/');
284 284
 
285
-        if ($matchRule = preg_split('/[' . $slash . ']?<\w+\??>/', $rule, 2)) {
285
+        if ($matchRule = preg_split('/['.$slash.']?<\w+\??>/', $rule, 2)) {
286 286
             if ($matchRule[0] && 0 !== strncasecmp($rule, $url, strlen($matchRule[0]))) {
287 287
                 return false;
288 288
             }
289 289
         }
290 290
 
291
-        if (preg_match_all('/[' . $slash . ']?<?\w+\??>?/', $rule, $matches)) {
291
+        if (preg_match_all('/['.$slash.']?<?\w+\??>?/', $rule, $matches)) {
292 292
             $regex = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $completeMatch);
293 293
 
294 294
             try {
295
-                if (!preg_match('/^' . $regex . '/u', $url, $match)) {
295
+                if (!preg_match('/^'.$regex.'/u', $url, $match)) {
296 296
                     return false;
297 297
                 }
298 298
             } catch (\Exception $e) {
Please login to merge, or discard this patch.