Passed
Push — master ( d451bf...01afb7 )
by Fran
09:38
created
src/base/Security.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -415,7 +415,7 @@
 block discarded – undo
415 415
      * @param array $parts
416 416
      * @param int $partLength
417 417
      *
418
-     * @return array
418
+     * @return string[]
419 419
      */
420 420
     private static function extractTsAndMod(array &$parts, $partLength)
421 421
     {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
     public static function save($user)
106 106
     {
107 107
         $admins = array();
108
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
109
-            $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);
108
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
109
+            $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);
110 110
         }
111
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
111
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
112 112
         $admins[$user['username']]['profile'] = $user['profile'];
113 113
 
114
-        return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));
114
+        return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));
115 115
     }
116 116
 
117 117
     /**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
     public function getAdmins()
146 146
     {
147 147
         $admins = array();
148
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
149
-            $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);
148
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
149
+            $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);
150 150
         }
151 151
 
152 152
         return $admins;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         Logger::log('Checking admin session');
167 167
         if (!$this->authorized) {
168 168
             $request = Request::getInstance();
169
-            if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) {
169
+            if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) {
170 170
                 //Si no hay fichero de usuarios redirigimos directamente al gestor
171 171
                 return Router::getInstance()->getAdmin()->adminers();
172 172
             }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             }
180 180
             if (!empty($user) && !empty($admins[$user])) {
181 181
                 $auth = $admins[$user]['hash'];
182
-                $this->authorized = ($auth == sha1($user . $pass));
182
+                $this->authorized = ($auth == sha1($user.$pass));
183 183
                 $this->admin = array(
184 184
                     'alias' => $user,
185 185
                     'profile' => $admins[$user]['profile'],
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
         $axis = 0;
399 399
         $parts = array();
400 400
         try {
401
-            $partLength = floor(strlen($token) / 10);
402
-            for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) {
401
+            $partLength = floor(strlen($token)/10);
402
+            for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) {
403 403
                 $parts[] = substr($token, $axis, $partLength);
404 404
                 $axis += $partLength;
405 405
             }
406
-        } catch (\Exception $e) {
406
+        }catch (\Exception $e) {
407 407
             $partLength = 0;
408 408
         }
409 409
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
         $decoded = NULL;
444 444
         list($partLength, $parts) = self::extractTokenParts($token);
445 445
         list($ts, $mod) = self::extractTsAndMod($parts, $partLength);
446
-        $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);
446
+        $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);
447 447
         if (time() - (integer)$ts < 300 && $hashMod === $mod) {
448 448
             $decoded = implode('', $parts);
449 449
         }
@@ -460,16 +460,16 @@  discard block
 block discarded – undo
460 460
     public static function generateToken($secret, $module = 'PSFS')
461 461
     {
462 462
         $ts = time();
463
-        $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);
463
+        $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);
464 464
         $hash = hash('sha256', $secret);
465
-        $insert = floor(strlen($hash) / strlen($ts));
465
+        $insert = floor(strlen($hash)/strlen($ts));
466 466
         $j = 0;
467 467
         $token = '';
468 468
         for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) {
469
-            $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2);
469
+            $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2);
470 470
             $j += $insert;
471 471
         }
472
-        $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts)));
472
+        $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts)));
473 473
         return $token;
474 474
     }
475 475
 
Please login to merge, or discard this patch.
src/base/Service.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-     * @param $header
129
-     * @param null $content
128
+     * @param string $header
129
+     * @param string $content
130 130
      *
131 131
      * @return $this
132 132
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
         $this->url = NULL;
178 178
         $this->params = array();
179 179
         $this->headers = array();
180
-        Logger::log("Context service for " . get_called_class() . " cleared!");
180
+        Logger::log("Context service for ".get_called_class()." cleared!");
181 181
     }
182 182
 
183 183
     /**
Please login to merge, or discard this patch.
src/base/Singleton.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function __construct()
21 21
     {
22
-        Logger::log(get_class($this) . ' constructor invoked');
22
+        Logger::log(get_class($this).' constructor invoked');
23 23
     }
24 24
 
25 25
     /**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
         $calledClass = get_called_class();
107 107
         try {
108 108
             $instance = $this->constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
109
-            $setter = "set" . ucfirst($variable);
109
+            $setter = "set".ucfirst($variable);
110 110
             if (method_exists($calledClass, $setter)) {
111 111
                 $this->$setter($instance);
112
-            } else {
112
+            }else {
113 113
                 $this->$variable = $instance;
114 114
             }
115
-        } catch (\Exception $e) {
116
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
115
+        }catch (\Exception $e) {
116
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
117 117
         }
118 118
         return $this;
119 119
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     public function init()
125 125
     {
126 126
         if (!$this->isLoaded()) {
127
-            $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json";
127
+            $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json";
128 128
             /** @var \PSFS\base\Cache $cacheService */
129 129
             $cacheService = Cache::getInstance();
130 130
             /** @var \PSFS\base\config\Config $configService */
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
                 $this->load($property, true, $class);
140 140
             }
141 141
             $this->setLoaded();
142
-        } else {
143
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
142
+        }else {
143
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
144 144
         }
145 145
     }
146 146
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         if (null === $class) {
156 156
             $class = get_class($this);
157 157
         }
158
-        Logger::log('Extracting annotations properties from class ' . $class);
158
+        Logger::log('Extracting annotations properties from class '.$class);
159 159
         $selfReflector = new \ReflectionClass($class);
160 160
         if (false !== $selfReflector->getParentClass()) {
161 161
             $properties = $this->getClassProperties($selfReflector->getParentClass()->getName());
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
      */
197 197
     private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)
198 198
     {
199
-        Logger::log('Create inyectable instance for ' . $classNameSpace . ' into ' . get_class($this));
199
+        Logger::log('Create inyectable instance for '.$classNameSpace.' into '.get_class($this));
200 200
         $reflector = new \ReflectionClass($calledClass);
201 201
         $property = $reflector->getProperty($variable);
202 202
         $varInstanceType = (null === $classNameSpace) ? $this->extractVarType($property->getDocComment()) : $classNameSpace;
203 203
         if (true === $singleton && method_exists($varInstanceType, "getInstance")) {
204 204
             $instance = $varInstanceType::getInstance();
205
-        } else {
205
+        }else {
206 206
             $instance = new $varInstanceType();
207 207
         }
208 208
         return $instance;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,9 +135,11 @@
 block discarded – undo
135 135
                 $cacheService->storeData($cacheFilename, $properties, Cache::JSON);
136 136
             }
137 137
             /** @var \ReflectionProperty $property */
138
-            if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) {
138
+            if (!empty($properties) && is_array($properties)) {
139
+                foreach ($properties as $property => $class) {
139 140
                 $this->load($property, true, $class);
140 141
             }
142
+            }
141 143
             $this->setLoaded();
142 144
         } else {
143 145
             Logger::log(get_class($this) . ' already loaded', LOG_INFO);
Please login to merge, or discard this patch.
src/base/config/Config.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function init()
48 48
     {
49
-        if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json")) {
49
+        if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json")) {
50 50
             $this->loadConfigData();
51 51
         }
52 52
         return $this;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getTemplatePath()
118 118
     {
119
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
119
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
120 120
         return realpath($path);
121 121
     }
122 122
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
         $final_data = self::saveExtraParams($data);
164 164
         $saved = false;
165 165
         try {
166
-            Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", $final_data, Cache::JSON, true);
166
+            Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", $final_data, Cache::JSON, true);
167 167
             Config::getInstance()->loadConfigData();
168 168
             $saved = true;
169
-        } catch (ConfigException $e) {
169
+        }catch (ConfigException $e) {
170 170
             Logger::log($e->getMessage(), LOG_ERR);
171 171
         }
172 172
         return $saved;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function getPropelParams()
200 200
     {
201
-        return Cache::getInstance()->getDataFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'properties.json', Cache::JSON, true);
201
+        return Cache::getInstance()->getDataFromFile(__DIR__.DIRECTORY_SEPARATOR.'properties.json', Cache::JSON, true);
202 202
     }
203 203
 
204 204
     /**
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
     {
211 211
         try {
212 212
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
213
-                throw new \Exception(_('Can\'t create directory ') . $dir);
213
+                throw new \Exception(_('Can\'t create directory ').$dir);
214 214
             }
215
-        } catch (\Exception $e) {
215
+        }catch (\Exception $e) {
216 216
             Logger::log($e->getMessage(), LOG_WARNING);
217 217
             if (!file_exists(dirname($dir))) {
218
-                throw new ConfigException($e->getMessage() . $dir);
218
+                throw new ConfigException($e->getMessage().$dir);
219 219
             }
220 220
         }
221 221
     }
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $rootDirs = array("css", "js", "media", "font");
229 229
         foreach ($rootDirs as $dir) {
230
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
230
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
231 231
                 try {
232
-                    @shell_exec("rm -rf " . WEB_DIR . DIRECTORY_SEPARATOR . $dir);
233
-                } catch (\Exception $e) {
232
+                    @shell_exec("rm -rf ".WEB_DIR.DIRECTORY_SEPARATOR.$dir);
233
+                }catch (\Exception $e) {
234 234
                     Logger::log($e->getMessage());
235 235
                 }
236 236
             }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function loadConfigData()
244 244
     {
245
-        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", Cache::JSON, TRUE) ?: array();
245
+        $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", Cache::JSON, TRUE) ?: array();
246 246
         $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE;
247 247
     }
248 248
 
Please login to merge, or discard this patch.
src/base/Logger.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 if (!defined("LOG_DIR")) {
16
-    Config::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
17
-    define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
16
+    Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs');
17
+    define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs');
18 18
 }
19 19
 
20 20
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $config = Config::getInstance();
44 44
         $args = func_get_args();
45 45
         list($logger, $debug, $path) = $this->setup($config, $args);
46
-        $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+");
46
+        $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+");
47 47
         $this->addPushLogger($logger, $debug, $config);
48 48
     }
49 49
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     private function createLoggerPath(Config $config)
186 186
     {
187 187
         $logger = $this->setLoggerName($config);
188
-        $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m');
188
+        $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m');
189 189
         Config::createDir($path);
190 190
 
191 191
         return $path;
Please login to merge, or discard this patch.
src/base/Template.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $this->setStatusHeader();
133 133
         $this->setAuthHeaders();
134 134
         $this->setCookieHeaders($cookies);
135
-        header('Content-type: ' . $contentType);
135
+        header('Content-type: '.$contentType);
136 136
 
137 137
     }
138 138
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
         Logger::log('Start output response');
149 149
         ob_start();
150 150
         $this->setReponseHeaders($contentType, $cookies);
151
-        header('Content-length: ' . strlen($output));
151
+        header('Content-length: '.strlen($output));
152 152
 
153 153
         $cache = Cache::needCache();
154 154
         if (false !== $cache && $this->status_code === 200 && $this->debug === false) {
155 155
             Logger::log('Saving output response into cache');
156 156
             $cacheName = $this->cache->getRequestCacheHash();
157
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName, $output);
158
-            $this->cache->storeData("json" . DIRECTORY_SEPARATOR . $cacheName . ".headers", headers_list(), Cache::JSON);
157
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName, $output);
158
+            $this->cache->storeData("json".DIRECTORY_SEPARATOR.$cacheName.".headers", headers_list(), Cache::JSON);
159 159
         }
160 160
         echo $output;
161 161
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     {
173 173
         Logger::log('Close template render');
174 174
         $this->security->setSessionKey("lastRequest", array(
175
-            "url" => Request::getInstance()->getRootUrl() . Request::requestUri(),
175
+            "url" => Request::getInstance()->getRootUrl().Request::requestUri(),
176 176
             "ts" => microtime(true),
177 177
         ));
178 178
         $this->security->updateSession();
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
         $dump = '';
225 225
         try {
226 226
             $dump = $this->tpl->render($tpl, $vars);
227
-        } catch (\Exception $e) {
228
-            echo $e->getMessage() . "<pre>" . $e->getTraceAsString() . "</pre>";
227
+        }catch (\Exception $e) {
228
+            echo $e->getMessage()."<pre>".$e->getTraceAsString()."</pre>";
229 229
         }
230 230
         return $dump;
231 231
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     public function regenerateTemplates()
339 339
     {
340 340
         $this->generateTemplatesCache();
341
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
341
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
342 342
         $translations = [];
343 343
         if (is_array($domains)) {
344 344
             $translations = $this->parsePathTranslations($domains);
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
             // force compilation
361 361
             if ($file->isFile()) {
362 362
                 try {
363
-                    $this->tpl->loadTemplate(str_replace($tplDir . '/', '', $file));
364
-                } catch (\Exception $e) {
363
+                    $this->tpl->loadTemplate(str_replace($tplDir.'/', '', $file));
364
+                }catch (\Exception $e) {
365 365
                     Logger::log($e->getMessage(), LOG_ERR);
366 366
                 }
367 367
             }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             unset($_SERVER["PHP_AUTH_USER"]);
432 432
             unset($_SERVER["PHP_AUTH_PW"]);
433 433
             header_remove("Authorization");
434
-        } else {
434
+        }else {
435 435
             header('Authorization:');
436 436
         }
437 437
     }
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
             Logger::log('Adding debug headers to render response');
459 459
             $vars["__DEBUG__"]["includes"] = get_included_files();
460 460
             $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
461
-            header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
462
-            header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
463
-            header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
461
+            header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s');
462
+            header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes');
463
+            header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened');
464 464
         }
465 465
 
466 466
         return $vars;
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
             $path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
22 22
 
23 23
             // filepath
24
-            $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php";
24
+            $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php";
25 25
             if (!file_exists($abs_path)) {
26
-                pre('&rarr;&nbsp;' . $class);
27
-                pre('&rarr;&nbsp;' . $path);
28
-                pre('&rarr;&nbsp;' . $abs_path);
26
+                pre('&rarr;&nbsp;'.$class);
27
+                pre('&rarr;&nbsp;'.$path);
28
+                pre('&rarr;&nbsp;'.$abs_path);
29 29
             }
30 30
 
31 31
             // require the file
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
6 6
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
7
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
8
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
9
+}else {
10
+    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
11
+    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
12 12
 }
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
13
+if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
14
+if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
15
+if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
16
+if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
17 17
 
18 18
 //Cargamos en memoria la función de desarrollo PRE
19 19
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
Braces   +32 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,19 +1,39 @@
 block discarded – undo
1 1
 <?php
2
-if (defined('PSFS_BOOTSTRAP_LOADED')) return;
2
+if (defined('PSFS_BOOTSTRAP_LOADED')) {
3
+    return;
4
+}
3 5
 use Symfony\Component\Finder\Finder;
4 6
 
5
-if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__);
7
+if (!defined('SOURCE_DIR')) {
8
+    define('SOURCE_DIR', __DIR__);
9
+}
6 10
 if (preg_match('/vendor/', SOURCE_DIR)) {
7
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
8
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
9
-} else {
10
-    if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
11
-    if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
12
-}
13
-if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
14
-if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
15
-if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
16
-if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
11
+    if (!defined('BASE_DIR')) {
12
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
13
+    }
14
+    if (!defined('CORE_DIR')) {
15
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
16
+    }
17
+    } else {
18
+    if (!defined('BASE_DIR')) {
19
+        define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
20
+    }
21
+    if (!defined('CORE_DIR')) {
22
+        define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
23
+    }
24
+    }
25
+if (!defined('LOG_DIR')) {
26
+    define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
27
+}
28
+if (!defined('CACHE_DIR')) {
29
+    define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
30
+}
31
+if (!defined('CONFIG_DIR')) {
32
+    define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
33
+}
34
+if (!defined('WEB_DIR')) {
35
+    define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
36
+}
17 37
 
18 38
 //Cargamos en memoria la función de desarrollo PRE
19 39
 if (!function_exists('pre')) {
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use PSFS\base\Logger;
14 14
 use PSFS\base\Singleton;
15 15
 
16
-require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php";
16
+require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php";
17 17
 
18 18
 /**
19 19
  * Class Dispatcher
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
     private function setLocale()
75 75
     {
76 76
         $this->locale = $this->config->get("default_language");
77
-        Logger::log('Set locale to project [' . $this->locale . ']');
77
+        Logger::log('Set locale to project ['.$this->locale.']');
78 78
         // Load translations
79
-        putenv("LC_ALL=" . $this->locale);
79
+        putenv("LC_ALL=".$this->locale);
80 80
         setlocale(LC_ALL, $this->locale);
81 81
         // Load the locale path
82
-        $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
83
-        Logger::log('Set locale dir ' . $locale_path);
82
+        $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
83
+        Logger::log('Set locale dir '.$locale_path);
84 84
         Config::createDir($locale_path);
85 85
         bindtextdomain('translations', $locale_path);
86 86
         textdomain('translations');
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
                 if (!$this->parser->isFile()) {
101 101
                     return $this->router->execute($this->actualUri);
102 102
                 }
103
-            } else {
103
+            }else {
104 104
                 return $this->router->getAdmin()->config();
105 105
             }
106
-        } catch (ConfigException $c) {
106
+        }catch (ConfigException $c) {
107 107
             return $this->dumpException($c);
108
-        } catch (SecurityException $s) {
108
+        }catch (SecurityException $s) {
109 109
             return $this->security->notAuthorized($this->actualUri);
110
-        } catch (RouterException $r) {
110
+        }catch (RouterException $r) {
111 111
             return $this->router->httpNotFound($r);
112
-        } catch (\Exception $e) {
112
+        }catch (\Exception $e) {
113 113
             return $this->dumpException($e);
114 114
         }
115 115
     }
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                 $use /= 1024;
152 152
                 break;
153 153
             case "MBytes":
154
-                $use /= (1024 * 1024);
154
+                $use /= (1024*1024);
155 155
                 break;
156 156
             case "Bytes":
157 157
             default:
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if ($this->config->getDebugMode()) {
178 178
             Logger::log('Added handlers for errors');
179 179
             //Warning & Notice handler
180
-            set_error_handler(function ($errno, $errstr, $errfile, $errline) {
180
+            set_error_handler(function($errno, $errstr, $errfile, $errline) {
181 181
                 Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]);
182 182
                 throw new \Exception($errstr, 500);
183 183
             });
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
         Logger::log('Initialicing stats (mem + ts)');
193 193
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
194 194
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
195
-        } else {
195
+        }else {
196 196
             $this->ts = $this->parser->getTs();
197 197
         }
198 198
         $this->mem = memory_get_usage();
Please login to merge, or discard this patch.