Passed
Push — master ( 74847c...ad33a7 )
by Fran
03:09
created
src/Dispatcher.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use PSFS\base\Singleton;
17 17
 use PSFS\controller\ConfigController;
18 18
 
19
-require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
19
+require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
20 20
 
21 21
 /**
22 22
  * Class Dispatcher
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
     private function setLocale()
78 78
     {
79 79
         $this->locale = $this->config->get("default_language");
80
-        Logger::log('Set locale to project [' . $this->locale . ']');
80
+        Logger::log('Set locale to project ['.$this->locale.']');
81 81
         // Load translations
82
-        putenv("LC_ALL=" . $this->locale);
82
+        putenv("LC_ALL=".$this->locale);
83 83
         setlocale(LC_ALL, $this->locale);
84 84
         // Load the locale path
85
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
86
-        Logger::log('Set locale dir ' . $locale_path);
85
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
86
+        Logger::log('Set locale dir '.$locale_path);
87 87
         Config::createDir($locale_path);
88 88
         bindtextdomain('translations', $locale_path);
89 89
         textdomain('translations');
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
                 if (!$this->parser->isFile()) {
105 105
                     return $this->router->execute($this->actualUri);
106 106
                 }
107
-            } else {
107
+            }else {
108 108
                 return ConfigController::getInstance()->config();
109 109
             }
110
-        } catch (ConfigException $c) {
110
+        }catch (ConfigException $c) {
111 111
             return $this->dumpException($c);
112
-        } catch (SecurityException $s) {
112
+        }catch (SecurityException $s) {
113 113
             return $this->security->notAuthorized($this->actualUri);
114
-        } catch (UserAuthException $u) {
114
+        }catch (UserAuthException $u) {
115 115
             Request::getInstance()->redirect($this->router->getRoute($this->config->get('home_action')));
116
-        } catch (RouterException $r) {
116
+        }catch (RouterException $r) {
117 117
             return $this->router->httpNotFound($r);
118
-        } catch (\Exception $e) {
118
+        }catch (\Exception $e) {
119 119
             return $this->dumpException($e);
120 120
         }
121 121
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 $use /= 1024;
158 158
                 break;
159 159
             case "MBytes":
160
-                $use /= (1024 * 1024);
160
+                $use /= (1024*1024);
161 161
                 break;
162 162
             case "Bytes":
163 163
             default:
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         if ($this->config->getDebugMode()) {
184 184
             Logger::log('Added handlers for errors');
185 185
             //Warning & Notice handler
186
-            set_error_handler(function ($errno, $errstr, $errfile, $errline) {
186
+            set_error_handler(function($errno, $errstr, $errfile, $errline) {
187 187
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
188 188
                 throw new \Exception($errstr, 500);
189 189
             });
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         Logger::log('Initialicing stats (mem + ts)');
199 199
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
200 200
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
201
-        } else {
201
+        }else {
202 202
             $this->ts = $this->parser->getTs();
203 203
         }
204 204
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.
src/base/Template.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -7,10 +7,7 @@
 block discarded – undo
7 7
 use PSFS\base\extension\AssetsTokenParser;
8 8
 use PSFS\base\extension\TemplateFunctions;
9 9
 use PSFS\base\types\helpers\ResponseHelper;
10
-use PSFS\base\types\helpers\SecurityHelper;
11
-use PSFS\base\types\helpers\TemplateHelper;
12 10
 use PSFS\base\types\SingletonTrait;
13
-use PSFS\Dispatcher;
14 11
 
15 12
 
16 13
 class Template
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         ResponseHelper::setStatusHeader($this->status_code);
131 131
         ResponseHelper::setAuthHeaders($this->public_zone);
132 132
         ResponseHelper::setCookieHeaders($cookies);
133
-        header('Content-type: ' . $contentType);
133
+        header('Content-type: '.$contentType);
134 134
 
135 135
     }
136 136
 
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
         Logger::log('Start output response');
147 147
         ob_start();
148 148
         $this->setReponseHeaders($contentType, $cookies);
149
-        header('Content-length: ' . strlen($output));
149
+        header('Content-length: '.strlen($output));
150 150
 
151 151
         $cache = Cache::needCache();
152 152
         if (false !== $cache && $this->status_code === Template::STATUS_OK && $this->debug === false) {
153 153
             Logger::log('Saving output response into cache');
154 154
             $cacheName = $this->cache->getRequestCacheHash();
155
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName, $output);
156
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName . ".headers", headers_list(), Cache::JSON);
155
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName, $output);
156
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName.".headers", headers_list(), Cache::JSON);
157 157
         }
158 158
         echo $output;
159 159
 
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
     {
171 171
         Logger::log('Close template render');
172 172
         Security::getInstance()->setSessionKey("lastRequest", array(
173
-            "url" => Request::getInstance()->getRootUrl() . Request::requestUri(),
173
+            "url" => Request::getInstance()->getRootUrl().Request::requestUri(),
174 174
             "ts" => microtime(true),
175 175
         ));
176 176
         Security::getInstance()->updateSession();
177
-        Logger::log('End request: ' . Request::requestUri(), LOG_INFO);
177
+        Logger::log('End request: '.Request::requestUri(), LOG_INFO);
178 178
         exit;
179 179
     }
180 180
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
         $dump = '';
224 224
         try {
225 225
             $dump = $this->tpl->render($tpl, $vars);
226
-        } catch (\Exception $e) {
226
+        }catch (\Exception $e) {
227 227
             Logger::log($e->getMessage(), LOG_ERR);
228 228
         }
229 229
         return $dump;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     public function regenerateTemplates()
338 338
     {
339 339
         $this->generateTemplatesCache();
340
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
340
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
341 341
         $translations = [];
342 342
         if (is_array($domains)) {
343 343
             $translations = $this->parsePathTranslations($domains);
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
             // force compilation
360 360
             if ($file->isFile()) {
361 361
                 try {
362
-                    $this->tpl->loadTemplate(str_replace($tplDir . '/', '', $file));
363
-                } catch (\Exception $e) {
362
+                    $this->tpl->loadTemplate(str_replace($tplDir.'/', '', $file));
363
+                }catch (\Exception $e) {
364 364
                     Logger::log($e->getMessage(), LOG_ERR);
365 365
                     throw $e;
366 366
                 }
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
      */
436 436
     private function loadDomains()
437 437
     {
438
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
439
-        if(null !== $domains) {
440
-            foreach($domains as $domain => $paths) {
438
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
439
+        if (null !== $domains) {
440
+            foreach ($domains as $domain => $paths) {
441 441
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
442 442
             }
443 443
         }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         $this->cache = Cache::getInstance();
453 453
         $loader = new \Twig_Loader_Filesystem(Config::getInstance()->getTemplatePath());
454 454
         $this->tpl = new \Twig_Environment($loader, array(
455
-            'cache' => Config::getInstance()->getCachePath() . DIRECTORY_SEPARATOR . 'twig',
455
+            'cache' => Config::getInstance()->getCachePath().DIRECTORY_SEPARATOR.'twig',
456 456
             'debug' => (bool)$this->debug,
457 457
             'auto_reload' => Config::getParam('twig.auto_reload', TRUE),
458 458
         ));
Please login to merge, or discard this patch.
src/base/types/helpers/ResponseHelper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             unset($_SERVER["PHP_AUTH_USER"]);
39 39
             unset($_SERVER["PHP_AUTH_PW"]);
40 40
             header_remove("Authorization");
41
-        } else {
41
+        }else {
42 42
             header('Authorization:');
43 43
         }
44 44
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
             Logger::log('Adding debug headers to render response');
67 67
             $vars["__DEBUG__"]["includes"] = get_included_files();
68 68
             $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
69
-            header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
70
-            header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
71
-            header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
69
+            header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s');
70
+            header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes');
71
+            header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened');
72 72
         }
73 73
 
74 74
         return $vars;
Please login to merge, or discard this patch.