Completed
Push — 6.0 ( 740410...ebf27b )
by liu
05:06
created
src/think/Http.php 1 patch
Spacing   +26 added lines, -26 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
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.