@@ -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 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function __construct(App $app) |
| 58 | 58 | { |
| 59 | 59 | $this->app = $app; |
| 60 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
| 60 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | $this->initialize(); |
| 174 | 174 | |
| 175 | 175 | // 加载全局中间件 |
| 176 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
| 177 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
| 176 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
| 177 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($this->multi) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | // 监听HttpRun |
| 188 | 188 | $this->app->event->trigger('HttpRun'); |
| 189 | 189 | |
| 190 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
| 190 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
| 191 | 191 | $this->loadRoutes(); |
| 192 | 192 | } : null; |
| 193 | 193 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $routePath = $this->getRoutePath(); |
| 206 | 206 | |
| 207 | 207 | if (is_dir($routePath)) { |
| 208 | - $files = glob($routePath . '*.php'); |
|
| 208 | + $files = glob($routePath.'*.php'); |
|
| 209 | 209 | foreach ($files as $file) { |
| 210 | 210 | include $file; |
| 211 | 211 | } |
@@ -221,11 +221,11 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | protected function getRoutePath(): string |
| 223 | 223 | { |
| 224 | - if ($this->isMulti() && is_dir($this->app->getAppPath() . 'route')) { |
|
| 225 | - return $this->app->getAppPath() . 'route' . DIRECTORY_SEPARATOR; |
|
| 224 | + if ($this->isMulti() && is_dir($this->app->getAppPath().'route')) { |
|
| 225 | + return $this->app->getAppPath().'route'.DIRECTORY_SEPARATOR; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
| 228 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $appName = $map[$name]; |
| 311 | 311 | } |
| 312 | 312 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
| 313 | - throw new HttpException(404, 'app not exists:' . $name); |
|
| 313 | + throw new HttpException(404, 'app not exists:'.$name); |
|
| 314 | 314 | } elseif ($name && isset($map['*'])) { |
| 315 | 315 | $appName = $map['*']; |
| 316 | 316 | } else { |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if ($name) { |
| 321 | - $this->app->request->setRoot('/' . $name); |
|
| 321 | + $this->app->request->setRoot('/'.$name); |
|
| 322 | 322 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -338,41 +338,41 @@ discard block |
||
| 338 | 338 | { |
| 339 | 339 | $this->name = $appName; |
| 340 | 340 | $this->app->request->setApp($appName); |
| 341 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
| 342 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
| 341 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
| 342 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
| 343 | 343 | |
| 344 | 344 | //加载app文件 |
| 345 | 345 | if (is_dir($this->app->getAppPath())) { |
| 346 | 346 | $appPath = $this->app->getAppPath(); |
| 347 | 347 | |
| 348 | - if (is_file($appPath . 'common.php')) { |
|
| 349 | - include_once $appPath . 'common.php'; |
|
| 348 | + if (is_file($appPath.'common.php')) { |
|
| 349 | + include_once $appPath.'common.php'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $configPath = $this->app->getConfigPath(); |
| 353 | 353 | |
| 354 | 354 | $files = []; |
| 355 | 355 | |
| 356 | - if (is_dir($configPath . $appName)) { |
|
| 357 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 358 | - } elseif (is_dir($appPath . 'config')) { |
|
| 359 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 356 | + if (is_dir($configPath.$appName)) { |
|
| 357 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 358 | + } elseif (is_dir($appPath.'config')) { |
|
| 359 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | foreach ($files as $file) { |
| 363 | 363 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if (is_file($appPath . 'event.php')) { |
|
| 367 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
| 366 | + if (is_file($appPath.'event.php')) { |
|
| 367 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if (is_file($appPath . 'middleware.php')) { |
|
| 371 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
| 370 | + if (is_file($appPath.'middleware.php')) { |
|
| 371 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if (is_file($appPath . 'provider.php')) { |
|
| 375 | - $this->app->bind(include $appPath . 'provider.php'); |
|
| 374 | + if (is_file($appPath.'provider.php')) { |
|
| 375 | + $this->app->bind(include $appPath.'provider.php'); |
|
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $this->app->loadLangPack($this->app->lang->defaultLangSet()); |
| 381 | 381 | |
| 382 | 382 | // 设置应用命名空间 |
| 383 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
| 383 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -48,27 +48,27 @@ discard block |
||
| 48 | 48 | $dbName = $input->getOption('db'); |
| 49 | 49 | $tables = $this->app->db->getConnection()->getTables($dbName); |
| 50 | 50 | } else { |
| 51 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
| 51 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
| 52 | 52 | $output->writeln('<error>Miss app name!</error>'); |
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($app) { |
| 57 | - $appPath = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR; |
|
| 58 | - $namespace = 'app\\' . $app; |
|
| 57 | + $appPath = $this->app->getBasePath().$app.DIRECTORY_SEPARATOR; |
|
| 58 | + $namespace = 'app\\'.$app; |
|
| 59 | 59 | } else { |
| 60 | 60 | $appPath = $this->app->getBasePath(); |
| 61 | 61 | $namespace = 'app'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $path = $appPath . 'model'; |
|
| 64 | + $path = $appPath.'model'; |
|
| 65 | 65 | $list = is_dir($path) ? scandir($path) : []; |
| 66 | 66 | |
| 67 | 67 | foreach ($list as $file) { |
| 68 | 68 | if (0 === strpos($file, '.')) { |
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | - $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); |
|
| 71 | + $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME); |
|
| 72 | 72 | $this->buildModelSchema($class); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $db = isset($dbName) ? $dbName . '.' : ''; |
|
| 79 | + $db = isset($dbName) ? $dbName.'.' : ''; |
|
| 80 | 80 | $this->buildDataBaseSchema($schemaPath, $tables, $db); |
| 81 | 81 | |
| 82 | 82 | $output->writeln('<info>Succeed!</info>'); |
@@ -93,27 +93,27 @@ discard block |
||
| 93 | 93 | $table = $model->getTable(); |
| 94 | 94 | $dbName = $model->getConnection()->getConfig('database'); |
| 95 | 95 | $path = $model->getConnection()->getConfig('schema_cache_path'); |
| 96 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
| 96 | + $content = '<?php '.PHP_EOL.'return '; |
|
| 97 | 97 | $info = $model->db()->getConnection()->getFields($table); |
| 98 | - $content .= var_export($info, true) . ';'; |
|
| 98 | + $content .= var_export($info, true).';'; |
|
| 99 | 99 | |
| 100 | - file_put_contents($path . $dbName . '.' . $table . '.php', $content); |
|
| 100 | + file_put_contents($path.$dbName.'.'.$table.'.php', $content); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | protected function buildDataBaseSchema(string $path, array $tables, string $db): void |
| 105 | 105 | { |
| 106 | 106 | if ('' == $db) { |
| 107 | - $dbName = $this->app->db->getConnection()->getConfig('database') . '.'; |
|
| 107 | + $dbName = $this->app->db->getConnection()->getConfig('database').'.'; |
|
| 108 | 108 | } else { |
| 109 | 109 | $dbName = $db; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | foreach ($tables as $table) { |
| 113 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
| 114 | - $info = $this->app->db->getConnection()->getFields($db . $table); |
|
| 115 | - $content .= var_export($info, true) . ';'; |
|
| 116 | - file_put_contents($path . $dbName . $table . '.php', $content); |
|
| 113 | + $content = '<?php '.PHP_EOL.'return '; |
|
| 114 | + $info = $this->app->db->getConnection()->getFields($db.$table); |
|
| 115 | + $content .= var_export($info, true).';'; |
|
| 116 | + file_put_contents($path.$dbName.$table.'.php', $content); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -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 | |
@@ -130,7 +130,7 @@ discard block |
||
| 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 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } else { |
| 301 | 301 | $function .= '()'; |
| 302 | 302 | } |
| 303 | - throw new Exception('function not exists: ' . $function, 0, $e); |
|
| 303 | + throw new Exception('function not exists: '.$function, 0, $e); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | } catch (ReflectionException $e) { |
| 329 | 329 | if (is_array($method)) { |
| 330 | 330 | $class = is_object($method[0]) ? get_class($method[0]) : $method[0]; |
| 331 | - $callback = $class . '::' . $method[1]; |
|
| 331 | + $callback = $class.'::'.$method[1]; |
|
| 332 | 332 | } else { |
| 333 | 333 | $callback = $method; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - throw new Exception('method not exists: ' . $callback . '()', 0, $e); |
|
| 336 | + throw new Exception('method not exists: '.$callback.'()', 0, $e); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | return $object; |
| 401 | 401 | } catch (ReflectionException $e) { |
| 402 | - throw new ClassNotFoundException('class not exists: ' . $class, $class, $e); |
|
| 402 | + throw new ClassNotFoundException('class not exists: '.$class, $class, $e); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | } elseif ($param->isDefaultValueAvailable()) { |
| 461 | 461 | $args[] = $param->getDefaultValue(); |
| 462 | 462 | } else { |
| 463 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
| 463 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | public static function parseName(string $name = null, int $type = 0, bool $ucfirst = true): string |
| 481 | 481 | { |
| 482 | 482 | if ($type) { |
| 483 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
| 483 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
| 484 | 484 | return strtoupper($match[1]); |
| 485 | 485 | }, $name); |
| 486 | 486 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public static function factory(string $name, string $namespace = '', ...$args) |
| 515 | 515 | { |
| 516 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
| 516 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
| 517 | 517 | |
| 518 | 518 | if (class_exists($class)) { |
| 519 | 519 | return Container::getInstance()->invokeClass($class, $args); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
| 522 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -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\route; |
| 14 | 14 | |
@@ -156,7 +156,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -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 TemplateNotFoundException('template not exists:' . $template, $template); |
|
| 81 | + throw new TemplateNotFoundException('template not exists:'.$template, $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 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | private function parseTemplate(string $template): string |
| 117 | 117 | { |
| 118 | 118 | if (empty($this->config['view_base'])) { |
| 119 | - $this->config['view_base'] = $this->app->getRootPath() . 'view' . DIRECTORY_SEPARATOR; |
|
| 119 | + $this->config['view_base'] = $this->app->getRootPath().'view'.DIRECTORY_SEPARATOR; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $request = $this->app->request; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } else { |
| 133 | 133 | $app = isset($app) ? $app : $request->app(); |
| 134 | 134 | // 基础视图目录 |
| 135 | - $path = $this->config['view_base'] . ($app ? $app . DIRECTORY_SEPARATOR : ''); |
|
| 135 | + $path = $this->config['view_base'].($app ? $app.DIRECTORY_SEPARATOR : ''); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $depr = $this->config['view_depr']; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $controller = $request->controller(); |
| 143 | 143 | if (strpos($controller, '.')) { |
| 144 | 144 | $pos = strrpos($controller, '.'); |
| 145 | - $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); |
|
| 145 | + $controller = substr($controller, 0, $pos).'.'.Str::snake(substr($controller, $pos + 1)); |
|
| 146 | 146 | } else { |
| 147 | 147 | $controller = Str::snake($controller); |
| 148 | 148 | } |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | $template = Str::snake($request->action()); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 161 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 162 | 162 | } elseif (false === strpos($template, $depr)) { |
| 163 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
| 163 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } else { |
| 167 | 167 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
| 170 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -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\service; |
| 14 | 14 | |
@@ -25,7 +25,7 @@ discard block |
||
| 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(); |
@@ -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\cache\driver; |
| 14 | 14 | |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | $key = $this->getCacheKey($name); |
| 192 | 192 | |
| 193 | 193 | return false === $ttl ? |
| 194 | - $this->handler->delete($key) : |
|
| 195 | - $this->handler->delete($key, $ttl); |
|
| 194 | + $this->handler->delete($key) : $this->handler->delete($key, $ttl); |
|
| 196 | 195 | } |
| 197 | 196 | |
| 198 | 197 | /** |