@@ -21,11 +21,11 @@ |
||
21 | 21 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
22 | 22 | |
23 | 23 | // filepath |
24 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
24 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
25 | 25 | if (!file_exists($abs_path)) { |
26 | - pre('→ ' . $class); |
|
27 | - pre('→ ' . $path); |
|
28 | - pre('→ ' . $abs_path); |
|
26 | + pre('→ '.$class); |
|
27 | + pre('→ '.$path); |
|
28 | + pre('→ '.$abs_path); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // require the file |
@@ -38,8 +38,8 @@ |
||
38 | 38 | //Generating the templates translations |
39 | 39 | $translations = $this->tpl->regenerateTemplates(); |
40 | 40 | |
41 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
42 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
41 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
42 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
43 | 43 | |
44 | 44 | //xgettext localizations |
45 | 45 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -33,7 +33,9 @@ |
||
33 | 33 | public function getTranslations($locale) |
34 | 34 | { |
35 | 35 | //Default locale |
36 | - if (null === $locale) $locale = $this->config->get("default_language"); |
|
36 | + if (null === $locale) { |
|
37 | + $locale = $this->config->get("default_language"); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | //Generating the templates translations |
39 | 41 | $translations = $this->tpl->regenerateTemplates(); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $msg |
89 | 89 | * @param array $context |
90 | 90 | * |
91 | - * @return bool |
|
91 | + * @return boolean|null |
|
92 | 92 | */ |
93 | 93 | public function debugLog($msg = '', $context = []) |
94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Método que escribe un log de Error |
100 | - * @param $msg |
|
100 | + * @param string $msg |
|
101 | 101 | * @param array $context |
102 | 102 | * |
103 | 103 | * @return bool |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Método que escribe un log de Warning |
112 | - * @param $msg |
|
112 | + * @param string $msg |
|
113 | 113 | * @param array $context |
114 | 114 | * @return bool |
115 | 115 | */ |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | if (!defined("LOG_DIR")) { |
17 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
18 | - define("LOG_DIR", BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
17 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
18 | + define("LOG_DIR", BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $config = Config::getInstance(); |
49 | 49 | $args = func_get_args(); |
50 | 50 | list($logger, $debug, $path) = $this->setup($config, $args); |
51 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date("Ymd") . ".log", "a+"); |
|
51 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date("Ymd").".log", "a+"); |
|
52 | 52 | $this->addPushLogger($logger, $debug, $config); |
53 | 53 | $this->log_level = Config::getParam('log.level', 'info'); |
54 | 54 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | private function createLoggerPath(Config $config) |
203 | 203 | { |
204 | 204 | $logger = $this->setLoggerName($config); |
205 | - $path = LOG_DIR . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
205 | + $path = LOG_DIR.DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
206 | 206 | GeneratorHelper::createDir($path); |
207 | 207 | |
208 | 208 | return $path; |
@@ -393,8 +393,10 @@ |
||
393 | 393 | throw new RouterException(_("No existe la ruta especificada")); |
394 | 394 | } |
395 | 395 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
396 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
396 | + if (!empty($params)) { |
|
397 | + foreach ($params as $key => $value) { |
|
397 | 398 | $url = str_replace("{" . $key . "}", $value, $url); |
399 | + } |
|
398 | 400 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
399 | 401 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
400 | 402 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function init() |
66 | 66 | { |
67 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", $this->cacheType, TRUE); |
|
68 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->cacheType, TRUE); |
|
67 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", $this->cacheType, TRUE); |
|
68 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->cacheType, TRUE); |
|
69 | 69 | if (empty($this->routing) || Config::getInstance()->getDebugMode()) { |
70 | 70 | $this->debugLoad(); |
71 | 71 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | "success" => FALSE, |
103 | 103 | "error" => $e->getMessage(), |
104 | 104 | )), 'application/json'); |
105 | - } else { |
|
105 | + }else { |
|
106 | 106 | return $template->render('error.html.twig', array( |
107 | 107 | 'exception' => $e, |
108 | 108 | 'trace' => $e->getTraceAsString(), |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | SecurityHelper::checkRestrictedAccess($route); |
161 | 161 | //Search action and execute |
162 | 162 | $this->searchAction($route); |
163 | - } catch (AccessDeniedException $e) { |
|
163 | + }catch (AccessDeniedException $e) { |
|
164 | 164 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
165 | 165 | return Admin::staticAdminLogon($route); |
166 | - } catch (RouterException $r) { |
|
166 | + }catch (RouterException $r) { |
|
167 | 167 | Logger::log($r->getMessage(), LOG_WARNING); |
168 | - } catch (\Exception $e) { |
|
168 | + }catch (\Exception $e) { |
|
169 | 169 | Logger::log($e->getMessage(), LOG_ERR); |
170 | 170 | throw $e; |
171 | 171 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function searchAction($route) |
184 | 184 | { |
185 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
185 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
186 | 186 | //Revisamos si tenemos la ruta registrada |
187 | 187 | $parts = parse_url($route); |
188 | 188 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $class = RouterHelper::getClassToCall($action); |
197 | 197 | try { |
198 | 198 | $this->executeCachedRoute($route, $action, $class, $get); |
199 | - } catch (\Exception $e) { |
|
199 | + }catch (\Exception $e) { |
|
200 | 200 | Logger::log($e->getMessage(), LOG_ERR); |
201 | 201 | throw new RouterException($e->getMessage(), 404, $e); |
202 | 202 | } |
@@ -225,17 +225,17 @@ discard block |
||
225 | 225 | $externalModules = explode(',', $externalModules); |
226 | 226 | foreach ($externalModules as &$module) { |
227 | 227 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
228 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
228 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
229 | 229 | if (file_exists($externalModulePath)) { |
230 | 230 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
231 | 231 | if (!empty($externalModule)) { |
232 | 232 | foreach ($externalModule as $modulePath) { |
233 | 233 | $extModule = $modulePath->getBasename(); |
234 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
234 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
235 | 235 | if (file_exists($moduleAutoloader)) { |
236 | 236 | @include $moduleAutoloader; |
237 | 237 | if ($hydrateRoute) { |
238 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
238 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
258 | 258 | foreach ($modules as $modulePath) { |
259 | 259 | $module = $modulePath->getBasename(); |
260 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
260 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | $this->checkExternalModules(); |
264 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
264 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $home_params = NULL; |
277 | 277 | foreach ($this->routing as $pattern => $params) { |
278 | 278 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
279 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
279 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
280 | 280 | $home_params = $params; |
281 | 281 | } |
282 | 282 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth(1)->name("*.php"); |
302 | 302 | foreach ($files as $file) { |
303 | 303 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
304 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
304 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
305 | 305 | } |
306 | 306 | $this->finder = new Finder(); |
307 | 307 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | if (!$this->domains) { |
372 | 372 | $this->domains = []; |
373 | 373 | } |
374 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
374 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
375 | 375 | if (!array_key_exists($domain, $this->domains)) { |
376 | 376 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
377 | 377 | } |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public function simpatize() |
388 | 388 | { |
389 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
390 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
389 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
390 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
391 | 391 | $this->generateSlugs($absoluteTranslationFileName); |
392 | 392 | GeneratorHelper::createDir(CONFIG_DIR); |
393 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
393 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
394 | 394 | |
395 | 395 | return $this; |
396 | 396 | } |
@@ -408,16 +408,16 @@ discard block |
||
408 | 408 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
409 | 409 | { |
410 | 410 | if (strlen($slug) === 0) { |
411 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
411 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
412 | 412 | } |
413 | 413 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
414 | 414 | throw new RouterException(_("No existe la ruta especificada")); |
415 | 415 | } |
416 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
416 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
417 | 417 | if (!empty($params)) foreach ($params as $key => $value) { |
418 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
418 | + $url = str_replace("{".$key."}", $value, $url); |
|
419 | 419 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
420 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
420 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -462,19 +462,19 @@ discard block |
||
462 | 462 | */ |
463 | 463 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
464 | 464 | { |
465 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
465 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
466 | 466 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
467 | 467 | $cache = Cache::needCache(); |
468 | 468 | $execute = TRUE; |
469 | 469 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
470 | 470 | $cacheDataName = $this->cache->getRequestCacheHash(); |
471 | - $tmpDir = substr($cacheDataName, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheDataName, 2, 2) . DIRECTORY_SEPARATOR; |
|
472 | - $cachedData = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName, |
|
473 | - $cache, function () { |
|
471 | + $tmpDir = substr($cacheDataName, 0, 2).DIRECTORY_SEPARATOR.substr($cacheDataName, 2, 2).DIRECTORY_SEPARATOR; |
|
472 | + $cachedData = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName, |
|
473 | + $cache, function() { |
|
474 | 474 | }); |
475 | 475 | if (NULL !== $cachedData) { |
476 | - $headers = $this->cache->readFromCache("json" . DIRECTORY_SEPARATOR . $tmpDir . $cacheDataName . ".headers", |
|
477 | - $cache, function () { |
|
476 | + $headers = $this->cache->readFromCache("json".DIRECTORY_SEPARATOR.$tmpDir.$cacheDataName.".headers", |
|
477 | + $cache, function() { |
|
478 | 478 | }, Cache::JSON); |
479 | 479 | Template::getInstance()->renderCache($cachedData, $headers); |
480 | 480 | $execute = FALSE; |
@@ -56,8 +56,10 @@ discard block |
||
56 | 56 | $_route = explode("/", $url['path']); |
57 | 57 | $_pattern = explode("/", $pattern); |
58 | 58 | $get = array(); |
59 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
59 | + if (!empty($_pattern)) { |
|
60 | + foreach ($_pattern as $index => $component) { |
|
60 | 61 | $_get = array(); |
62 | + } |
|
61 | 63 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
62 | 64 | if (!empty($_get[1]) && isset($_route[$index])) { |
63 | 65 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -151,12 +153,16 @@ discard block |
||
151 | 153 | $params = []; |
152 | 154 | $parameters = $method->getParameters(); |
153 | 155 | /** @var \ReflectionParameter $param */ |
154 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
156 | + if (count($parameters) > 0) { |
|
157 | + foreach ($parameters as $param) { |
|
155 | 158 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
156 | 159 | $params[$param->getName()] = $param->getDefaultValue(); |
160 | + } |
|
157 | 161 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
158 | 162 | } |
159 | - } else $default = $regex; |
|
163 | + } else { |
|
164 | + $default = $regex; |
|
165 | + } |
|
160 | 166 | |
161 | 167 | return array($regex, $default, $params); |
162 | 168 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * Método que extrae los parámetros de una función |
142 | 142 | * |
143 | - * @param array $sr |
|
143 | + * @param string[] $sr |
|
144 | 144 | * @param \ReflectionMethod $method |
145 | 145 | * |
146 | 146 | * @return array |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param string $docComments |
209 | 209 | * |
210 | - * @return bool |
|
210 | + * @return string |
|
211 | 211 | */ |
212 | 212 | public static function extractReflectionCacheability($docComments) |
213 | 213 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function getClassToCall($action) |
23 | 23 | { |
24 | 24 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
25 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
25 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
26 | 26 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
27 | 27 | return $class; |
28 | 28 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $expr = preg_quote($expr, '/'); |
109 | 109 | $expr = str_replace('###', '(.*)', $expr); |
110 | 110 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
111 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
111 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
112 | 112 | return $matched; |
113 | 113 | } |
114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
121 | 121 | { |
122 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
123 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
122 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
123 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
124 | 124 | $tpl_path = "templates"; |
125 | 125 | $public_path = "public"; |
126 | 126 | $model_path = "models"; |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | $model_path = ucfirst($model_path); |
131 | 131 | } |
132 | 132 | if ($class->hasConstant("TPL")) { |
133 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
133 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
134 | 134 | } |
135 | 135 | return [ |
136 | 136 | "base" => $path, |
137 | - "template" => $path . $tpl_path, |
|
138 | - "model" => $path . $model_path, |
|
139 | - "public" => $path . $public_path, |
|
137 | + "template" => $path.$tpl_path, |
|
138 | + "model" => $path.$model_path, |
|
139 | + "public" => $path.$public_path, |
|
140 | 140 | ]; |
141 | 141 | } |
142 | 142 | |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | if (count($parameters) > 0) foreach ($parameters as $param) { |
159 | 159 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
160 | 160 | $params[$param->getName()] = $param->getDefaultValue(); |
161 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
161 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
162 | 162 | } |
163 | - } else $default = $regex; |
|
163 | + }else $default = $regex; |
|
164 | 164 | |
165 | 165 | return array($regex, $default, $params); |
166 | 166 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $default = str_replace('{__DOMAIN__}', $module, $default); |
241 | 241 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
242 | 242 | $label = RouterHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
243 | - $route = $httpMethod . "#|#" . $regex; |
|
243 | + $route = $httpMethod."#|#".$regex; |
|
244 | 244 | $info = [ |
245 | 245 | "method" => $method->getName(), |
246 | 246 | "params" => $params, |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
56 | 56 | { |
57 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
57 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
58 | 58 | $reflector = new \ReflectionClass($calledClass); |
59 | 59 | $property = $reflector->getProperty($variable); |
60 | 60 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
61 | 61 | if (true === $singleton && method_exists($varInstanceType, "getInstance")) { |
62 | 62 | $instance = $varInstanceType::getInstance(); |
63 | - } else { |
|
63 | + }else { |
|
64 | 64 | $instance = new $varInstanceType(); |
65 | 65 | } |
66 | 66 | return $instance; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public static function getClassProperties($class) |
75 | 75 | { |
76 | 76 | $properties = []; |
77 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
77 | + Logger::log('Extracting annotations properties from class '.$class); |
|
78 | 78 | $selfReflector = new \ReflectionClass($class); |
79 | 79 | if (false !== $selfReflector->getParentClass()) { |
80 | 80 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | unset($_SERVER["PHP_AUTH_USER"]); |
39 | 39 | unset($_SERVER["PHP_AUTH_PW"]); |
40 | 40 | header_remove("Authorization"); |
41 | - } else { |
|
41 | + }else { |
|
42 | 42 | header('Authorization:'); |
43 | 43 | } |
44 | 44 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | Logger::log('Adding debug headers to render response'); |
67 | 67 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
68 | 68 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
69 | - header('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
70 | - header('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
71 | - header('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
69 | + header('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
70 | + header('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
71 | + header('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $vars; |
@@ -121,6 +121,9 @@ discard block |
||
121 | 121 | return self::getInstance()->getHeader($name); |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
124 | 127 | public function getHeader($name) |
125 | 128 | { |
126 | 129 | $header = null; |
@@ -171,7 +174,7 @@ discard block |
||
171 | 174 | * |
172 | 175 | * @param string $queryParams |
173 | 176 | * |
174 | - * @return mixed |
|
177 | + * @return string |
|
175 | 178 | */ |
176 | 179 | public function getQuery($queryParams) |
177 | 180 | { |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
218 | 218 | ob_start(); |
219 | - header('Location: ' . $url); |
|
219 | + header('Location: '.$url); |
|
220 | 220 | ob_end_clean(); |
221 | 221 | Security::getInstance()->updateSession(); |
222 | 222 | exit(_("Redireccionando...")); |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | $host = $this->getServerName(); |
262 | 262 | $protocol = $protocol ? $this->getProtocol() : ''; |
263 | 263 | $url = ''; |
264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
264 | + if (!empty($host) && !empty($protocol)) $url = $protocol.$host; |
|
265 | 265 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
266 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
266 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
267 | 267 | } |
268 | 268 | return $url; |
269 | 269 | } |
@@ -8,9 +8,10 @@ discard block |
||
8 | 8 | function getallheaders() |
9 | 9 | { |
10 | 10 | $headers = array(); |
11 | - foreach ($_SERVER as $h => $v) |
|
12 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
11 | + foreach ($_SERVER as $h => $v) { |
|
12 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) |
|
13 | 13 | $headers[$hp[1]] = $v; |
14 | + } |
|
14 | 15 | return $headers; |
15 | 16 | } |
16 | 17 | } |
@@ -214,7 +215,9 @@ discard block |
||
214 | 215 | */ |
215 | 216 | public function redirect($url = null) |
216 | 217 | { |
217 | - if (null === $url) $url = $this->getServer('HTTP_ORIGIN'); |
|
218 | + if (null === $url) { |
|
219 | + $url = $this->getServer('HTTP_ORIGIN'); |
|
220 | + } |
|
218 | 221 | ob_start(); |
219 | 222 | header('Location: ' . $url); |
220 | 223 | ob_end_clean(); |
@@ -261,7 +264,9 @@ discard block |
||
261 | 264 | $host = $this->getServerName(); |
262 | 265 | $protocol = $protocol ? $this->getProtocol() : ''; |
263 | 266 | $url = ''; |
264 | - if (!empty($host) && !empty($protocol)) $url = $protocol . $host; |
|
267 | + if (!empty($host) && !empty($protocol)) { |
|
268 | + $url = $protocol . $host; |
|
269 | + } |
|
265 | 270 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443])) { |
266 | 271 | $url .= ':' . $this->getServer('SERVER_PORT'); |
267 | 272 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @route /admin/config/params |
23 | 23 | * @label Parámetros de configuración de PSGS |
24 | 24 | * @visible false |
25 | - * @return mixed |
|
25 | + * @return string|null |
|
26 | 26 | */ |
27 | 27 | public function getConfigParams() |
28 | 28 | { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | foreach ($domains as $domain => $routes) { |
32 | 32 | $pDomain = str_replace('@', '', $domain); |
33 | 33 | $pDomain = str_replace('/', '', $pDomain); |
34 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
34 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
35 | 35 | } |
36 | 36 | return $this->json($response); |
37 | 37 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function config() |
47 | 47 | { |
48 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
48 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
49 | 49 | /* @var $form \PSFS\base\config\ConfigForm */ |
50 | 50 | $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig()); |
51 | 51 | $form->build(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente")); |
84 | 84 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
85 | - } else { |
|
85 | + }else { |
|
86 | 86 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
87 | 87 | } |
88 | 88 | } |