@@ -107,7 +107,7 @@  | 
                                                    ||
| 107 | 107 | |
| 108 | 108 | /**  | 
                                                        
| 109 | 109 | * Método que guarda en fichero los datos pasados  | 
                                                        
| 110 | - * @param $path  | 
                                                        |
| 110 | + * @param string $path  | 
                                                        |
| 111 | 111 | * @param $data  | 
                                                        
| 112 | 112 | * @param int $transform  | 
                                                        
| 113 | 113 | * @param boolean $absolutePath  | 
                                                        
@@ -131,7 +131,7 @@  | 
                                                    ||
| 131 | 131 |                  if (null !== $function && $this->hasExpiredCache($path, $expires)) { | 
                                                        
| 132 | 132 | $data = call_user_func($function);  | 
                                                        
| 133 | 133 | $this->storeData($path, $data, $transform);  | 
                                                        
| 134 | -                } else { | 
                                                        |
| 134 | +                }else { | 
                                                        |
| 135 | 135 | $data = $this->getDataFromFile($path, $transform);  | 
                                                        
| 136 | 136 | }  | 
                                                        
| 137 | 137 | }  | 
                                                        
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | * Método que copia los recursos recursivamente  | 
                                                        
| 131 | 131 | * @param string $dest  | 
                                                        
| 132 | 132 | * @param boolean $force  | 
                                                        
| 133 | - * @param $filename_path  | 
                                                        |
| 133 | + * @param string $filename_path  | 
                                                        |
| 134 | 134 | * @param boolean $debug  | 
                                                        
| 135 | 135 | */  | 
                                                        
| 136 | 136 | private static function copyResources($dest, $force, $filename_path, $debug)  | 
                                                        
@@ -155,7 +155,7 @@ discard block  | 
                                                    ||
| 155 | 155 | * @param string $path  | 
                                                        
| 156 | 156 | * @param $domains  | 
                                                        
| 157 | 157 | *  | 
                                                        
| 158 | - * @return mixed  | 
                                                        |
| 158 | + * @return string  | 
                                                        |
| 159 | 159 | */  | 
                                                        
| 160 | 160 | private static function extractPathname($path, $domains)  | 
                                                        
| 161 | 161 |          { | 
                                                        
@@ -52,7 +52,7 @@  | 
                                                    ||
| 52 | 52 | $router = Router::getInstance();  | 
                                                        
| 53 | 53 |              try { | 
                                                        
| 54 | 54 | return $router->getRoute($path, $absolute, $params);  | 
                                                        
| 55 | - } catch (\Exception $e)  | 
                                                        |
| 55 | + }catch (\Exception $e)  | 
                                                        |
| 56 | 56 |              { | 
                                                        
| 57 | 57 |                  return $router->getRoute('', $absolute, $params); | 
                                                        
| 58 | 58 | }  | 
                                                        
@@ -141,7 +141,7 @@ discard block  | 
                                                    ||
| 141 | 141 |                      if (is_dir($filename_path)) { | 
                                                        
| 142 | 142 | Config::createDir(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);  | 
                                                        
| 143 | 143 | Template::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);  | 
                                                        
| 144 | -                    }else { | 
                                                        |
| 144 | +                    } else { | 
                                                        |
| 145 | 145 |                          if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { | 
                                                        
| 146 | 146 |                              throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); | 
                                                        
| 147 | 147 | }  | 
                                                        
@@ -198,8 +198,11 @@ discard block  | 
                                                    ||
| 198 | 198 | private static function putResourceContent($name, $filename_path, $base, $file_path)  | 
                                                        
| 199 | 199 |          { | 
                                                        
| 200 | 200 | $data = file_get_contents($filename_path);  | 
                                                        
| 201 | - if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);  | 
                                                        |
| 202 | - else file_put_contents($base.$file_path, $data);  | 
                                                        |
| 201 | +            if (!empty($name)) { | 
                                                        |
| 202 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);  | 
                                                        |
| 203 | +            } else { | 
                                                        |
| 204 | + file_put_contents($base.$file_path, $data);  | 
                                                        |
| 205 | + }  | 
                                                        |
| 203 | 206 | }  | 
                                                        
| 204 | 207 | |
| 205 | 208 | /**  | 
                                                        
@@ -95,6 +95,10 @@ discard block  | 
                                                    ||
| 95 | 95 | * @return string|null  | 
                                                        
| 96 | 96 | */  | 
                                                        
| 97 | 97 |      public static function header($name) { return self::getInstance()->getHeader($name); } | 
                                                        
| 98 | +  | 
                                                        |
| 99 | + /**  | 
                                                        |
| 100 | + * @return string  | 
                                                        |
| 101 | + */  | 
                                                        |
| 98 | 102 | public function getHeader($name)  | 
                                                        
| 99 | 103 |      { | 
                                                        
| 100 | 104 | $header = null;  | 
                                                        
@@ -107,7 +111,7 @@ discard block  | 
                                                    ||
| 107 | 111 | |
| 108 | 112 | /**  | 
                                                        
| 109 | 113 | * Método que devuelve la url solicitada  | 
                                                        
| 110 | - * @return string|null  | 
                                                        |
| 114 | + * @return string  | 
                                                        |
| 111 | 115 | */  | 
                                                        
| 112 | 116 |      public static function requestUri(){ return self::getInstance()->getRequestUri(); } | 
                                                        
| 113 | 117 | |
@@ -4,14 +4,14 @@ discard block  | 
                                                    ||
| 4 | 4 | |
| 5 | 5 | use PSFS\base\types\SingletonTrait;  | 
                                                        
| 6 | 6 | |
| 7 | -if(!function_exists("getallheaders")) | 
                                                        |
| 7 | +if (!function_exists("getallheaders")) | 
                                                        |
| 8 | 8 |  { | 
                                                        
| 9 | 9 | function getallheaders()  | 
                                                        
| 10 | 10 |      { | 
                                                        
| 11 | 11 | $headers = array();  | 
                                                        
| 12 | - foreach($_SERVER as $h=>$v)  | 
                                                        |
| 13 | -            if(preg_match('/HTTP_(.+)/',$h,$hp)) | 
                                                        |
| 14 | - $headers[$hp[1]]=$v;  | 
                                                        |
| 12 | + foreach ($_SERVER as $h=>$v)  | 
                                                        |
| 13 | +            if (preg_match('/HTTP_(.+)/', $h, $hp)) | 
                                                        |
| 14 | + $headers[$hp[1]] = $v;  | 
                                                        |
| 15 | 15 | return $headers;  | 
                                                        
| 16 | 16 | }  | 
                                                        
| 17 | 17 | }  | 
                                                        
@@ -109,12 +109,12 @@ discard block  | 
                                                    ||
| 109 | 109 | * Método que devuelve la url solicitada  | 
                                                        
| 110 | 110 | * @return string|null  | 
                                                        
| 111 | 111 | */  | 
                                                        
| 112 | -    public static function requestUri(){ return self::getInstance()->getRequestUri(); } | 
                                                        |
| 112 | +    public static function requestUri() { return self::getInstance()->getRequestUri(); } | 
                                                        |
| 113 | 113 | |
| 114 | 114 | /**  | 
                                                        
| 115 | 115 | * @return string  | 
                                                        
| 116 | 116 | */  | 
                                                        
| 117 | -    public function getRequestUri(){ return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } | 
                                                        |
| 117 | +    public function getRequestUri() { return array_key_exists('REQUEST_URI', $this->server) ? $this->server['REQUEST_URI'] : ''; } | 
                                                        |
| 118 | 118 | |
| 119 | 119 | /**  | 
                                                        
| 120 | 120 | * Método que devuelve el idioma de la petición  | 
                                                        
@@ -9,9 +9,10 @@ discard block  | 
                                                    ||
| 9 | 9 | function getallheaders()  | 
                                                        
| 10 | 10 |      { | 
                                                        
| 11 | 11 | $headers = array();  | 
                                                        
| 12 | - foreach($_SERVER as $h=>$v)  | 
                                                        |
| 13 | -            if(preg_match('/HTTP_(.+)/',$h,$hp)) | 
                                                        |
| 12 | +        foreach($_SERVER as $h=>$v) { | 
                                                        |
| 13 | +                    if(preg_match('/HTTP_(.+)/',$h,$hp)) | 
                                                        |
| 14 | 14 | $headers[$hp[1]]=$v;  | 
                                                        
| 15 | + }  | 
                                                        |
| 15 | 16 | return $headers;  | 
                                                        
| 16 | 17 | }  | 
                                                        
| 17 | 18 | }  | 
                                                        
@@ -180,7 +181,9 @@ discard block  | 
                                                    ||
| 180 | 181 | */  | 
                                                        
| 181 | 182 | public function redirect($url = null)  | 
                                                        
| 182 | 183 |      { | 
                                                        
| 183 | - if (null === $url) $url = $this->server['HTTP_ORIGIN'];  | 
                                                        |
| 184 | +        if (null === $url) { | 
                                                        |
| 185 | + $url = $this->server['HTTP_ORIGIN'];  | 
                                                        |
| 186 | + }  | 
                                                        |
| 184 | 187 | ob_start();  | 
                                                        
| 185 | 188 |          header('Location: '.$url); | 
                                                        
| 186 | 189 | ob_end_clean();  | 
                                                        
@@ -226,7 +229,9 @@ discard block  | 
                                                    ||
| 226 | 229 | $host = $this->getServerName();  | 
                                                        
| 227 | 230 | $protocol = $protocol ? $this->getProtocol() : '';  | 
                                                        
| 228 | 231 | $url = '';  | 
                                                        
| 229 | - if (!empty($host) && !empty($protocol)) $url = $protocol.$host;  | 
                                                        |
| 232 | +        if (!empty($host) && !empty($protocol)) { | 
                                                        |
| 233 | + $url = $protocol.$host;  | 
                                                        |
| 234 | + }  | 
                                                        |
| 230 | 235 | return $url;  | 
                                                        
| 231 | 236 | }  | 
                                                        
| 232 | 237 | |
@@ -588,7 +588,7 @@ discard block  | 
                                                    ||
| 588 | 588 | /**  | 
                                                        
| 589 | 589 | * Método que extrae los parámetros de una función  | 
                                                        
| 590 | 590 | *  | 
                                                        
| 591 | - * @param array $sr  | 
                                                        |
| 591 | + * @param string[] $sr  | 
                                                        |
| 592 | 592 | * @param \ReflectionMethod $method  | 
                                                        
| 593 | 593 | *  | 
                                                        
| 594 | 594 | * @return array  | 
                                                        
@@ -642,7 +642,7 @@ discard block  | 
                                                    ||
| 642 | 642 | *  | 
                                                        
| 643 | 643 | * @param string $docComments  | 
                                                        
| 644 | 644 | *  | 
                                                        
| 645 | - * @return bool  | 
                                                        |
| 645 | + * @return string  | 
                                                        |
| 646 | 646 | */  | 
                                                        
| 647 | 647 | private function extractReflectionCacheability($docComments)  | 
                                                        
| 648 | 648 |          { | 
                                                        
@@ -260,8 +260,10 @@ discard block  | 
                                                    ||
| 260 | 260 |              $_route = explode("/", $url['path']); | 
                                                        
| 261 | 261 |              $_pattern = explode("/", $pattern); | 
                                                        
| 262 | 262 | $get = array();  | 
                                                        
| 263 | -            if (!empty($_pattern)) foreach ($_pattern as $index => $component) { | 
                                                        |
| 263 | +            if (!empty($_pattern)) { | 
                                                        |
| 264 | +                foreach ($_pattern as $index => $component) { | 
                                                        |
| 264 | 265 | $_get = array();  | 
                                                        
| 266 | + }  | 
                                                        |
| 265 | 267 |                  preg_match_all('/^\{(.*)\}$/i', $component, $_get); | 
                                                        
| 266 | 268 |                  if (!empty($_get[1]) && isset($_route[$index])) { | 
                                                        
| 267 | 269 | $get[array_pop($_get[1])] = $_route[$index];  | 
                                                        
@@ -476,8 +478,10 @@ discard block  | 
                                                    ||
| 476 | 478 |                  throw new RouterException(_("No existe la ruta especificada")); | 
                                                        
| 477 | 479 | }  | 
                                                        
| 478 | 480 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];  | 
                                                        
| 479 | -            if (!empty($params)) foreach ($params as $key => $value) { | 
                                                        |
| 481 | +            if (!empty($params)) { | 
                                                        |
| 482 | +                foreach ($params as $key => $value) { | 
                                                        |
| 480 | 483 |                  $url = str_replace("{" . $key . "}", $value, $url); | 
                                                        
| 484 | + }  | 
                                                        |
| 481 | 485 |              } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { | 
                                                        
| 482 | 486 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];  | 
                                                        
| 483 | 487 | }  | 
                                                        
@@ -599,12 +603,16 @@ discard block  | 
                                                    ||
| 599 | 603 | $default = '';  | 
                                                        
| 600 | 604 | $params = array();  | 
                                                        
| 601 | 605 | $parameters = $method->getParameters();  | 
                                                        
| 602 | -            if (count($parameters) > 0) foreach ($parameters as $param) { | 
                                                        |
| 606 | +            if (count($parameters) > 0) { | 
                                                        |
| 607 | +                foreach ($parameters as $param) { | 
                                                        |
| 603 | 608 |                  if ($param->isOptional() && !is_array($param->getDefaultValue())) { | 
                                                        
| 604 | 609 | $params[$param->getName()] = $param->getDefaultValue();  | 
                                                        
| 610 | + }  | 
                                                        |
| 605 | 611 |                      $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); | 
                                                        
| 606 | 612 | }  | 
                                                        
| 607 | - } else $default = $regex;  | 
                                                        |
| 613 | +            } else { | 
                                                        |
| 614 | + $default = $regex;  | 
                                                        |
| 615 | + }  | 
                                                        |
| 608 | 616 | |
| 609 | 617 | return array($regex, $default, $params);  | 
                                                        
| 610 | 618 | }  | 
                                                        
@@ -59,12 +59,12 @@ discard block  | 
                                                    ||
| 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  | 
                                                    ||
| 84 | 84 | "success" => FALSE,  | 
                                                        
| 85 | 85 | "error" => $e->getMessage(),  | 
                                                        
| 86 | 86 | )), 'application/json');  | 
                                                        
| 87 | -            } else { | 
                                                        |
| 87 | +            }else { | 
                                                        |
| 88 | 88 |                  if (NULL === $e) { | 
                                                        
| 89 | 89 |                      $e = new \Exception(_('Página no encontrada'), 404); | 
                                                        
| 90 | 90 | }  | 
                                                        
@@ -124,24 +124,24 @@ discard block  | 
                                                    ||
| 124 | 124 | |
| 125 | 125 | //Search action and execute  | 
                                                        
| 126 | 126 | return $this->searchAction($route);  | 
                                                        
| 127 | -            } catch (AccessDeniedException $e) { | 
                                                        |
| 127 | +            }catch (AccessDeniedException $e) { | 
                                                        |
| 128 | 128 |                  Logger::getInstance()->debugLog(_('Solicitamos credenciales de acceso a zona restringida')); | 
                                                        
| 129 | 129 |                  if ('login' === Config::getInstance()->get('admin_login')) { | 
                                                        
| 130 | 130 | return $this->redirectLogin($route);  | 
                                                        
| 131 | -                } else { | 
                                                        |
| 131 | +                }else { | 
                                                        |
| 132 | 132 | return $this->sentAuthHeader();  | 
                                                        
| 133 | 133 | }  | 
                                                        
| 134 | -            } catch (RouterException $r) { | 
                                                        |
| 134 | +            }catch (RouterException $r) { | 
                                                        |
| 135 | 135 |                  if (FALSE !== preg_match('/\/$/', $route)) { | 
                                                        
| 136 | 136 |                      if (preg_match('/admin/', $route)) { | 
                                                        
| 137 | 137 |                          $default = Config::getInstance()->get('admin_action'); | 
                                                        
| 138 | -                    } else { | 
                                                        |
| 138 | +                    }else { | 
                                                        |
| 139 | 139 |                          $default = Config::getInstance()->get('home_action'); | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
| 142 | 142 | return $this->execute($this->getRoute($default));  | 
                                                        
| 143 | 143 | }  | 
                                                        
| 144 | -            } catch (\Exception $e) { | 
                                                        |
| 144 | +            }catch (\Exception $e) { | 
                                                        |
| 145 | 145 | Logger::getInstance()->errorLog($e->getMessage());  | 
                                                        
| 146 | 146 | throw $e;  | 
                                                        
| 147 | 147 | }  | 
                                                        
@@ -157,7 +157,7 @@ discard block  | 
                                                    ||
| 157 | 157 |              $corsEnabled = Config::getInstance()->get('cors.enabled'); | 
                                                        
| 158 | 158 | $request = Request::getInstance();  | 
                                                        
| 159 | 159 |              if (NULL !== $corsEnabled && null !== $request->getServer('HTTP_REFERER')) { | 
                                                        
| 160 | -                if($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { | 
                                                        |
| 160 | +                if ($corsEnabled == '*' || preg_match($corsEnabled, $request->getServer('HTTP_REFERER'))) { | 
                                                        |
| 161 | 161 |                      if (!$this->headersSent) { | 
                                                        
| 162 | 162 |                          header("Access-Control-Allow-Credentials: true"); | 
                                                        
| 163 | 163 |                          header("Access-Control-Allow-Origin: *"); | 
                                                        
@@ -165,8 +165,8 @@ discard block  | 
                                                    ||
| 165 | 165 |                          header("Access-Control-Allow-Headers: Access-Control-Allow-Methods, Access-Control-Allow-Headers, Access-Control-Allow-Origin, Origin, X-Requested-With, Content-Type, Accept, Authorization"); | 
                                                        
| 166 | 166 | $this->headersSent = true;  | 
                                                        
| 167 | 167 | }  | 
                                                        
| 168 | -                    if(Request::getInstance()->getMethod() == 'OPTIONS') { | 
                                                        |
| 169 | - header( "HTTP/1.1 200 OK" );  | 
                                                        |
| 168 | +                    if (Request::getInstance()->getMethod() == 'OPTIONS') { | 
                                                        |
| 169 | +                        header("HTTP/1.1 200 OK"); | 
                                                        |
| 170 | 170 | exit();  | 
                                                        
| 171 | 171 | }  | 
                                                        
| 172 | 172 | }  | 
                                                        
@@ -195,7 +195,7 @@ discard block  | 
                                                    ||
| 195 | 195 | $class = $this->getClassToCall($action);  | 
                                                        
| 196 | 196 |                      try { | 
                                                        
| 197 | 197 | return $this->executeCachedRoute($route, $action, $class, $get);  | 
                                                        
| 198 | -                    } catch (\Exception $e) { | 
                                                        |
| 198 | +                    }catch (\Exception $e) { | 
                                                        |
| 199 | 199 | Logger::getInstance()->debugLog($e->getMessage(), array($e->getFile(), $e->getLine()));  | 
                                                        
| 200 | 200 | throw new RouterException($e->getMessage(), 404, $e);  | 
                                                        
| 201 | 201 | }  | 
                                                        
@@ -283,13 +283,13 @@ discard block  | 
                                                    ||
| 283 | 283 |              if (file_exists($modules)) { | 
                                                        
| 284 | 284 | $this->routing = $this->inspectDir($modules, "", $this->routing);  | 
                                                        
| 285 | 285 | }  | 
                                                        
| 286 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE);  | 
                                                        |
| 286 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE);  | 
                                                        |
| 287 | 287 |              $home = Config::getInstance()->get('home_action'); | 
                                                        
| 288 | 288 |              if (NULL !== $home || $home !== '') { | 
                                                        
| 289 | 289 | $home_params = NULL;  | 
                                                        
| 290 | 290 |                  foreach ($this->routing as $pattern => $params) { | 
                                                        
| 291 | 291 | list($method, $route) = $this->extractHttpRoute($pattern);  | 
                                                        
| 292 | -                    if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { | 
                                                        |
| 292 | +                    if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { | 
                                                        |
| 293 | 293 | $home_params = $params;  | 
                                                        
| 294 | 294 | }  | 
                                                        
| 295 | 295 | }  | 
                                                        
@@ -314,7 +314,7 @@ discard block  | 
                                                    ||
| 314 | 314 |              $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); | 
                                                        
| 315 | 315 |              foreach ($files as $file) { | 
                                                        
| 316 | 316 |                  $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); | 
                                                        
| 317 | -                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); | 
                                                        |
| 317 | +                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); | 
                                                        |
| 318 | 318 | }  | 
                                                        
| 319 | 319 | $this->finder = new Finder();  | 
                                                        
| 320 | 320 | |
@@ -355,7 +355,7 @@ discard block  | 
                                                    ||
| 355 | 355 | $httpMethod = $this->extractReflectionHttpMethod($docComments);  | 
                                                        
| 356 | 356 | $visible = $this->extractReflectionVisibility($docComments);  | 
                                                        
| 357 | 357 | $expiration = $this->extractReflectionCacheability($docComments);  | 
                                                        
| 358 | - $routing[$httpMethod . "#|#" . $regex] = array(  | 
                                                        |
| 358 | + $routing[$httpMethod."#|#".$regex] = array(  | 
                                                        |
| 359 | 359 | "class" => $namespace,  | 
                                                        
| 360 | 360 | "method" => $method->getName(),  | 
                                                        
| 361 | 361 | "params" => $params,  | 
                                                        
@@ -385,9 +385,9 @@ discard block  | 
                                                    ||
| 385 | 385 |          { | 
                                                        
| 386 | 386 | //Calculamos los dominios para las plantillas  | 
                                                        
| 387 | 387 |              if ($class->hasConstant("DOMAIN")) { | 
                                                        
| 388 | -                $domain = "@" . $class->getConstant("DOMAIN") . "/"; | 
                                                        |
| 389 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;  | 
                                                        |
| 390 | - $path = realpath($path) . DIRECTORY_SEPARATOR;  | 
                                                        |
| 388 | +                $domain = "@".$class->getConstant("DOMAIN")."/"; | 
                                                        |
| 389 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;  | 
                                                        |
| 390 | + $path = realpath($path).DIRECTORY_SEPARATOR;  | 
                                                        |
| 391 | 391 | $tpl_path = "templates";  | 
                                                        
| 392 | 392 | $public_path = "public";  | 
                                                        
| 393 | 393 | $model_path = "models";  | 
                                                        
@@ -397,12 +397,12 @@ discard block  | 
                                                    ||
| 397 | 397 | $model_path = ucfirst($model_path);  | 
                                                        
| 398 | 398 | }  | 
                                                        
| 399 | 399 |                  if ($class->hasConstant("TPL")) { | 
                                                        
| 400 | -                    $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); | 
                                                        |
| 400 | +                    $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); | 
                                                        |
| 401 | 401 | }  | 
                                                        
| 402 | 402 | $this->domains[$domain] = array(  | 
                                                        
| 403 | - "template" => $path . $tpl_path,  | 
                                                        |
| 404 | - "model" => $path . $model_path,  | 
                                                        |
| 405 | - "public" => $path . $public_path,  | 
                                                        |
| 403 | + "template" => $path.$tpl_path,  | 
                                                        |
| 404 | + "model" => $path.$model_path,  | 
                                                        |
| 405 | + "public" => $path.$public_path,  | 
                                                        |
| 406 | 406 | );  | 
                                                        
| 407 | 407 | }  | 
                                                        
| 408 | 408 | |
@@ -415,11 +415,11 @@ discard block  | 
                                                    ||
| 415 | 415 | */  | 
                                                        
| 416 | 416 | private function simpatize()  | 
                                                        
| 417 | 417 |          { | 
                                                        
| 418 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php";  | 
                                                        |
| 419 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName;  | 
                                                        |
| 418 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php";  | 
                                                        |
| 419 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName;  | 
                                                        |
| 420 | 420 | $this->generateSlugs($absoluteTranslationFileName);  | 
                                                        
| 421 | 421 | Config::createDir(CONFIG_DIR);  | 
                                                        
| 422 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);  | 
                                                        |
| 422 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE);  | 
                                                        |
| 423 | 423 | |
| 424 | 424 | return $this;  | 
                                                        
| 425 | 425 | }  | 
                                                        
@@ -470,16 +470,16 @@ discard block  | 
                                                    ||
| 470 | 470 | public function getRoute($slug = '', $absolute = FALSE, $params = NULL)  | 
                                                        
| 471 | 471 |          { | 
                                                        
| 472 | 472 |              if (strlen($slug) === 0) { | 
                                                        
| 473 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/';  | 
                                                        |
| 473 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/';  | 
                                                        |
| 474 | 474 | }  | 
                                                        
| 475 | 475 |              if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { | 
                                                        
| 476 | 476 |                  throw new RouterException(_("No existe la ruta especificada")); | 
                                                        
| 477 | 477 | }  | 
                                                        
| 478 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug];  | 
                                                        |
| 478 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug];  | 
                                                        |
| 479 | 479 |              if (!empty($params)) foreach ($params as $key => $value) { | 
                                                        
| 480 | -                $url = str_replace("{" . $key . "}", $value, $url); | 
                                                        |
| 480 | +                $url = str_replace("{".$key."}", $value, $url); | 
                                                        |
| 481 | 481 |              } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { | 
                                                        
| 482 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];  | 
                                                        |
| 482 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"];  | 
                                                        |
| 483 | 483 | }  | 
                                                        
| 484 | 484 | |
| 485 | 485 |              return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); | 
                                                        
@@ -497,12 +497,12 @@ discard block  | 
                                                    ||
| 497 | 497 |                  if (preg_match('/^\/admin(\/|$)/', $routePattern)) { | 
                                                        
| 498 | 498 |                      if (preg_match('/^PSFS/', $params["class"])) { | 
                                                        
| 499 | 499 | $profile = "superadmin";  | 
                                                        
| 500 | -                    } else { | 
                                                        |
| 500 | +                    }else { | 
                                                        |
| 501 | 501 | $profile = "admin";  | 
                                                        
| 502 | 502 | }  | 
                                                        
| 503 | 503 |                      if (!empty($params["default"]) && preg_match('/(GET|ALL)/i', $httpMethod)) { | 
                                                        
| 504 | 504 | $_profile = ($params["visible"]) ? $profile : 'adminhidden';  | 
                                                        
| 505 | -                        if(!array_key_exists($_profile, $routes)) { | 
                                                        |
| 505 | +                        if (!array_key_exists($_profile, $routes)) { | 
                                                        |
| 506 | 506 | $routes[$_profile] = array();  | 
                                                        
| 507 | 507 | }  | 
                                                        
| 508 | 508 | $routes[$_profile][] = $params["slug"];  | 
                                                        
@@ -571,7 +571,7 @@ discard block  | 
                                                    ||
| 571 | 571 | $expr = preg_quote($expr, '/');  | 
                                                        
| 572 | 572 |              $expr = str_replace('###', '(.*)', $expr); | 
                                                        
| 573 | 573 |              $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); | 
                                                        
| 574 | -            $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); | 
                                                        |
| 574 | +            $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); | 
                                                        |
| 575 | 575 | |
| 576 | 576 | return $matched;  | 
                                                        
| 577 | 577 | }  | 
                                                        
@@ -609,9 +609,9 @@ discard block  | 
                                                    ||
| 609 | 609 |              if (count($parameters) > 0) foreach ($parameters as $param) { | 
                                                        
| 610 | 610 |                  if ($param->isOptional() && !is_array($param->getDefaultValue())) { | 
                                                        
| 611 | 611 | $params[$param->getName()] = $param->getDefaultValue();  | 
                                                        
| 612 | -                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); | 
                                                        |
| 612 | +                    $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); | 
                                                        |
| 613 | 613 | }  | 
                                                        
| 614 | - } else $default = $regex;  | 
                                                        |
| 614 | + }else $default = $regex;  | 
                                                        |
| 615 | 615 | |
| 616 | 616 | return array($regex, $default, $params);  | 
                                                        
| 617 | 617 | }  | 
                                                        
@@ -668,16 +668,16 @@ discard block  | 
                                                    ||
| 668 | 668 | */  | 
                                                        
| 669 | 669 | protected function executeCachedRoute($route, $action, $class, $params = NULL)  | 
                                                        
| 670 | 670 |          { | 
                                                        
| 671 | -            Logger::getInstance()->debugLog(_('Ruta resuelta para ') . $route); | 
                                                        |
| 671 | +            Logger::getInstance()->debugLog(_('Ruta resuelta para ').$route); | 
                                                        |
| 672 | 672 |              $this->session->setSessionKey("__CACHE__", $action); | 
                                                        
| 673 | 673 | $cache = Cache::needCache();  | 
                                                        
| 674 | 674 | $execute = TRUE;  | 
                                                        
| 675 | 675 |              if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { | 
                                                        
| 676 | 676 | $cacheDataName = $this->cache->getRequestCacheHash();  | 
                                                        
| 677 | -                $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, $cache, function () { | 
                                                        |
| 677 | +                $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, $cache, function() { | 
                                                        |
| 678 | 678 | });  | 
                                                        
| 679 | 679 |                  if (NULL !== $cachedData) { | 
                                                        
| 680 | -                    $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", $cache, function () { | 
                                                        |
| 680 | +                    $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", $cache, function() { | 
                                                        |
| 681 | 681 | }, Cache::JSON);  | 
                                                        
| 682 | 682 | Template::getInstance()->renderCache($cachedData, $headers);  | 
                                                        
| 683 | 683 | $execute = FALSE;  | 
                                                        
@@ -726,7 +726,7 @@ discard block  | 
                                                    ||
| 726 | 726 | $translations = array();  | 
                                                        
| 727 | 727 |              if (file_exists($absoluteTranslationFileName)) { | 
                                                        
| 728 | 728 | include($absoluteTranslationFileName);  | 
                                                        
| 729 | -            } else { | 
                                                        |
| 729 | +            }else { | 
                                                        |
| 730 | 730 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);  | 
                                                        
| 731 | 731 | }  | 
                                                        
| 732 | 732 | |
@@ -371,7 +371,7 @@  | 
                                                    ||
| 371 | 371 | * @param array $parts  | 
                                                        
| 372 | 372 | * @param int $partLength  | 
                                                        
| 373 | 373 | *  | 
                                                        
| 374 | - * @return array  | 
                                                        |
| 374 | + * @return string[]  | 
                                                        |
| 375 | 375 | */  | 
                                                        
| 376 | 376 | private static function extractTsAndMod(array &$parts, $partLength)  | 
                                                        
| 377 | 377 |          { | 
                                                        
@@ -78,13 +78,13 @@ discard block  | 
                                                    ||
| 78 | 78 | public static function save($user)  | 
                                                        
| 79 | 79 |          { | 
                                                        
| 80 | 80 | $admins = array();  | 
                                                        
| 81 | -            if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { | 
                                                        |
| 82 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);  | 
                                                        |
| 81 | +            if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { | 
                                                        |
| 82 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);  | 
                                                        |
| 83 | 83 | }  | 
                                                        
| 84 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);  | 
                                                        |
| 84 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);  | 
                                                        |
| 85 | 85 | $admins[$user['username']]['profile'] = $user['profile'];  | 
                                                        
| 86 | 86 | |
| 87 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));  | 
                                                        |
| 87 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT)));  | 
                                                        |
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | 90 | /**  | 
                                                        
@@ -104,8 +104,8 @@ discard block  | 
                                                    ||
| 104 | 104 | public function getAdmins()  | 
                                                        
| 105 | 105 |          { | 
                                                        
| 106 | 106 | $admins = array();  | 
                                                        
| 107 | -            if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { | 
                                                        |
| 108 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE);  | 
                                                        |
| 107 | +            if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { | 
                                                        |
| 108 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE);  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | return $admins;  | 
                                                        
@@ -124,7 +124,7 @@ discard block  | 
                                                    ||
| 124 | 124 |          { | 
                                                        
| 125 | 125 |              if (!$this->authorized) { | 
                                                        
| 126 | 126 | $request = Request::getInstance();  | 
                                                        
| 127 | -                if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { | 
                                                        |
| 127 | +                if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { | 
                                                        |
| 128 | 128 | //Si no hay fichero de usuarios redirigimos directamente al gestor  | 
                                                        
| 129 | 129 | return Router::getInstance()->getAdmin()->adminers();  | 
                                                        
| 130 | 130 | }  | 
                                                        
@@ -137,7 +137,7 @@ discard block  | 
                                                    ||
| 137 | 137 | }  | 
                                                        
| 138 | 138 |                  if (!empty($user) && !empty($admins[$user])) { | 
                                                        
| 139 | 139 | $auth = $admins[$user]['hash'];  | 
                                                        
| 140 | - $this->authorized = ($auth == sha1($user . $pass));  | 
                                                        |
| 140 | + $this->authorized = ($auth == sha1($user.$pass));  | 
                                                        |
| 141 | 141 | $this->admin = array(  | 
                                                        
| 142 | 142 | 'alias' => $user,  | 
                                                        
| 143 | 143 | 'profile' => $admins[$user]['profile'],  | 
                                                        
@@ -354,12 +354,12 @@ discard block  | 
                                                    ||
| 354 | 354 | $axis = 0;  | 
                                                        
| 355 | 355 | $parts = array();  | 
                                                        
| 356 | 356 |              try { | 
                                                        
| 357 | - $partLength = floor(strlen($token) / 10);  | 
                                                        |
| 358 | -                for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { | 
                                                        |
| 357 | + $partLength = floor(strlen($token)/10);  | 
                                                        |
| 358 | +                for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { | 
                                                        |
| 359 | 359 | $parts[] = substr($token, $axis, $partLength);  | 
                                                        
| 360 | 360 | $axis += $partLength;  | 
                                                        
| 361 | 361 | }  | 
                                                        
| 362 | -            } catch(\Exception $e) { | 
                                                        |
| 362 | +            }catch (\Exception $e) { | 
                                                        |
| 363 | 363 | $partLength = 0;  | 
                                                        
| 364 | 364 | }  | 
                                                        
| 365 | 365 | |
@@ -399,7 +399,7 @@ discard block  | 
                                                    ||
| 399 | 399 | $decoded = NULL;  | 
                                                        
| 400 | 400 | list($partLength, $parts) = self::extractTokenParts($token);  | 
                                                        
| 401 | 401 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength);  | 
                                                        
| 402 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);  | 
                                                        |
| 402 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);  | 
                                                        |
| 403 | 403 |              if (time() - (integer)$ts < 300 && $hashMod === $mod) { | 
                                                        
| 404 | 404 |                  $decoded = implode('', $parts); | 
                                                        
| 405 | 405 | }  | 
                                                        
@@ -416,16 +416,16 @@ discard block  | 
                                                    ||
| 416 | 416 | public static function generateToken($secret, $module = 'PSFS')  | 
                                                        
| 417 | 417 |          { | 
                                                        
| 418 | 418 | $ts = time();  | 
                                                        
| 419 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2);  | 
                                                        |
| 419 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2);  | 
                                                        |
| 420 | 420 |              $hash = hash('sha256', $secret); | 
                                                        
| 421 | - $insert = floor(strlen($hash) / strlen($ts));  | 
                                                        |
| 421 | + $insert = floor(strlen($hash)/strlen($ts));  | 
                                                        |
| 422 | 422 | $j = 0;  | 
                                                        
| 423 | 423 | $token = '';  | 
                                                        
| 424 | 424 |              for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { | 
                                                        
| 425 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2);  | 
                                                        |
| 425 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2);  | 
                                                        |
| 426 | 426 | $j += $insert;  | 
                                                        
| 427 | 427 | }  | 
                                                        
| 428 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts)));  | 
                                                        |
| 428 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts)));  | 
                                                        |
| 429 | 429 | return $token;  | 
                                                        
| 430 | 430 | }  | 
                                                        
| 431 | 431 | |
@@ -125,8 +125,8 @@  | 
                                                    ||
| 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 | */  | 
                                                        
@@ -177,7 +177,7 @@ discard block  | 
                                                    ||
| 177 | 177 | $this->url = NULL;  | 
                                                        
| 178 | 178 | $this->params = array();  | 
                                                        
| 179 | 179 | $this->headers = array();  | 
                                                        
| 180 | -            $this->log->debugLog(_("Context service for " . get_called_class() . " cleared!")); | 
                                                        |
| 180 | +            $this->log->debugLog(_("Context service for ".get_called_class()." cleared!")); | 
                                                        |
| 181 | 181 | }  | 
                                                        
| 182 | 182 | |
| 183 | 183 | /**  | 
                                                        
@@ -208,7 +208,7 @@ discard block  | 
                                                    ||
| 208 | 208 | |
| 209 | 209 | protected function setOpts()  | 
                                                        
| 210 | 210 |          { | 
                                                        
| 211 | -            switch(strtoupper($this->type)) { | 
                                                        |
| 211 | +            switch (strtoupper($this->type)) { | 
                                                        |
| 212 | 212 | case 'GET':  | 
                                                        
| 213 | 213 | default:  | 
                                                        
| 214 | 214 | curl_setopt($this->con, CURLOPT_CUSTOMREQUEST, "GET");  | 
                                                        
@@ -175,10 +175,10 @@  | 
                                                    ||
| 175 | 175 | |
| 176 | 176 | /**  | 
                                                        
| 177 | 177 | * Create the depecency injected  | 
                                                        
| 178 | - * @param $variable  | 
                                                        |
| 179 | - * @param $singleton  | 
                                                        |
| 178 | + * @param string $variable  | 
                                                        |
| 179 | + * @param boolean $singleton  | 
                                                        |
| 180 | 180 | * @param $classNameSpace  | 
                                                        
| 181 | - * @param $calledClass  | 
                                                        |
| 181 | + * @param string $calledClass  | 
                                                        |
| 182 | 182 | * @return mixed  | 
                                                        
| 183 | 183 | */  | 
                                                        
| 184 | 184 | private function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass)  | 
                                                        
@@ -98,10 +98,10 @@ discard block  | 
                                                    ||
| 98 | 98 | $setter = "set".ucfirst($variable);  | 
                                                        
| 99 | 99 |              if (method_exists($calledClass, $setter)) { | 
                                                        
| 100 | 100 | $this->$setter($instance);  | 
                                                        
| 101 | -            } else { | 
                                                        |
| 101 | +            }else { | 
                                                        |
| 102 | 102 | $this->$variable = $instance;  | 
                                                        
| 103 | 103 | }  | 
                                                        
| 104 | -        } catch (\Exception $e) { | 
                                                        |
| 104 | +        }catch (\Exception $e) { | 
                                                        |
| 105 | 105 | Logger::getInstance()->errorLog($e->getMessage());  | 
                                                        
| 106 | 106 | }  | 
                                                        
| 107 | 107 | return $this;  | 
                                                        
@@ -189,7 +189,7 @@ discard block  | 
                                                    ||
| 189 | 189 |          if (true === $singleton && method_exists($varInstanceType, "getInstance")) { | 
                                                        
| 190 | 190 | $instance = $varInstanceType::getInstance();  | 
                                                        
| 191 | 191 | return $instance;  | 
                                                        
| 192 | -        } else { | 
                                                        |
| 192 | +        }else { | 
                                                        |
| 193 | 193 | $instance = new $varInstanceType();  | 
                                                        
| 194 | 194 | return $instance;  | 
                                                        
| 195 | 195 | }  | 
                                                        
@@ -125,11 +125,13 @@  | 
                                                    ||
| 125 | 125 | $cacheService->storeData($cacheFilename, $properties, Cache::JSON);  | 
                                                        
| 126 | 126 | }  | 
                                                        
| 127 | 127 | /** @var \ReflectionProperty $property */  | 
                                                        
| 128 | -            if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) { | 
                                                        |
| 128 | +            if (!empty($properties) && is_array($properties)) { | 
                                                        |
| 129 | +                foreach ($properties as $property => $class) { | 
                                                        |
| 129 | 130 | $this->load($property, true, $class);  | 
                                                        
| 130 | 131 | }  | 
                                                        
| 132 | + }  | 
                                                        |
| 131 | 133 | $this->setLoaded();  | 
                                                        
| 132 | -        }else { | 
                                                        |
| 134 | +        } else { | 
                                                        |
| 133 | 135 | $logService->warningLog(get_class($this)." ya cargada");  | 
                                                        
| 134 | 136 | }  | 
                                                        
| 135 | 137 | }  | 
                                                        
@@ -259,7 +259,7 @@ discard block  | 
                                                    ||
| 259 | 259 | *  | 
                                                        
| 260 | 260 | * @param null|string $pk  | 
                                                        
| 261 | 261 | *  | 
                                                        
| 262 | - * @return JsonResponse JSON  | 
                                                        |
| 262 | + * @return string|null JSON  | 
                                                        |
| 263 | 263 | */  | 
                                                        
| 264 | 264 | public function get($pk = NULL)  | 
                                                        
| 265 | 265 |          { | 
                                                        
@@ -303,7 +303,7 @@ discard block  | 
                                                    ||
| 303 | 303 | * @POST  | 
                                                        
| 304 | 304 |           * @ROUTE /api/{__API__} | 
                                                        
| 305 | 305 | *  | 
                                                        
| 306 | - * @return JsonResponse JSON  | 
                                                        |
| 306 | + * @return string|null JSON  | 
                                                        |
| 307 | 307 | */  | 
                                                        
| 308 | 308 | public function post()  | 
                                                        
| 309 | 309 |          { | 
                                                        
@@ -333,7 +333,7 @@ discard block  | 
                                                    ||
| 333 | 333 | *  | 
                                                        
| 334 | 334 | * @param string $pk  | 
                                                        
| 335 | 335 | *  | 
                                                        
| 336 | - * @return JsonResponse JSON  | 
                                                        |
| 336 | + * @return string|null JSON  | 
                                                        |
| 337 | 337 | */  | 
                                                        
| 338 | 338 | public function delete($pk = NULL)  | 
                                                        
| 339 | 339 |          { | 
                                                        
@@ -362,7 +362,7 @@ discard block  | 
                                                    ||
| 362 | 362 | *  | 
                                                        
| 363 | 363 | * @param string $pk  | 
                                                        
| 364 | 364 | *  | 
                                                        
| 365 | - * @return JsonResponse  | 
                                                        |
| 365 | + * @return string|null  | 
                                                        |
| 366 | 366 | *  | 
                                                        
| 367 | 367 | */  | 
                                                        
| 368 | 368 | public function put($pk)  | 
                                                        
@@ -179,7 +179,7 @@ discard block  | 
                                                    ||
| 179 | 179 | *  | 
                                                        
| 180 | 180 | * @param ModelCriteria $query  | 
                                                        
| 181 | 181 | */  | 
                                                        
| 182 | - private function addOrders(ModelCriteria &$query)  | 
                                                        |
| 182 | + private function addOrders(ModelCriteria & $query)  | 
                                                        |
| 183 | 183 |          { | 
                                                        
| 184 | 184 | $orderAdded = FALSE;  | 
                                                        
| 185 | 185 |              foreach ($this->order->getOrders() as $field => $direction) { | 
                                                        
@@ -187,7 +187,7 @@ discard block  | 
                                                    ||
| 187 | 187 | $orderAdded = TRUE;  | 
                                                        
| 188 | 188 |                      if ($direction === Order::ASC) { | 
                                                        
| 189 | 189 | $query->addAscendingOrderByColumn($field);  | 
                                                        
| 190 | -                    } else { | 
                                                        |
| 190 | +                    }else { | 
                                                        |
| 191 | 191 | $query->addDescendingOrderByColumn($field);  | 
                                                        
| 192 | 192 | }  | 
                                                        
| 193 | 193 | }  | 
                                                        
@@ -201,9 +201,9 @@ discard block  | 
                                                    ||
| 201 | 201 | * Add extra columns to pagination query  | 
                                                        
| 202 | 202 | * @param ModelCriteria $query  | 
                                                        
| 203 | 203 | */  | 
                                                        
| 204 | - private function addExtraColumns(ModelCriteria &$query)  | 
                                                        |
| 204 | + private function addExtraColumns(ModelCriteria & $query)  | 
                                                        |
| 205 | 205 |          { | 
                                                        
| 206 | -            if(!empty($this->extraColumns)) { | 
                                                        |
| 206 | +            if (!empty($this->extraColumns)) { | 
                                                        |
| 207 | 207 |                  foreach ($this->extraColumns as $expression => $columnName) { | 
                                                        
| 208 | 208 | $query->withColumn($expression, $columnName);  | 
                                                        
| 209 | 209 | }  | 
                                                        
@@ -214,7 +214,7 @@ discard block  | 
                                                    ||
| 214 | 214 | * Method that allow joins between models  | 
                                                        
| 215 | 215 | * @param ModelCriteria $query  | 
                                                        
| 216 | 216 | */  | 
                                                        
| 217 | - protected function joinTables(ModelCriteria &$query)  | 
                                                        |
| 217 | + protected function joinTables(ModelCriteria & $query)  | 
                                                        |
| 218 | 218 |          { | 
                                                        
| 219 | 219 | //TODO for specific implementations  | 
                                                        
| 220 | 220 | }  | 
                                                        
@@ -224,7 +224,7 @@ discard block  | 
                                                    ||
| 224 | 224 | *  | 
                                                        
| 225 | 225 | * @param ModelCriteria $query  | 
                                                        
| 226 | 226 | */  | 
                                                        
| 227 | - private function addFilters(ModelCriteria &$query)  | 
                                                        |
| 227 | + private function addFilters(ModelCriteria & $query)  | 
                                                        |
| 228 | 228 |          { | 
                                                        
| 229 | 229 |              if (count($this->query) > 0) { | 
                                                        
| 230 | 230 |                  foreach ($this->query as $field => $value) { | 
                                                        
@@ -241,7 +241,7 @@ discard block  | 
                                                    ||
| 241 | 241 |                          } elseif (preg_match('/^(\'|\")(.*)(\'|\")$/', $value)) { | 
                                                        
| 242 | 242 |                              $text = preg_replace('/(\'|\")/', '', $value); | 
                                                        
| 243 | 243 | $query->filterBy($tableField, $text, Criteria::LIKE);  | 
                                                        
| 244 | -                        } else { | 
                                                        |
| 244 | +                        }else { | 
                                                        |
| 245 | 245 | $query->filterBy($tableField, $value, Criteria::EQUAL);  | 
                                                        
| 246 | 246 | }  | 
                                                        
| 247 | 247 | }  | 
                                                        
@@ -264,10 +264,10 @@ discard block  | 
                                                    ||
| 264 | 264 | list($page, $limit) = $this->extractPagination();  | 
                                                        
| 265 | 265 |                  if ($limit == -1) { | 
                                                        
| 266 | 266 | $this->list = $query->find($this->con);  | 
                                                        
| 267 | -                } else { | 
                                                        |
| 267 | +                }else { | 
                                                        |
| 268 | 268 | $this->list = $query->paginate($page, $limit, $this->con);  | 
                                                        
| 269 | 269 | }  | 
                                                        
| 270 | -            } catch (\Exception $e) { | 
                                                        |
| 270 | +            }catch (\Exception $e) { | 
                                                        |
| 271 | 271 | Logger::getInstance(get_class($this))->errorLog($e->getMessage());  | 
                                                        
| 272 | 272 | }  | 
                                                        
| 273 | 273 | }  | 
                                                        
@@ -284,7 +284,7 @@ discard block  | 
                                                    ||
| 284 | 284 | $this->joinTables($query);  | 
                                                        
| 285 | 285 | $this->addExtraColumns($query);  | 
                                                        
| 286 | 286 | $this->model = $query->findPk($pk);  | 
                                                        
| 287 | -            } catch (\Exception $e) { | 
                                                        |
| 287 | +            }catch (\Exception $e) { | 
                                                        |
| 288 | 288 | Logger::getInstance(get_class($this))->errorLog($e->getMessage());  | 
                                                        
| 289 | 289 | }  | 
                                                        
| 290 | 290 | }  | 
                                                        
@@ -308,7 +308,7 @@ discard block  | 
                                                    ||
| 308 | 308 | $pages = 1;  | 
                                                        
| 309 | 309 |              if (NULL === $pk || '' === $pk) { | 
                                                        
| 310 | 310 | list($return, $total, $pages) = $this->getList();  | 
                                                        
| 311 | -            } else { | 
                                                        |
| 311 | +            }else { | 
                                                        |
| 312 | 312 | list($code, $return) = $this->getSingleResult($pk);  | 
                                                        
| 313 | 313 | |
| 314 | 314 | }  | 
                                                        
@@ -359,7 +359,7 @@ discard block  | 
                                                    ||
| 359 | 359 | $saved = TRUE;  | 
                                                        
| 360 | 360 | $model = $this->model->toArray();  | 
                                                        
| 361 | 361 | }  | 
                                                        
| 362 | -            } catch (\Exception $e) { | 
                                                        |
| 362 | +            }catch (\Exception $e) { | 
                                                        |
| 363 | 363 | jpre($e->getMessage(), true);  | 
                                                        
| 364 | 364 | Logger::getInstance()->errorLog($e->getMessage());  | 
                                                        
| 365 | 365 | }  | 
                                                        
@@ -388,7 +388,7 @@ discard block  | 
                                                    ||
| 388 | 388 | $this->model->delete($this->con);  | 
                                                        
| 389 | 389 | $deleted = TRUE;  | 
                                                        
| 390 | 390 | }  | 
                                                        
| 391 | -                } catch (\Exception $e) { | 
                                                        |
| 391 | +                }catch (\Exception $e) { | 
                                                        |
| 392 | 392 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage());  | 
                                                        
| 393 | 393 | }  | 
                                                        
| 394 | 394 | }  | 
                                                        
@@ -431,7 +431,7 @@ discard block  | 
                                                    ||
| 431 | 431 | */  | 
                                                        
| 432 | 432 | private function extractQuery()  | 
                                                        
| 433 | 433 |          { | 
                                                        
| 434 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query");  | 
                                                        |
| 434 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query");  | 
                                                        |
| 435 | 435 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */  | 
                                                        
| 436 | 436 |              $query = $queryReflector->getMethod('create')->invoke(NULL); | 
                                                        
| 437 | 437 | |
@@ -475,7 +475,7 @@ discard block  | 
                                                    ||
| 475 | 475 |              if ($this->con->inTransaction()) { | 
                                                        
| 476 | 476 |                  if ($status === 200) { | 
                                                        
| 477 | 477 | $this->con->commit();  | 
                                                        
| 478 | -                } else { | 
                                                        |
| 478 | +                }else { | 
                                                        |
| 479 | 479 | $this->con->rollBack();  | 
                                                        
| 480 | 480 | }  | 
                                                        
| 481 | 481 | }  | 
                                                        
@@ -518,7 +518,7 @@ discard block  | 
                                                    ||
| 518 | 518 |              return $this->render('api.admin.html.twig', array( | 
                                                        
| 519 | 519 | "api" => $this->getApi(),  | 
                                                        
| 520 | 520 | "domain" => $this->domain,  | 
                                                        
| 521 | -                "url"    => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), | 
                                                        |
| 521 | +                "url"    => preg_replace('/\/$/', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), | 
                                                        |
| 522 | 522 | ));  | 
                                                        
| 523 | 523 | }  | 
                                                        
| 524 | 524 | |
@@ -554,7 +554,7 @@ discard block  | 
                                                    ||
| 554 | 554 | $return = $this->list->toArray();  | 
                                                        
| 555 | 555 | $total = $this->list->getNbResults();  | 
                                                        
| 556 | 556 | $pages = $this->list->getLastPage();  | 
                                                        
| 557 | -            } catch (\Exception $e) { | 
                                                        |
| 557 | +            }catch (\Exception $e) { | 
                                                        |
| 558 | 558 | Logger::getInstance(get_class($this))->errorLog($e->getMessage());  | 
                                                        
| 559 | 559 | }  | 
                                                        
| 560 | 560 | |
@@ -574,7 +574,7 @@ discard block  | 
                                                    ||
| 574 | 574 | $return = array();  | 
                                                        
| 575 | 575 |              if (NULL === $model) { | 
                                                        
| 576 | 576 | $code = 404;  | 
                                                        
| 577 | -            } else { | 
                                                        |
| 577 | +            }else { | 
                                                        |
| 578 | 578 | $return = $model->toArray();  | 
                                                        
| 579 | 579 | }  | 
                                                        
| 580 | 580 | return array($code, $return);  | 
                                                        
@@ -42,6 +42,10 @@ discard block  | 
                                                    ||
| 42 | 42 | * @return Form  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | 44 |          public function setEncType($enctype) { $this->enctype = $enctype; return $this; } | 
                                                        
| 45 | +  | 
                                                        |
| 46 | + /**  | 
                                                        |
| 47 | + * @param string|null $action  | 
                                                        |
| 48 | + */  | 
                                                        |
| 45 | 49 |          public function setAction($action) { $this->action = $action; return $this; } | 
                                                        
| 46 | 50 |          public function setMethod($method) { $this->method = $method; return $this; } | 
                                                        
| 47 | 51 |          public function setAttrs(array $attrs) { $this->attrs = $attrs; return $this; } | 
                                                        
@@ -466,7 +470,7 @@ discard block  | 
                                                    ||
| 466 | 470 | }  | 
                                                        
| 467 | 471 | |
| 468 | 472 | /**  | 
                                                        
| 469 | - * @param $token_field  | 
                                                        |
| 473 | + * @param string $token_field  | 
                                                        |
| 470 | 474 | * @return bool  | 
                                                        
| 471 | 475 | */  | 
                                                        
| 472 | 476 |          protected function existsFormToken($token_field) { | 
                                                        
@@ -494,7 +498,7 @@ discard block  | 
                                                    ||
| 494 | 498 | /**  | 
                                                        
| 495 | 499 | * Método que extrae el valor de un campo del formulario del modelo  | 
                                                        
| 496 | 500 | * @param $field  | 
                                                        
| 497 | - * @param $value  | 
                                                        |
| 501 | + * @param ObjectCollection $value  | 
                                                        |
| 498 | 502 | * @param $type  | 
                                                        
| 499 | 503 | * @return mixed  | 
                                                        
| 500 | 504 | */  | 
                                                        
@@ -12,7 +12,7 @@ discard block  | 
                                                    ||
| 12 | 12 | use PSFS\base\Singleton;  | 
                                                        
| 13 | 13 | use PSFS\base\types\interfaces\FormType;  | 
                                                        
| 14 | 14 | |
| 15 | -    abstract class Form extends Singleton implements FormType{ | 
                                                        |
| 15 | +    abstract class Form extends Singleton implements FormType { | 
                                                        |
| 16 | 16 | |
| 17 | 17 | /**  | 
                                                        
| 18 | 18 | * Variables de formulario  | 
                                                        
@@ -31,7 +31,7 @@ discard block  | 
                                                    ||
| 31 | 31 | |
| 32 | 32 | public function __construct($model = null)  | 
                                                        
| 33 | 33 |          { | 
                                                        
| 34 | -            if(null !== $model) { | 
                                                        |
| 34 | +            if (null !== $model) { | 
                                                        |
| 35 | 35 | $this->model = $model;  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | }  | 
                                                        
@@ -122,7 +122,7 @@ discard block  | 
                                                    ||
| 122 | 122 | */  | 
                                                        
| 123 | 123 |          public function getFieldValue($name) { | 
                                                        
| 124 | 124 | $value = null;  | 
                                                        
| 125 | -            if (null !== $this->getField($name)){ | 
                                                        |
| 125 | +            if (null !== $this->getField($name)) { | 
                                                        |
| 126 | 126 | $field = $this->getField($name);  | 
                                                        
| 127 | 127 |                  $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null; | 
                                                        
| 128 | 128 | }  | 
                                                        
@@ -323,7 +323,7 @@ discard block  | 
                                                    ||
| 323 | 323 | $model->save();  | 
                                                        
| 324 | 324 | $save = true;  | 
                                                        
| 325 | 325 | Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey());  | 
                                                        
| 326 | -            } catch (\Exception $e) { | 
                                                        |
| 326 | +            }catch (\Exception $e) { | 
                                                        |
| 327 | 327 | Logger::getInstance()->errorLog($e->getMessage());  | 
                                                        
| 328 | 328 | throw new FormException($e->getMessage(), $e->getCode(), $e);  | 
                                                        
| 329 | 329 | }  | 
                                                        
@@ -369,10 +369,10 @@ discard block  | 
                                                    ||
| 369 | 369 |              if (array_key_exists($key, $data[$form_name])) { | 
                                                        
| 370 | 370 |                  if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) { | 
                                                        
| 371 | 371 | $field["value"] = null;  | 
                                                        
| 372 | -                } else { | 
                                                        |
| 372 | +                }else { | 
                                                        |
| 373 | 373 | $field["value"] = $data[$form_name][$key];  | 
                                                        
| 374 | 374 | }  | 
                                                        
| 375 | -            } else { | 
                                                        |
| 375 | +            }else { | 
                                                        |
| 376 | 376 | unset($field["value"]);  | 
                                                        
| 377 | 377 | }  | 
                                                        
| 378 | 378 | return array($data, $field);  | 
                                                        
@@ -416,10 +416,10 @@ discard block  | 
                                                    ||
| 416 | 416 |                  if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) { | 
                                                        
| 417 | 417 | $method = "get".$field["class_id"];  | 
                                                        
| 418 | 418 | $data[] = $class->$method();  | 
                                                        
| 419 | -                } else { | 
                                                        |
| 419 | +                }else { | 
                                                        |
| 420 | 420 | $data[] = $class->getPrimaryKey();  | 
                                                        
| 421 | 421 | }  | 
                                                        
| 422 | -            } else { | 
                                                        |
| 422 | +            }else { | 
                                                        |
| 423 | 423 | $data[] = $val;  | 
                                                        
| 424 | 424 | }  | 
                                                        
| 425 | 425 | |
@@ -449,11 +449,11 @@ discard block  | 
                                                    ||
| 449 | 449 | $field["value"] = $value;  | 
                                                        
| 450 | 450 |                          } elseif ($value instanceof \DateTime) { | 
                                                        
| 451 | 451 |                              $field["value"] = $value->format("Y-m-d H:i:s"); | 
                                                        
| 452 | -                        } else { | 
                                                        |
| 452 | +                        }else { | 
                                                        |
| 453 | 453 | $field["value"] = $value->getPrimaryKey();  | 
                                                        
| 454 | 454 | }  | 
                                                        
| 455 | 455 | }  | 
                                                        
| 456 | -                } else { | 
                                                        |
| 456 | +                }else { | 
                                                        |
| 457 | 457 | $field["value"] = $value;  | 
                                                        
| 458 | 458 | }  | 
                                                        
| 459 | 459 | }  | 
                                                        
@@ -157,7 +157,9 @@ discard block  | 
                                                    ||
| 157 | 157 |              if ($valid) { | 
                                                        
| 158 | 158 |                  if (count($this->fields) > 0) { | 
                                                        
| 159 | 159 |                      foreach ($this->fields as $key => &$field) { | 
                                                        
| 160 | - if ($key === self::SEPARATOR) continue;  | 
                                                        |
| 160 | +                        if ($key === self::SEPARATOR) { | 
                                                        |
| 161 | + continue;  | 
                                                        |
| 162 | + }  | 
                                                        |
| 161 | 163 | list($field, $valid) = $this->checkFieldValidation($field, $key);  | 
                                                        
| 162 | 164 | }  | 
                                                        
| 163 | 165 | }  | 
                                                        
@@ -444,7 +446,7 @@ discard block  | 
                                                    ||
| 444 | 446 | //Si es una relación múltiple  | 
                                                        
| 445 | 447 |                      if ($value instanceof ObjectCollection) { | 
                                                        
| 446 | 448 | $field = $this->computeModelFieldValue($field, $value, $type);  | 
                                                        
| 447 | -                    }else { //O una relación unitaria | 
                                                        |
| 449 | +                    } else { //O una relación unitaria | 
                                                        |
| 448 | 450 |                          if (method_exists($value, "__toString")) { | 
                                                        
| 449 | 451 | $field["value"] = $value;  | 
                                                        
| 450 | 452 |                          } elseif ($value instanceof \DateTime) { |