Passed
Push — master ( 2955c9...ee5866 )
by Fran
05:26
created
src/controller/ConfigController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      * @GET
21 21
      * @route /admin/config/params
22 22
      * @visible false
23
-     * @return mixed
23
+     * @return string|null
24 24
      */
25 25
     public function getConfigParams() {
26 26
         $response = array_merge(Config::$required, Config::$optional);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     public function getConfigParams() {
26 26
         $response = array_merge(Config::$required, Config::$optional);
27 27
         $domains = Router::getInstance()->getDomains();
28
-        foreach($domains as $domain => $routes) {
28
+        foreach ($domains as $domain => $routes) {
29 29
             $pDomain = str_replace('@', '', $domain);
30 30
             $pDomain = str_replace('/', '', $pDomain);
31
-            $response[] = strtolower($pDomain) . '.api.secret';
31
+            $response[] = strtolower($pDomain).'.api.secret';
32 32
         }
33 33
         return $this->json($response);
34 34
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function config()
44 44
     {
45
-        Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
45
+        Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri());
46 46
         /* @var $form \PSFS\base\config\ConfigForm */
47 47
         $form = new ConfigForm();
48 48
         $form->build();
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 }
80 80
                 Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente"));
81 81
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
82
-            } else {
82
+            }else {
83 83
                 throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
84 84
             }
85 85
         }
Please login to merge, or discard this patch.
src/controller/RouteController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      * @GET
29 29
      * @route /admin/routes/show
30 30
      * @visible false
31
-     * @return mixed
31
+     * @return string|null
32 32
      */
33 33
     public function getRouting()
34 34
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
             $router->simpatize();
52 52
             Security::getInstance()->setFlash("callback_message", _("Rutas generadas correctamente"));
53 53
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
54
-        } catch(\Exception $e) {
54
+        }catch (\Exception $e) {
55 55
             Logger::log($e->getMessage(), LOG_ERR);
56 56
             Security::getInstance()->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs"));
57 57
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function init()
56 56
     {
57
-        if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) {
57
+        if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) {
58 58
             $this->hydrateRouting();
59 59
             $this->simpatize();
60
-        } else {
61
-            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE);
62
-            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE);
60
+        }else {
61
+            list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE);
62
+            $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE);
63 63
         }
64 64
     }
65 65
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 "success" => FALSE,
80 80
                 "error" => $e->getMessage(),
81 81
             )), 'application/json');
82
-        } else {
82
+        }else {
83 83
             if (NULL === $e) {
84 84
                 Logger::log('Not found page throwed without previus exception');
85 85
                 $e = new \Exception(_('Page not found'), 404);
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function getAllRoutes() {
110 110
         $routes = [];
111
-        foreach($this->routing as $path => $route) {
112
-            if(array_key_exists('slug', $route)) {
111
+        foreach ($this->routing as $path => $route) {
112
+            if (array_key_exists('slug', $route)) {
113 113
                 $routes[$route['slug']] = $path;
114 114
             }
115 115
         }
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
             $this->checkRestrictedAccess($route);
135 135
             //Search action and execute
136 136
             $this->searchAction($route);
137
-        } catch (AccessDeniedException $e) {
137
+        }catch (AccessDeniedException $e) {
138 138
             Logger::log(_('Solicitamos credenciales de acceso a zona restringida'));
139 139
             if ('login' === Config::getInstance()->get('admin_login')) {
140 140
                 return $this->redirectLogin($route);
141
-            } else {
141
+            }else {
142 142
                 return $this->sentAuthHeader();
143 143
             }
144
-        } catch (RouterException $r) {
144
+        }catch (RouterException $r) {
145 145
             if (FALSE !== preg_match('/\/$/', $route)) {
146 146
                 if (preg_match('/admin/', $route)) {
147 147
                     $default = Config::getInstance()->get('admin_action');
148
-                } else {
148
+                }else {
149 149
                     $default = Config::getInstance()->get('home_action');
150 150
                 }
151 151
 
152 152
                 return $this->execute($this->getRoute($default));
153 153
             }
154
-        } catch (\Exception $e) {
154
+        }catch (\Exception $e) {
155 155
             Logger::log($e->getMessage(), LOG_ERR);
156 156
             throw $e;
157 157
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 $class = $this->getClassToCall($action);
229 229
                 try {
230 230
                     $this->executeCachedRoute($route, $action, $class, $get);
231
-                } catch (\Exception $e) {
231
+                }catch (\Exception $e) {
232 232
                     Logger::log($e->getMessage(), LOG_ERR);
233 233
                     throw new RouterException($e->getMessage(), 404, $e);
234 234
                 }
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
         if (file_exists($modules)) {
319 319
             $this->routing = $this->inspectDir($modules, "", $this->routing);
320 320
         }
321
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);
321
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);
322 322
         $home = Config::getInstance()->get('home_action');
323 323
         if (NULL !== $home || $home !== '') {
324 324
             $home_params = NULL;
325 325
             foreach ($this->routing as $pattern => $params) {
326 326
                 list($method, $route) = $this->extractHttpRoute($pattern);
327
-                if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) {
327
+                if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) {
328 328
                     $home_params = $params;
329 329
                 }
330 330
             }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php");
350 350
         foreach ($files as $file) {
351 351
             $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname()));
352
-            $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing);
352
+            $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing);
353 353
         }
354 354
         $this->finder = new Finder();
355 355
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                             $httpMethod = $this->extractReflectionHttpMethod($docComments);
391 391
                             $visible = $this->extractReflectionVisibility($docComments);
392 392
                             $expiration = $this->extractReflectionCacheability($docComments);
393
-                            $routing[$httpMethod . "#|#" . $regex] = array(
393
+                            $routing[$httpMethod."#|#".$regex] = array(
394 394
                                 "class" => $namespace,
395 395
                                 "method" => $method->getName(),
396 396
                                 "params" => $params,
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
     {
421 421
         //Calculamos los dominios para las plantillas
422 422
         if ($class->hasConstant("DOMAIN")) {
423
-            $domain = "@" . $class->getConstant("DOMAIN") . "/";
424
-            $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
425
-            $path = realpath($path) . DIRECTORY_SEPARATOR;
423
+            $domain = "@".$class->getConstant("DOMAIN")."/";
424
+            $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
425
+            $path = realpath($path).DIRECTORY_SEPARATOR;
426 426
             $tpl_path = "templates";
427 427
             $public_path = "public";
428 428
             $model_path = "models";
@@ -432,12 +432,12 @@  discard block
 block discarded – undo
432 432
                 $model_path = ucfirst($model_path);
433 433
             }
434 434
             if ($class->hasConstant("TPL")) {
435
-                $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL");
435
+                $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL");
436 436
             }
437 437
             $this->domains[$domain] = array(
438
-                "template" => $path . $tpl_path,
439
-                "model" => $path . $model_path,
440
-                "public" => $path . $public_path,
438
+                "template" => $path.$tpl_path,
439
+                "model" => $path.$model_path,
440
+                "public" => $path.$public_path,
441 441
             );
442 442
         }
443 443
 
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
      */
451 451
     public function simpatize()
452 452
     {
453
-        $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";
454
-        $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;
453
+        $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";
454
+        $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;
455 455
         $this->generateSlugs($absoluteTranslationFileName);
456 456
         Config::createDir(CONFIG_DIR);
457
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
457
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);
458 458
 
459 459
         return $this;
460 460
     }
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
     public function getRoute($slug = '', $absolute = FALSE, $params = NULL)
506 506
     {
507 507
         if (strlen($slug) === 0) {
508
-            return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';
508
+            return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';
509 509
         }
510 510
         if (NULL === $slug || !array_key_exists($slug, $this->slugs)) {
511 511
             throw new RouterException(_("No existe la ruta especificada"));
512 512
         }
513
-        $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];
513
+        $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];
514 514
         if (!empty($params)) foreach ($params as $key => $value) {
515
-            $url = str_replace("{" . $key . "}", $value, $url);
515
+            $url = str_replace("{".$key."}", $value, $url);
516 516
         } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) {
517
-            $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
517
+            $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];
518 518
         }
519 519
 
520 520
         return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url);
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             if (preg_match('/^\/admin(\/|$)/', $routePattern)) {
533 533
                 if (preg_match('/^\\\?PSFS/', $params["class"])) {
534 534
                     $profile = "superadmin";
535
-                } else {
535
+                }else {
536 536
                     $profile = "admin";
537 537
                 }
538 538
                 if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
     protected function getClassToCall($action)
585 585
     {
586 586
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
587
-        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"];
587
+        $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"];
588 588
         $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass;
589 589
         return $class;
590 590
     }
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
         $expr = preg_quote($expr, '/');
604 604
         $expr = str_replace('###', '(.*)', $expr);
605 605
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
606
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
606
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
607 607
         return $matched;
608 608
     }
609 609
 
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
         if (count($parameters) > 0) foreach ($parameters as $param) {
641 641
             if ($param->isOptional() && !is_array($param->getDefaultValue())) {
642 642
                 $params[$param->getName()] = $param->getDefaultValue();
643
-                $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
643
+                $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
644 644
             }
645
-        } else $default = $regex;
645
+        }else $default = $regex;
646 646
 
647 647
         return array($regex, $default, $params);
648 648
     }
@@ -698,16 +698,16 @@  discard block
 block discarded – undo
698 698
      */
699 699
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
700 700
     {
701
-        Logger::log('Executing route ' . $route);
701
+        Logger::log('Executing route '.$route);
702 702
         Security::getInstance()->setSessionKey("__CACHE__", $action);
703 703
         $cache = Cache::needCache();
704 704
         $execute = TRUE;
705 705
         if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) {
706 706
             $cacheDataName = $this->cache->getRequestCacheHash();
707
-            $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () {
707
+            $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() {
708 708
             });
709 709
             if (NULL !== $cachedData) {
710
-                $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () {
710
+                $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() {
711 711
                 }, Cache::JSON);
712 712
                 Template::getInstance()->renderCache($cachedData, $headers);
713 713
                 $execute = FALSE;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
         $translations = array();
755 755
         if (file_exists($absoluteTranslationFileName)) {
756 756
             include($absoluteTranslationFileName);
757
-        } else {
757
+        }else {
758 758
             Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
759 759
         }
760 760
 
Please login to merge, or discard this patch.
src/controller/base/Admin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
  * @package PSFS\controller
13 13
  * @domain ROOT
14 14
  */
15
-class Admin extends AuthAdminController{
15
+class Admin extends AuthAdminController {
16 16
 
17 17
     const DOMAIN = 'ROOT';
18 18
 
Please login to merge, or discard this patch.
src/controller/I18nController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@
 block discarded – undo
38 38
         //Generating the templates translations
39 39
         $translations = $this->tpl->regenerateTemplates();
40 40
 
41
-        $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
42
-        $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
41
+        $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
42
+        $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
43 43
 
44 44
         //xgettext localizations
45 45
         $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale));
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@
 block discarded – undo
33 33
     public function getTranslations($locale)
34 34
     {
35 35
         //Default locale
36
-        if (null === $locale) $locale = $this->config->get("default_language");
36
+        if (null === $locale) {
37
+            $locale = $this->config->get("default_language");
38
+        }
37 39
 
38 40
         //Generating the templates translations
39 41
         $translations = $this->tpl->regenerateTemplates();
Please login to merge, or discard this patch.
src/controller/UserController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
                 Logger::log('Configuration saved successful');
54 54
                 Security::getInstance()->setFlash("callback_message", _("Usuario agregado correctamente"));
55 55
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin"), true);
56
-            } else {
56
+            }else {
57 57
                 throw new ConfigException(_('Error al guardar los administradores, prueba a cambiar los permisos'));
58 58
             }
59 59
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 $cookies = array(
105 105
                     array(
106 106
                         "name" => Security::getInstance()->getHash(),
107
-                        "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")),
107
+                        "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")),
108 108
                         "expire" => time() + 3600,
109 109
                         "http" => true,
110 110
                     )
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                     'status_message' => _("Acceso permitido... redirigiendo!!"),
116 116
                     'delay' => 1,
117 117
                 );
118
-            } else {
118
+            }else {
119 119
                 $form->setError("user", _("El usuario no tiene acceso a la web"));
120 120
             }
121 121
         }
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function generateModule()
32 32
     {
33
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
33
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
34 34
         /* @var $form \PSFS\base\config\ConfigForm */
35 35
         $form = new ModuleForm();
36 36
         $form->build();
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
                 $this->gen->createStructureModule($module, $force, $type);
61 61
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
62 62
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
63
-            } catch (\Exception $e) {
64
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
63
+            }catch (\Exception $e) {
64
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
65 65
                 throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403);
66 66
             }
67 67
         }
Please login to merge, or discard this patch.