Test Failed
Push — master ( e708ee...6883f1 )
by Fran
04:38
created
src/base/Cache.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         GeneratorHelper::createDir(dirname($path));
46 46
         if (false === file_put_contents($path, $data)) {
47
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $path);
47
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$path);
48 48
         }
49 49
     }
50 50
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
59 59
     {
60 60
         $data = null;
61
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
61
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
62 62
         if (file_exists($absolutePath)) {
63 63
             $data = file_get_contents($absolutePath);
64 64
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
76 76
     {
77
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
77
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
78 78
         $lasModificationDate = filemtime($absolutePath);
79 79
         return ($lasModificationDate + $expires <= time());
80 80
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function storeData($path, $data, $transform = Cache::TEXT, $absolute = false, $expires = 600)
141 141
     {
142 142
         $data = Cache::transformData($data, $transform);
143
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
143
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
144 144
         $this->saveTextToFile($data, $absolutePath);
145 145
     }
146 146
 
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
156 156
     {
157 157
         $data = null;
158
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
158
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
159 159
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
160 160
                 $data = call_user_func($function);
161 161
                 $this->storeData($path, $data, $transform, false, $expires);
162
-            } else {
162
+            }else {
163 163
                 $data = $this->getDataFromFile($path, $transform);
164 164
             }
165 165
         }
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
         $action = Security::getInstance()->getSessionKey("__CACHE__");
202 202
         if (null !== $action && $action["cache"] > 0) {
203 203
             $class = array_pop(explode('\\', $action['class']));
204
-            $filename = sha1($action["http"] . " " . $action["slug"]);
205
-            $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2);
206
-            $hashPath = $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR;
204
+            $filename = sha1($action["http"]." ".$action["slug"]);
205
+            $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2);
206
+            $hashPath = $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR;
207 207
         }
208 208
         return [$hashPath, $filename];
209 209
     }
Please login to merge, or discard this patch.
src/base/types/traits/OutputTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         ResponseHelper::setStatusHeader($this->status_code);
79 79
         ResponseHelper::setAuthHeaders($this->public_zone);
80 80
         ResponseHelper::setCookieHeaders($cookies);
81
-        header('Content-type: ' . $contentType);
81
+        header('Content-type: '.$contentType);
82 82
 
83 83
     }
84 84
 
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
         Logger::log('Start output response');
95 95
         ob_start();
96 96
         $this->setReponseHeaders($contentType, $cookies);
97
-        header('Content-length: ' . strlen($output));
97
+        header('Content-length: '.strlen($output));
98 98
 
99 99
         $needCache = Cache::needCache();
100 100
         if (false !== $needCache && $this->status_code === Template::STATUS_OK) {
101 101
             $cache = Cache::getInstance();
102 102
             Logger::log('Saving output response into cache');
103 103
             list($path, $cacheDataName) = $cache->getRequestCacheHash();
104
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
105
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON);
104
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output);
105
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON);
106 106
         }
107 107
         echo $output;
108 108
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
         Logger::log('Close template render');
121 121
         $uri = Request::requestUri();
122 122
         Security::getInstance()->setSessionKey("lastRequest", array(
123
-            "url" => Request::getInstance()->getRootUrl() . $uri,
123
+            "url" => Request::getInstance()->getRootUrl().$uri,
124 124
             "ts" => microtime(true),
125 125
         ));
126 126
         Security::getInstance()->updateSession();
127
-        Logger::log('End request: ' . $uri, LOG_INFO);
127
+        Logger::log('End request: '.$uri, LOG_INFO);
128 128
         exit;
129 129
     }
130 130
 
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
         /////////////////////////////////////////////////////////////
163 163
         // Date in the past sets the value to already have been expired.
164 164
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
165
-        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
165
+        header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
166 166
         header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
167 167
         header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
168 168
         header("Pragma: no-cache");
169 169
         header("Expires: 0");
170 170
         header('Content-Transfer-Encoding: none');
171
-        header("Content-type: " . $content);
172
-        header("Content-length: " . strlen($data));
173
-        header('Content-Disposition: attachment; filename="' . $filename . '"');
171
+        header("Content-type: ".$content);
172
+        header("Content-length: ".strlen($data));
173
+        header('Content-Disposition: attachment; filename="'.$filename.'"');
174 174
         echo $data;
175 175
         ob_flush();
176 176
         ob_end_clean();
Please login to merge, or discard this patch.
src/base/Template.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $dump = '';
105 105
         try {
106 106
             $dump = $this->tpl->render($tpl, $vars);
107
-        } catch (\Exception $e) {
107
+        }catch (\Exception $e) {
108 108
             Logger::log($e->getMessage(), LOG_ERR);
109 109
         }
110 110
         return $dump;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public function regenerateTemplates()
132 132
     {
133 133
         $this->generateTemplatesCache();
134
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true);
134
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true);
135 135
         $translations = [];
136 136
         if (is_array($domains)) {
137 137
             $translations = $this->parsePathTranslations($domains);
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             // force compilation
154 154
             if ($file->isFile()) {
155 155
                 try {
156
-                    $this->tpl->load(str_replace($tplDir . '/', '', $file));
157
-                } catch (\Exception $e) {
156
+                    $this->tpl->load(str_replace($tplDir.'/', '', $file));
157
+                }catch (\Exception $e) {
158 158
                     Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]);
159 159
                 }
160 160
             }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             'existsFlash' => TemplateFunctions::EXISTS_FLASH_FUNCTION,
215 215
             'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION,
216 216
         ];
217
-        foreach($functions as $name => $function) {
217
+        foreach ($functions as $name => $function) {
218 218
             $this->addTemplateFunction($name, $function);
219 219
         }
220 220
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      */
234 234
     private function loadDomains()
235 235
     {
236
-        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true);
236
+        $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true);
237 237
         if (null !== $domains) {
238 238
             foreach ($domains as $domain => $paths) {
239 239
                 $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain));
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     {
249 249
         $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath());
250 250
         $this->tpl = new \Twig_Environment($loader, array(
251
-            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
251
+            'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig',
252 252
             'debug' => (bool)$this->debug,
253 253
             'auto_reload' => Config::getParam('twig.auto_reload', TRUE),
254 254
         ));
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function init()
64 64
     {
65
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", $this->cacheType, TRUE);
66
-        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->cacheType, TRUE);
65
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", $this->cacheType, TRUE);
66
+        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->cacheType, TRUE);
67 67
         if (empty($this->routing) || Config::getInstance()->getDebugMode()) {
68 68
             $this->debugLoad();
69 69
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 "success" => FALSE,
101 101
                 "error" => $e->getMessage(),
102 102
             )), 'application/json');
103
-        } else {
103
+        }else {
104 104
             return $template->render('error.html.twig', array(
105 105
                 'exception' => $e,
106 106
                 'trace' => $e->getTraceAsString(),
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
             SecurityHelper::checkRestrictedAccess($route);
159 159
             //Search action and execute
160 160
             $this->searchAction($route);
161
-        } catch (AccessDeniedException $e) {
161
+        }catch (AccessDeniedException $e) {
162 162
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
163 163
             return Admin::staticAdminLogon($route);
164
-        } catch (RouterException $r) {
164
+        }catch (RouterException $r) {
165 165
             Logger::log($r->getMessage(), LOG_WARNING);
166
-        } catch (\Exception $e) {
166
+        }catch (\Exception $e) {
167 167
             Logger::log($e->getMessage(), LOG_ERR);
168 168
             throw $e;
169 169
         }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      */
181 181
     protected function searchAction($route)
182 182
     {
183
-        Logger::log('Searching action to execute: ' . $route, LOG_INFO);
183
+        Logger::log('Searching action to execute: '.$route, LOG_INFO);
184 184
         //Revisamos si tenemos la ruta registrada
185 185
         $parts = parse_url($route);
186 186
         $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 $class = RouterHelper::getClassToCall($action);
195 195
                 try {
196 196
                     $this->executeCachedRoute($route, $action, $class, $get);
197
-                } catch (\Exception $e) {
197
+                }catch (\Exception $e) {
198 198
                     Logger::log($e->getMessage(), LOG_ERR);
199 199
                     throw new \RuntimeException($e->getMessage(), 404, $e);
200 200
                 }
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
             $externalModules = explode(',', $externalModules);
224 224
             foreach ($externalModules as &$module) {
225 225
                 $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
226
-                $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
226
+                $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
227 227
                 if (file_exists($externalModulePath)) {
228 228
                     $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
229 229
                     if (!empty($externalModule)) {
230 230
                         foreach ($externalModule as $modulePath) {
231 231
                             $extModule = $modulePath->getBasename();
232
-                            $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
232
+                            $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
233 233
                             if (file_exists($moduleAutoloader)) {
234 234
                                 @include $moduleAutoloader;
235 235
                                 if ($hydrateRoute) {
236
-                                    $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing);
236
+                                    $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing);
237 237
                                 }
238 238
                             }
239 239
                         }
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
             $modules = $this->finder->directories()->in($modulesPath)->depth(0);
257 257
             foreach ($modules as $modulePath) {
258 258
                 $module = $modulePath->getBasename();
259
-                $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
259
+                $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
260 260
             }
261 261
         }
262
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
262
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
263 263
     }
264 264
 
265 265
     /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
             $home_params = NULL;
275 275
             foreach ($this->routing as $pattern => $params) {
276 276
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
277
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
277
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
278 278
                     $home_params = $params;
279 279
                 }
280 280
             }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php");
300 300
         foreach ($files as $file) {
301 301
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
302
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
302
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
303 303
         }
304 304
         $this->finder = new Finder();
305 305
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             if (!$this->domains) {
370 370
                 $this->domains = [];
371 371
             }
372
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
372
+            $domain = "@".$class->getConstant("DOMAIN")."/";
373 373
             if (!array_key_exists($domain, $this->domains)) {
374 374
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
375 375
             }
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function simpatize()
386 386
     {
387
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
388
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
387
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
388
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
389 389
         $this->generateSlugs($absoluteTranslationFileName);
390 390
         GeneratorHelper::createDir(CONFIG_DIR);
391
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
391
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
392 392
 
393 393
         return $this;
394 394
     }
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
     public function getRoute($slug = '', $absolute = FALSE, $params = [])
407 407
     {
408 408
         if (strlen($slug) === 0) {
409
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
409
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
410 410
         }
411 411
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
412 412
             throw new RouterException(_("No existe la ruta especificada"));
413 413
         }
414
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
414
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
415 415
         if (!empty($params)) foreach ($params as $key => $value) {
416
-            $url = str_replace("{" . $key . "}", $value, $url);
416
+            $url = str_replace("{".$key."}", $value, $url);
417 417
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
418
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
418
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
419 419
         }
420 420
 
421 421
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -460,18 +460,18 @@  discard block
 block discarded – undo
460 460
      */
461 461
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
462 462
     {
463
-        Logger::log('Executing route ' . $route, LOG_INFO);
463
+        Logger::log('Executing route '.$route, LOG_INFO);
464 464
         Security::getInstance()->setSessionKey("__CACHE__", $action);
465 465
         $cache = Cache::needCache();
466 466
         $execute = TRUE;
467 467
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
468 468
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
469
-            $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName,
470
-                $cache, function () {
469
+            $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName,
470
+                $cache, function() {
471 471
                 });
472 472
             if (NULL !== $cachedData) {
473
-                $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers",
474
-                    $cache, function () {
473
+                $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers",
474
+                    $cache, function() {
475 475
                     }, Cache::JSON);
476 476
                 Template::getInstance()->renderCache($cachedData, $headers);
477 477
                 $execute = FALSE;
Please login to merge, or discard this patch.