@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | { |
32 | 32 | $app = $input->getArgument('app'); |
33 | 33 | |
34 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
34 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
35 | 35 | $output->writeln('<error>Miss app name!</error>'); |
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | 39 | if ($app) { |
40 | - $runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR; |
|
41 | - $appPath = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR; |
|
42 | - $namespace = 'app\\' . $app; |
|
40 | + $runtimePath = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR; |
|
41 | + $appPath = $this->app->getBasePath().$app.DIRECTORY_SEPARATOR; |
|
42 | + $namespace = 'app\\'.$app; |
|
43 | 43 | } else { |
44 | - $runtimePath = $this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR; |
|
44 | + $runtimePath = $this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR; |
|
45 | 45 | $appPath = $this->app->getBasePath(); |
46 | 46 | $namespace = 'app'; |
47 | 47 | } |
48 | 48 | |
49 | - $schemaPath = $runtimePath . 'schema' . DIRECTORY_SEPARATOR; |
|
49 | + $schemaPath = $runtimePath.'schema'.DIRECTORY_SEPARATOR; |
|
50 | 50 | if (!is_dir($schemaPath)) { |
51 | 51 | mkdir($schemaPath, 0755, true); |
52 | 52 | } |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | $tables = $this->app->db->getConnection()->getTables($dbName); |
64 | 64 | } else { |
65 | 65 | |
66 | - $path = $appPath . 'model'; |
|
66 | + $path = $appPath.'model'; |
|
67 | 67 | $list = is_dir($path) ? scandir($path) : []; |
68 | 68 | |
69 | 69 | foreach ($list as $file) { |
70 | 70 | if (0 === strpos($file, '.')) { |
71 | 71 | continue; |
72 | 72 | } |
73 | - $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); |
|
73 | + $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME); |
|
74 | 74 | $this->buildModelSchema($schemaPath, $class); |
75 | 75 | } |
76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $db = isset($dbName) ? $dbName . '.' : ''; |
|
81 | + $db = isset($dbName) ? $dbName.'.' : ''; |
|
82 | 82 | $this->buildDataBaseSchema($schemaPath, $tables, $db); |
83 | 83 | |
84 | 84 | $output->writeln('<info>Succeed!</info>'); |
@@ -94,27 +94,27 @@ discard block |
||
94 | 94 | |
95 | 95 | $table = $model->getTable(); |
96 | 96 | $dbName = $model->getConfig('database'); |
97 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
97 | + $content = '<?php '.PHP_EOL.'return '; |
|
98 | 98 | $info = $model->db()->getConnection()->getFields($table); |
99 | - $content .= var_export($info, true) . ';'; |
|
99 | + $content .= var_export($info, true).';'; |
|
100 | 100 | |
101 | - file_put_contents($path . $dbName . '.' . $table . '.php', $content); |
|
101 | + file_put_contents($path.$dbName.'.'.$table.'.php', $content); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | protected function buildDataBaseSchema(string $path, array $tables, string $db): void |
106 | 106 | { |
107 | 107 | if ('' == $db) { |
108 | - $dbName = $this->app->db->getConfig('database') . '.'; |
|
108 | + $dbName = $this->app->db->getConfig('database').'.'; |
|
109 | 109 | } else { |
110 | 110 | $dbName = $db; |
111 | 111 | } |
112 | 112 | |
113 | 113 | foreach ($tables as $table) { |
114 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
115 | - $info = $this->app->db->getConnection()->getFields($db . $table); |
|
116 | - $content .= var_export($info, true) . ';'; |
|
117 | - file_put_contents($path . $dbName . $table . '.php', $content); |
|
114 | + $content = '<?php '.PHP_EOL.'return '; |
|
115 | + $info = $this->app->db->getConnection()->getFields($db.$table); |
|
116 | + $content .= var_export($info, true).';'; |
|
117 | + file_put_contents($path.$dbName.$table.'.php', $content); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | } |
@@ -8,7 +8,7 @@ discard block |
||
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\console\command; |
14 | 14 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | $force = $this->input->getOption('force'); |
31 | 31 | |
32 | - if (is_file($path = $this->app->getRootPath() . 'vendor/composer/installed.json')) { |
|
32 | + if (is_file($path = $this->app->getRootPath().'vendor/composer/installed.json')) { |
|
33 | 33 | $packages = json_decode(@file_get_contents($path), true); |
34 | 34 | |
35 | 35 | foreach ($packages as $package) { |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | |
39 | 39 | if (!empty($package['extra']['think']['config'])) { |
40 | 40 | |
41 | - $installPath = $this->app->getRootPath() . 'vendor/' . $package['name'] . DIRECTORY_SEPARATOR; |
|
41 | + $installPath = $this->app->getRootPath().'vendor/'.$package['name'].DIRECTORY_SEPARATOR; |
|
42 | 42 | |
43 | 43 | foreach ((array) $package['extra']['think']['config'] as $name => $file) { |
44 | 44 | |
45 | - $target = $configDir . $name . '.php'; |
|
46 | - $source = $installPath . $file; |
|
45 | + $target = $configDir.$name.'.php'; |
|
46 | + $source = $installPath.$file; |
|
47 | 47 | |
48 | 48 | if (is_file($target) && !$force) { |
49 | 49 | $this->output->info("File {$target} exist!"); |
@@ -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 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | foreach ($events as $event) { |
216 | 216 | $name = false !== strpos($event, '\\') ? substr(strrchr($event, '\\'), 1) : $event; |
217 | - $method = 'on' . $name; |
|
217 | + $method = 'on'.$name; |
|
218 | 218 | |
219 | 219 | if (method_exists($observer, $method)) { |
220 | 220 | $this->listen($event, [$observer, $method]); |
@@ -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 助手函数 |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); |
222 | 222 | |
223 | 223 | if (PHP_SAPI == 'cli') { |
224 | - $output = PHP_EOL . $output . PHP_EOL; |
|
224 | + $output = PHP_EOL.$output.PHP_EOL; |
|
225 | 225 | } else { |
226 | 226 | if (!extension_loaded('xdebug')) { |
227 | 227 | $output = htmlspecialchars($output, ENT_SUBSTITUTE); |
228 | 228 | } |
229 | - $output = '<pre>' . $output . '</pre>'; |
|
229 | + $output = '<pre>'.$output.'</pre>'; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | echo $output; |
@@ -305,8 +305,7 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | return isset($has) ? |
308 | - request()->has($key, $method) : |
|
309 | - request()->$method($key, $default, $filter); |
|
308 | + request()->has($key, $method) : request()->$method($key, $default, $filter); |
|
310 | 309 | } |
311 | 310 | } |
312 | 311 | |
@@ -383,7 +382,7 @@ discard block |
||
383 | 382 | function parse_name(string $name, int $type = 0, bool $ucfirst = true): string |
384 | 383 | { |
385 | 384 | if ($type) { |
386 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
385 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
387 | 386 | return strtoupper($match[1]); |
388 | 387 | }, $name); |
389 | 388 | |
@@ -488,7 +487,7 @@ discard block |
||
488 | 487 | { |
489 | 488 | $token = Request::buildToken($name, $type); |
490 | 489 | |
491 | - return '<input type="hidden" name="' . $name . '" value="' . $token . '" />'; |
|
490 | + return '<input type="hidden" name="'.$name.'" value="'.$token.'" />'; |
|
492 | 491 | } |
493 | 492 | } |
494 | 493 | |
@@ -503,7 +502,7 @@ discard block |
||
503 | 502 | { |
504 | 503 | $token = Request::buildToken($name, $type); |
505 | 504 | |
506 | - return '<meta name="csrf-token" content="' . $token . '">'; |
|
505 | + return '<meta name="csrf-token" content="'.$token.'">'; |
|
507 | 506 | } |
508 | 507 | } |
509 | 508 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function testConnect($config) |
24 | 24 | { |
25 | - $mysql = m::mock('overload:' . Mysql::class); |
|
25 | + $mysql = m::mock('overload:'.Mysql::class); |
|
26 | 26 | |
27 | 27 | $db = new Db($config); |
28 | 28 | } |
@@ -107,27 +107,27 @@ discard block |
||
107 | 107 | |
108 | 108 | public function testPath() |
109 | 109 | { |
110 | - $rootPath = __DIR__ . DIRECTORY_SEPARATOR; |
|
110 | + $rootPath = __DIR__.DIRECTORY_SEPARATOR; |
|
111 | 111 | |
112 | 112 | $app = new App($rootPath); |
113 | 113 | |
114 | 114 | $this->assertEquals($rootPath, $app->getRootPath()); |
115 | 115 | |
116 | - $this->assertEquals(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR, $app->getThinkPath()); |
|
116 | + $this->assertEquals(dirname(__DIR__).DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, $app->getThinkPath()); |
|
117 | 117 | |
118 | - $this->assertEquals($rootPath . 'app' . DIRECTORY_SEPARATOR, $app->getAppPath()); |
|
118 | + $this->assertEquals($rootPath.'app'.DIRECTORY_SEPARATOR, $app->getAppPath()); |
|
119 | 119 | |
120 | - $appPath = $rootPath . 'app' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR; |
|
120 | + $appPath = $rootPath.'app'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR; |
|
121 | 121 | $app->setAppPath($appPath); |
122 | 122 | $this->assertEquals($appPath, $app->getAppPath()); |
123 | 123 | |
124 | - $this->assertEquals($rootPath . 'app' . DIRECTORY_SEPARATOR, $app->getBasePath()); |
|
124 | + $this->assertEquals($rootPath.'app'.DIRECTORY_SEPARATOR, $app->getBasePath()); |
|
125 | 125 | |
126 | - $this->assertEquals($rootPath . 'config' . DIRECTORY_SEPARATOR, $app->getConfigPath()); |
|
126 | + $this->assertEquals($rootPath.'config'.DIRECTORY_SEPARATOR, $app->getConfigPath()); |
|
127 | 127 | |
128 | - $this->assertEquals($rootPath . 'runtime' . DIRECTORY_SEPARATOR, $app->getRuntimePath()); |
|
128 | + $this->assertEquals($rootPath.'runtime'.DIRECTORY_SEPARATOR, $app->getRuntimePath()); |
|
129 | 129 | |
130 | - $runtimePath = $rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR; |
|
130 | + $runtimePath = $rootPath.'runtime'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR; |
|
131 | 131 | $app->setRuntimePath($runtimePath); |
132 | 132 | $this->assertEquals($runtimePath, $app->getRuntimePath()); |
133 | 133 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function prepareAppForInitialize(vfsStreamDirectory $root, $debug = true) |
141 | 141 | { |
142 | - $rootPath = $root->url() . DIRECTORY_SEPARATOR; |
|
142 | + $rootPath = $root->url().DIRECTORY_SEPARATOR; |
|
143 | 143 | |
144 | 144 | $app = new App($rootPath); |
145 | 145 | |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | |
149 | 149 | $app->instance($initializer->mockery_getName(), $initializer); |
150 | 150 | |
151 | - (function () use ($initializer) { |
|
151 | + (function() use ($initializer) { |
|
152 | 152 | $this->initializers = [$initializer->mockery_getName()]; |
153 | 153 | })->call($app); |
154 | 154 | |
155 | 155 | $env = m::mock(Env::class); |
156 | - $env->shouldReceive('load')->once()->with($rootPath . '.env'); |
|
156 | + $env->shouldReceive('load')->once()->with($rootPath.'.env'); |
|
157 | 157 | $env->shouldReceive('get')->once()->with('config_ext', '.php')->andReturn('.php'); |
158 | 158 | $env->shouldReceive('get')->once()->with('app_debug')->andReturn($debug); |
159 | 159 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | $route = m::mock(Route::class); |
50 | 50 | |
51 | - $route->shouldReceive('dispatch')->withArgs(function ($req, $withRoute) use ($request) { |
|
51 | + $route->shouldReceive('dispatch')->withArgs(function($req, $withRoute) use ($request) { |
|
52 | 52 | if ($withRoute) { |
53 | 53 | $withRoute(); |
54 | 54 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | |
81 | 81 | $this->http->multi(false); |
82 | 82 | |
83 | - $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); |
|
84 | - $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); |
|
83 | + $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url().DIRECTORY_SEPARATOR); |
|
84 | + $this->app->shouldReceive('getRootPath')->andReturn($root->url().DIRECTORY_SEPARATOR); |
|
85 | 85 | |
86 | 86 | $request = m::mock(Request::class)->makePartial(); |
87 | 87 | $response = m::mock(Response::class)->makePartial(); |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | |
141 | 141 | $this->app->shouldReceive('get')->with('config')->andReturn($config); |
142 | 142 | |
143 | - $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); |
|
144 | - $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); |
|
145 | - $this->app->shouldReceive('getConfigPath')->andReturn($root->getChild('config')->url() . DIRECTORY_SEPARATOR); |
|
143 | + $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url().DIRECTORY_SEPARATOR); |
|
144 | + $this->app->shouldReceive('getRootPath')->andReturn($root->url().DIRECTORY_SEPARATOR); |
|
145 | + $this->app->shouldReceive('getConfigPath')->andReturn($root->getChild('config')->url().DIRECTORY_SEPARATOR); |
|
146 | 146 | |
147 | 147 | $response = m::mock(Response::class)->makePartial(); |
148 | 148 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $this->assertTrue($this->http->isBindDomain()); |
175 | 175 | } |
176 | 176 | if ($path) { |
177 | - $this->assertEquals(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $this->app->getAppPath()); |
|
177 | + $this->assertEquals(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR, $this->app->getAppPath()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 |
@@ -8,7 +8,7 @@ |
||
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 |
@@ -8,7 +8,7 @@ |
||
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 |