Completed
Push — master ( 8a02a1...c877ec )
by Fran
04:56 queued 14s
created
src/base/Cache.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
 
115 115
     /**
116 116
      * Método que guarda en fichero los datos pasados
117
-     * @param $path
117
+     * @param string $path
118 118
      * @param $data
119 119
      * @param int $transform
120 120
      * @param boolean $absolutePath
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
      */
30 30
     private function saveTextToFile($data, $path, $absolute = false)
31 31
     {
32
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
32
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
33 33
         $filename = basename($absolutePath);
34 34
         Config::createDir(str_replace($filename, "", $absolutePath));
35 35
         if (false === file_put_contents($absolutePath, $data)) {
36
-            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ') . $absolutePath);
36
+            throw new ConfigException(_('No se tienen los permisos suficientes para escribir en el fichero ').$absolutePath);
37 37
         }
38 38
     }
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
48 48
     {
49 49
         $data = null;
50
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
50
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
51 51
         if (file_exists($absolutePath)) {
52 52
             $data = file_get_contents($absolutePath);
53 53
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
65 65
     {
66
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
66
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
67 67
         $lasModificationDate = filemtime($absolutePath);
68 68
         return ($lasModificationDate + $expires <= time());
69 69
     }
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
137 137
     {
138 138
         $data = null;
139
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
139
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
140 140
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
141 141
                 $data = call_user_func($function);
142 142
                 $this->storeData($path, $data, $transform);
143
-            } else {
143
+            }else {
144 144
                 $data = $this->getDataFromFile($path, $transform);
145 145
             }
146 146
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $hash = "";
171 171
         $action = Security::getInstance()->getSessionKey("__CACHE__");
172 172
         if (null !== $action && $action["cache"] > 0) {
173
-            $hash = $action["http"] . " " . $action["slug"];
173
+            $hash = $action["http"]." ".$action["slug"];
174 174
         }
175 175
         return sha1($hash);
176 176
     }
Please login to merge, or discard this patch.
src/base/Logger.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     /**
83 83
      * Método que escribe un log de Error
84
-     * @param $msg
84
+     * @param string $msg
85 85
      * @param array $context
86 86
      *
87 87
      * @return bool
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
     /**
95 95
      * Método que escribe un log de Warning
96
-     * @param $msg
96
+     * @param string $msg
97 97
      * @param array $context
98 98
      * @return bool
99 99
      */
Please login to merge, or discard this 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/Request.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@
 block discarded – undo
121 121
         return self::getInstance()->getHeader($name);
122 122
     }
123 123
 
124
+    /**
125
+     * @return string
126
+     */
124 127
     public function getHeader($name)
125 128
     {
126 129
         $header = null;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     {
217 217
         if (null === $url) $url = $this->server['HTTP_ORIGIN'];
218 218
         ob_start();
219
-        header('Location: ' . $url);
219
+        header('Location: '.$url);
220 220
         ob_end_clean();
221 221
         exit(_("Redireccionando..."));
222 222
     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         $host = $this->getServerName();
261 261
         $protocol = $protocol ? $this->getProtocol() : '';
262 262
         $url = '';
263
-        if (!empty($host) && !empty($protocol)) $url = $protocol . $host;
263
+        if (!empty($host) && !empty($protocol)) $url = $protocol.$host;
264 264
         return $url;
265 265
     }
266 266
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,10 @@  discard block
 block discarded – undo
8 8
     function getallheaders()
9 9
     {
10 10
         $headers = array();
11
-        foreach ($_SERVER as $h => $v)
12
-            if (preg_match('/HTTP_(.+)/', $h, $hp))
11
+        foreach ($_SERVER as $h => $v) {
12
+                    if (preg_match('/HTTP_(.+)/', $h, $hp))
13 13
                 $headers[$hp[1]] = $v;
14
+        }
14 15
         return $headers;
15 16
     }
16 17
 }
@@ -214,7 +215,9 @@  discard block
 block discarded – undo
214 215
      */
215 216
     public function redirect($url = null)
216 217
     {
217
-        if (null === $url) $url = $this->server['HTTP_ORIGIN'];
218
+        if (null === $url) {
219
+            $url = $this->server['HTTP_ORIGIN'];
220
+        }
218 221
         ob_start();
219 222
         header('Location: ' . $url);
220 223
         ob_end_clean();
@@ -260,7 +263,9 @@  discard block
 block discarded – undo
260 263
         $host = $this->getServerName();
261 264
         $protocol = $protocol ? $this->getProtocol() : '';
262 265
         $url = '';
263
-        if (!empty($host) && !empty($protocol)) $url = $protocol . $host;
266
+        if (!empty($host) && !empty($protocol)) {
267
+            $url = $protocol . $host;
268
+        }
264 269
         return $url;
265 270
     }
266 271
 
Please login to merge, or discard this patch.
src/base/Router.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
     /**
618 618
      * Método que extrae los parámetros de una función
619 619
      *
620
-     * @param array $sr
620
+     * @param string[] $sr
621 621
      * @param \ReflectionMethod $method
622 622
      *
623 623
      * @return array
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
      *
671 671
      * @param string $docComments
672 672
      *
673
-     * @return bool
673
+     * @return string
674 674
      */
675 675
     private function extractReflectionCacheability($docComments)
676 676
     {
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function init()
61 61
     {
62
-        if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) {
62
+        if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) {
63 63
             $this->hydrateRouting();
64 64
             $this->simpatize();
65
-        } else {
66
-            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE);
67
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE);
65
+        }else {
66
+            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE);
67
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE);
68 68
         }
69 69
     }
70 70
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 "success" => FALSE,
85 85
                 "error" => $e->getMessage(),
86 86
             )), 'application/json');
87
-        } else {
87
+        }else {
88 88
             if (NULL === $e) {
89 89
                 Logger::log('Not found page throwed without previus exception');
90 90
                 $e = new \Exception(_('Page not found'), 404);
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
             $this->checkRestrictedAccess($route);
126 126
             //Search action and execute
127 127
             return $this->searchAction($route);
128
-        } catch (AccessDeniedException $e) {
128
+        }catch (AccessDeniedException $e) {
129 129
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
130 130
             if ('login' === Config::getInstance()->get('admin_login')) {
131 131
                 return $this->redirectLogin($route);
132
-            } else {
132
+            }else {
133 133
                 return $this->sentAuthHeader();
134 134
             }
135
-        } catch (RouterException $r) {
135
+        }catch (RouterException $r) {
136 136
             if (FALSE !== preg_match('/\/$/', $route)) {
137 137
                 if (preg_match('/admin/', $route)) {
138 138
                     $default = Config::getInstance()->get('admin_action');
139
-                } else {
139
+                }else {
140 140
                     $default = Config::getInstance()->get('home_action');
141 141
                 }
142 142
 
143 143
                 return $this->execute($this->getRoute($default));
144 144
             }
145
-        } catch (\Exception $e) {
145
+        }catch (\Exception $e) {
146 146
             Logger::log($e->getMessage(), LOG_ERR);
147 147
             throw $e;
148 148
         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                 $class = $this->getClassToCall($action);
220 220
                 try {
221 221
                     return $this->executeCachedRoute($route, $action, $class, $get);
222
-                } catch (\Exception $e) {
222
+                }catch (\Exception $e) {
223 223
                     Logger::log($e->getMessage(), LOG_ERR);
224 224
                     throw new RouterException($e->getMessage(), 404, $e);
225 225
                 }
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
         if (file_exists($modules)) {
310 310
             $this->routing = $this->inspectDir($modules, "", $this->routing);
311 311
         }
312
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
312
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
313 313
         $home = Config::getInstance()->get('home_action');
314 314
         if (NULL !== $home || $home !== '') {
315 315
             $home_params = NULL;
316 316
             foreach ($this->routing as $pattern => $params) {
317 317
                 list($method, $route) = $this->extractHttpRoute($pattern);
318
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
318
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
319 319
                     $home_params = $params;
320 320
                 }
321 321
             }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php");
341 341
         foreach ($files as $file) {
342 342
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
343
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing);
343
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing);
344 344
         }
345 345
         $this->finder = new Finder();
346 346
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                             $httpMethod = $this->extractReflectionHttpMethod($docComments);
382 382
                             $visible = $this->extractReflectionVisibility($docComments);
383 383
                             $expiration = $this->extractReflectionCacheability($docComments);
384
-                            $routing[$httpMethod . "#|#" . $regex] = array(
384
+                            $routing[$httpMethod."#|#".$regex] = array(
385 385
                                 "class" => $namespace,
386 386
                                 "method" => $method->getName(),
387 387
                                 "params" => $params,
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
     {
412 412
         //Calculamos los dominios para las plantillas
413 413
         if ($class->hasConstant("DOMAIN")) {
414
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
415
-            $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
416
-            $path = realpath($path) . DIRECTORY_SEPARATOR;
414
+            $domain = "@".$class->getConstant("DOMAIN")."/";
415
+            $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
416
+            $path = realpath($path).DIRECTORY_SEPARATOR;
417 417
             $tpl_path = "templates";
418 418
             $public_path = "public";
419 419
             $model_path = "models";
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
                 $model_path = ucfirst($model_path);
424 424
             }
425 425
             if ($class->hasConstant("TPL")) {
426
-                $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
426
+                $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
427 427
             }
428 428
             $this->domains[$domain] = array(
429
-                "template" => $path . $tpl_path,
430
-                "model" => $path . $model_path,
431
-                "public" => $path . $public_path,
429
+                "template" => $path.$tpl_path,
430
+                "model" => $path.$model_path,
431
+                "public" => $path.$public_path,
432 432
             );
433 433
         }
434 434
 
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function simpatize()
443 443
     {
444
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
445
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
444
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
445
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
446 446
         $this->generateSlugs($absoluteTranslationFileName);
447 447
         Config::createDir(CONFIG_DIR);
448
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
448
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
449 449
 
450 450
         return $this;
451 451
     }
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
     public function getRoute($slug = '', $absolute = FALSE, $params = NULL)
497 497
     {
498 498
         if (strlen($slug) === 0) {
499
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
499
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
500 500
         }
501 501
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
502 502
             throw new RouterException(_("No existe la ruta especificada"));
503 503
         }
504
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
504
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
505 505
         if (!empty($params)) foreach ($params as $key => $value) {
506
-            $url = str_replace("{" . $key . "}", $value, $url);
506
+            $url = str_replace("{".$key."}", $value, $url);
507 507
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
508
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
508
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
509 509
         }
510 510
 
511 511
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             if (preg_match('/^\/admin(\/|$)/', $routePattern)) {
524 524
                 if (preg_match('/^PSFS/', $params["class"])) {
525 525
                     $profile = "superadmin";
526
-                } else {
526
+                }else {
527 527
                     $profile = "admin";
528 528
                 }
529 529
                 if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
     protected function getClassToCall($action)
576 576
     {
577 577
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
578
-        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
578
+        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
579 579
         $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass;
580 580
         return $class;
581 581
     }
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
         $expr = preg_quote($expr, '/');
595 595
         $expr = str_replace('###', '(.*)', $expr);
596 596
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
597
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
597
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
598 598
         return $matched;
599 599
     }
600 600
 
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
         if (count($parameters) > 0) foreach ($parameters as $param) {
632 632
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
633 633
                 $params[$param->getName()] = $param->getDefaultValue();
634
-                $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
634
+                $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
635 635
             }
636
-        } else $default = $regex;
636
+        }else $default = $regex;
637 637
 
638 638
         return array($regex, $default, $params);
639 639
     }
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
      */
690 690
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
691 691
     {
692
-        Logger::log('Executing route ' . $route);
692
+        Logger::log('Executing route '.$route);
693 693
         $this->session->setSessionKey("__CACHE__", $action);
694 694
         $cache = Cache::needCache();
695 695
         $execute = TRUE;
696 696
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
697 697
             $cacheDataName = $this->cache->getRequestCacheHash();
698
-            $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () {
698
+            $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() {
699 699
             });
700 700
             if (NULL !== $cachedData) {
701
-                $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () {
701
+                $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() {
702 702
                 }, Cache::JSON);
703 703
                 Template::getInstance()->renderCache($cachedData, $headers);
704 704
                 $execute = FALSE;
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
         $translations = array();
748 748
         if (file_exists($absoluteTranslationFileName)) {
749 749
             include($absoluteTranslationFileName);
750
-        } else {
750
+        }else {
751 751
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
752 752
         }
753 753
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -286,8 +286,10 @@  discard block
 block discarded – undo
286 286
         $_route = explode("/", $url['path']);
287 287
         $_pattern = explode("/", $pattern);
288 288
         $get = array();
289
-        if (!empty($_pattern)) foreach ($_pattern as $index => $component) {
289
+        if (!empty($_pattern)) {
290
+            foreach ($_pattern as $index => $component) {
290 291
             $_get = array();
292
+        }
291 293
             preg_match_all('/^\{(.*)\}$/i', $component, $_get);
292 294
             if (!empty($_get[1]) && isset($_route[$index])) {
293 295
                 $get[array_pop($_get[1])] = $_route[$index];
@@ -502,8 +504,10 @@  discard block
 block discarded – undo
502 504
             throw new RouterException(_("No existe la ruta especificada"));
503 505
         }
504 506
         $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
505
-        if (!empty($params)) foreach ($params as $key => $value) {
507
+        if (!empty($params)) {
508
+            foreach ($params as $key => $value) {
506 509
             $url = str_replace("{" . $key . "}", $value, $url);
510
+        }
507 511
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
508 512
             $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
509 513
         }
@@ -628,12 +632,16 @@  discard block
 block discarded – undo
628 632
         $default = '';
629 633
         $params = array();
630 634
         $parameters = $method->getParameters();
631
-        if (count($parameters) > 0) foreach ($parameters as $param) {
635
+        if (count($parameters) > 0) {
636
+            foreach ($parameters as $param) {
632 637
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
633 638
                 $params[$param->getName()] = $param->getDefaultValue();
639
+        }
634 640
                 $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
635 641
             }
636
-        } else $default = $regex;
642
+        } else {
643
+            $default = $regex;
644
+        }
637 645
 
638 646
         return array($regex, $default, $params);
639 647
     }
Please login to merge, or discard this patch.
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/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.