@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | } |
58 | 58 | } |
59 | 59 | $dto[$property->getName()] = $value; |
60 | - } else { |
|
60 | + }else { |
|
61 | 61 | $type = InjectorHelper::extractVarType($property->getDocComment()); |
62 | 62 | $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type ?: 'string'); |
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
66 | - } catch (\Exception $e) { |
|
67 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
66 | + }catch (\Exception $e) { |
|
67 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
68 | 68 | } |
69 | 69 | return $dto; |
70 | 70 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | $this->$key[] = $dto; |
102 | 102 | } |
103 | 103 | } |
104 | - } else { |
|
104 | + }else { |
|
105 | 105 | $this->$key = clone $this->__cache[$type]; |
106 | 106 | $this->$key->fromArray($value); |
107 | 107 | } |
108 | 108 | } |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | $this->castValue($key, $value, $type); |
111 | 111 | } |
112 | 112 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @return mixed |
135 | 135 | */ |
136 | - public function jsonSerialize(): array|string|null |
|
136 | + public function jsonSerialize(): array | string | null |
|
137 | 137 | { |
138 | 138 | return $this->toArray(); |
139 | 139 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $value = (bool)$rawValue; |
194 | 194 | break; |
195 | 195 | } |
196 | - } else { |
|
196 | + }else { |
|
197 | 197 | $value = $rawValue; |
198 | 198 | } |
199 | 199 | return $value; |
@@ -46,11 +46,11 @@ |
||
46 | 46 | foreach ($this->fields as $field) { |
47 | 47 | $array['fields'][] = $field->__toArray(); |
48 | 48 | } |
49 | - usort($array['fields'], function ($fieldA, $fieldB) { |
|
49 | + usort($array['fields'], function($fieldA, $fieldB) { |
|
50 | 50 | if ((bool)$fieldA['required'] !== (bool)$fieldB['required']) { |
51 | 51 | if ((bool)$fieldA['required']) { |
52 | 52 | return -1; |
53 | - } else { |
|
53 | + }else { |
|
54 | 54 | return 1; |
55 | 55 | } |
56 | 56 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | { |
64 | 64 | if (preg_match('/^asc$/i', $direction)) { |
65 | 65 | return self::ASC; |
66 | - } else { |
|
66 | + }else { |
|
67 | 67 | return self::DESC; |
68 | 68 | } |
69 | 69 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function init() |
63 | 63 | { |
64 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
65 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
64 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
65 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
66 | 66 | if (empty($this->routing) || Config::getParam('debug', true)) { |
67 | 67 | $this->debugLoad(); |
68 | 68 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->hydrateRouting(); |
84 | 84 | $this->simpatize(); |
85 | 85 | Logger::log('End routes load'); |
86 | - } else { |
|
86 | + }else { |
|
87 | 87 | Logger::log('Routes generation skipped'); |
88 | 88 | } |
89 | 89 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | try { |
101 | 101 | //Search action and execute |
102 | 102 | return $this->searchAction($route); |
103 | - } catch (AccessDeniedException $e) { |
|
104 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
103 | + }catch (AccessDeniedException $e) { |
|
104 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
105 | 105 | return Admin::staticAdminLogon(); |
106 | - } catch (RouterException $r) { |
|
106 | + }catch (RouterException $r) { |
|
107 | 107 | Logger::log($r->getMessage(), LOG_WARNING); |
108 | 108 | $code = $r->getCode(); |
109 | - } catch (Exception $e) { |
|
109 | + }catch (Exception $e) { |
|
110 | 110 | Logger::log($e->getMessage(), LOG_ERR); |
111 | 111 | throw $e; |
112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function searchAction($route) |
126 | 126 | { |
127 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
127 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
128 | 128 | //Revisamos si tenemos la ruta registrada |
129 | 129 | $parts = parse_url($route); |
130 | 130 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | throw new RouterException(t('Preconditions failed'), 412); |
147 | - } catch (Exception $e) { |
|
147 | + }catch (Exception $e) { |
|
148 | 148 | Logger::log($e->getMessage(), LOG_ERR); |
149 | 149 | throw $e; |
150 | 150 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } |
170 | 170 | } |
171 | 171 | $valid = count($action['requirements']) === $checked; |
172 | - } else { |
|
172 | + }else { |
|
173 | 173 | $valid = true; |
174 | 174 | } |
175 | 175 | return $valid; |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | if ($modules->hasResults()) { |
193 | 193 | foreach ($modules->getIterator() as $modulePath) { |
194 | 194 | $module = $modulePath->getBasename(); |
195 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
195 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
199 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $homeParams = NULL; |
214 | 214 | foreach ($this->routing as $pattern => $params) { |
215 | 215 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
216 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
216 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
217 | 217 | $homeParams = $params; |
218 | 218 | } |
219 | 219 | unset($method); |
@@ -245,18 +245,18 @@ discard block |
||
245 | 245 | { |
246 | 246 | $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : ''; |
247 | 247 | if ('' === $slug) { |
248 | - return $baseUrl . '/'; |
|
248 | + return $baseUrl.'/'; |
|
249 | 249 | } |
250 | 250 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
251 | 251 | throw new RouterException(t('No existe la ruta especificada')); |
252 | 252 | } |
253 | - $url = $baseUrl . $this->slugs[$slug]; |
|
253 | + $url = $baseUrl.$this->slugs[$slug]; |
|
254 | 254 | if (!empty($params)) { |
255 | 255 | foreach ($params as $key => $value) { |
256 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
256 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
257 | 257 | } |
258 | 258 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
259 | - $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default']; |
|
259 | + $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | private function checkPreActions($class, $method) |
270 | 270 | { |
271 | - $preAction = 'pre' . ucfirst($method); |
|
271 | + $preAction = 'pre'.ucfirst($method); |
|
272 | 272 | if (method_exists($class, $preAction)) { |
273 | 273 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
274 | 274 | try { |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
277 | 277 | error_clear_last(); |
278 | 278 | } |
279 | - } catch (Exception $e) { |
|
279 | + }catch (Exception $e) { |
|
280 | 280 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
281 | 281 | } |
282 | 282 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
295 | 295 | { |
296 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
296 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
297 | 297 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
298 | 298 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
299 | 299 | $cache = Cache::needCache(); |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | $return = null; |
302 | 302 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
303 | 303 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
304 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
304 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
305 | 305 | if (NULL !== $cachedData) { |
306 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
306 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
307 | 307 | Template::getInstance()->renderCache($cachedData, $headers); |
308 | 308 | $execute = FALSE; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | if ($execute) { |
312 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
312 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
313 | 313 | $this->checkPreActions($class, $action['method']); |
314 | 314 | $return = call_user_func_array([$class, $action['method']], $params); |
315 | 315 | if (false === $return) { |
@@ -79,18 +79,18 @@ |
||
79 | 79 | if (!Request::getInstance()->isFile()) { |
80 | 80 | return $this->router->execute($uri ?: $this->actualUri); |
81 | 81 | } |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | return ConfigController::getInstance()->config(); |
84 | 84 | } |
85 | - } catch (AdminCredentialsException $a) { |
|
85 | + }catch (AdminCredentialsException $a) { |
|
86 | 86 | return UserController::showAdminManager(); |
87 | - } catch (SecurityException $s) { |
|
87 | + }catch (SecurityException $s) { |
|
88 | 88 | return $this->security->notAuthorized($this->actualUri); |
89 | - } catch (RouterException $r) { |
|
89 | + }catch (RouterException $r) { |
|
90 | 90 | return $this->router->httpNotFound($r); |
91 | - } catch (ApiException $a) { |
|
91 | + }catch (ApiException $a) { |
|
92 | 92 | return $this->router->httpNotFound($a, true); |
93 | - } catch (\Exception $e) { |
|
93 | + }catch (\Exception $e) { |
|
94 | 94 | return $this->dumpException($e); |
95 | 95 | } |
96 | 96 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | if (!defined('LOG_DIR')) { |
21 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
22 | - define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
21 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
22 | + define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | { |
60 | 60 | $args = func_get_args(); |
61 | 61 | list($logger, $debug, $path) = $this->setup($args); |
62 | - $this->stream = fopen($path . DIRECTORY_SEPARATOR . date('Ymd') . '.log', 'ab+'); |
|
62 | + $this->stream = fopen($path.DIRECTORY_SEPARATOR.date('Ymd').'.log', 'ab+'); |
|
63 | 63 | if (false !== $this->stream && is_resource($this->stream)) { |
64 | 64 | $this->addPushLogger($logger, $debug); |
65 | - } else { |
|
65 | + }else { |
|
66 | 66 | throw new ConfigException(t('Error creating logger')); |
67 | 67 | } |
68 | 68 | $this->logLevel = strtoupper(Config::getParam('log.level', 'NOTICE')); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | private function createLoggerPath(): string |
142 | 142 | { |
143 | 143 | $logger = $this->setLoggerName(); |
144 | - $path = Config::getParam('default.log.path', LOG_DIR) . DIRECTORY_SEPARATOR . $logger . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); |
|
144 | + $path = Config::getParam('default.log.path', LOG_DIR).DIRECTORY_SEPARATOR.$logger.DIRECTORY_SEPARATOR.date('Y').DIRECTORY_SEPARATOR.date('m'); |
|
145 | 145 | GeneratorHelper::createDir($path); |
146 | 146 | return $path; |
147 | 147 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | public static function dropServerValue(string $key): void |
29 | 29 | { |
30 | - if(array_key_exists($key, $_SERVER)) { |
|
30 | + if (array_key_exists($key, $_SERVER)) { |
|
31 | 31 | unset($_SERVER[$key]); |
32 | 32 | } |
33 | 33 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $use /= 1024; |
41 | 41 | break; |
42 | 42 | case "MBytes": |
43 | - $use /= (1024 * 1024); |
|
43 | + $use /= (1024*1024); |
|
44 | 44 | break; |
45 | 45 | case "Bytes": |
46 | 46 | default: |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | ini_set('display_errors', 1); |
71 | 71 | } |
72 | 72 | //Warning & Notice handler |
73 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
73 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
74 | 74 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]); |
75 | 75 | return true; |
76 | 76 | }, E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR); |
77 | 77 | |
78 | - register_shutdown_function(function () { |
|
78 | + register_shutdown_function(function() { |
|
79 | 79 | $error = error_get_last() or json_last_error() or preg_last_error() or \DateTime::getLastErrors(); |
80 | 80 | if ($error !== NULL) { |
81 | 81 | $errno = $error["type"]; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | |
91 | 91 | if (self::getTs() > 10 && null !== Config::getParam('log.slack.hook')) { |
92 | 92 | SlackHelper::getInstance()->trace('Slow service endpoint', '', '', [ |
93 | - 'time' => round(self::getTs(), 3) . ' secs', |
|
94 | - 'memory' => round(self::getMem('MBytes'), 3) . ' Mb', |
|
93 | + 'time' => round(self::getTs(), 3).' secs', |
|
94 | + 'memory' => round(self::getMem('MBytes'), 3).' Mb', |
|
95 | 95 | ]); |
96 | 96 | } |
97 | 97 | return false; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | Inspector::stats('[SystemTrait] Initializing stats (mem + ts)'); |
107 | 107 | if (ServerHelper::hasServerValue('REQUEST_TIME_FLOAT')) { |
108 | 108 | $this->ts = (float)ServerHelper::getServerValue('REQUEST_TIME_FLOAT'); |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | $this->ts = PSFS_START_TS; |
111 | 111 | } |
112 | 112 | $this->mem = PSFS_START_MEM; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function init() |
99 | 99 | { |
100 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
100 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
101 | 101 | $this->loadConfigData(); |
102 | 102 | } |
103 | 103 | return $this; |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $finalData = self::saveExtraParams($data); |
213 | 213 | $saved = false; |
214 | 214 | try { |
215 | - $finalData = array_filter($finalData, function ($key, $value) { |
|
215 | + $finalData = array_filter($finalData, function($key, $value) { |
|
216 | 216 | return in_array($key, self::$required, true) || !empty($value); |
217 | 217 | }, ARRAY_FILTER_USE_BOTH); |
218 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
218 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($finalData, JSON_PRETTY_PRINT))); |
|
219 | 219 | self::getInstance()->loadConfigData(); |
220 | 220 | $saved = true; |
221 | - } catch (ConfigException $e) { |
|
221 | + }catch (ConfigException $e) { |
|
222 | 222 | Logger::log($e->getMessage(), LOG_ERR); |
223 | 223 | } |
224 | 224 | return $saved; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function loadConfigData(): void |
252 | 252 | { |
253 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
253 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
254 | 254 | $this->debug = array_key_exists('debug', $this->config) ? (bool)$this->config['debug'] : FALSE; |
255 | 255 | if (array_key_exists('cache.var', $this->config)) { |
256 | 256 | Security::getInstance()->setSessionKey('config.cache.var', $this->config['cache.var']); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | public static function getParam($key, $defaultValue = null, $module = null) |
276 | 276 | { |
277 | 277 | if (null !== $module) { |
278 | - return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue)); |
|
278 | + return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue)); |
|
279 | 279 | } |
280 | 280 | $param = self::getInstance()->get($key); |
281 | 281 | return (null !== $param) ? $param : $defaultValue; |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | { |
292 | 292 | $done = true; |
293 | 293 | foreach (self::$cleanable_config_files as $configFile) { |
294 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . $configFile)) { |
|
295 | - if (!unlink(CONFIG_DIR . DIRECTORY_SEPARATOR . $configFile)) { |
|
294 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.$configFile)) { |
|
295 | + if (!unlink(CONFIG_DIR.DIRECTORY_SEPARATOR.$configFile)) { |
|
296 | 296 | $done = false; |
297 | 297 | } |
298 | 298 | } |