@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function generateModule() |
36 | 36 | { |
37 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
37 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
38 | 38 | /* @var $form ConfigForm */ |
39 | 39 | $form = new ModuleForm(); |
40 | 40 | $form->build(); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $this->gen->createStructureModule($module, false, $type, $apiClass); |
67 | 67 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, t("Módulo %s generado correctamente"))); |
68 | 68 | // Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
69 | - } catch (Exception $e) { |
|
70 | - Logger::log($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
69 | + }catch (Exception $e) { |
|
70 | + Logger::log($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
71 | 71 | Security::getInstance()->setFlash("callback_message", htmlentities($e->getMessage())); |
72 | 72 | } |
73 | 73 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() |
28 | 28 | { |
29 | - Logger::log(static::class . ' constructor invoked'); |
|
29 | + Logger::log(static::class.' constructor invoked'); |
|
30 | 30 | $this->init(); |
31 | 31 | } |
32 | 32 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | $calledClass = static::class; |
86 | 86 | try { |
87 | 87 | $instance = InjectorHelper::constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass); |
88 | - $setter = 'set' . ucfirst($variable); |
|
88 | + $setter = 'set'.ucfirst($variable); |
|
89 | 89 | if (method_exists($calledClass, $setter)) { |
90 | 90 | $this->$setter($instance); |
91 | - } else { |
|
91 | + }else { |
|
92 | 92 | $this->$variable = $instance; |
93 | 93 | } |
94 | - } catch (Exception $e) { |
|
95 | - Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR); |
|
94 | + }catch (Exception $e) { |
|
95 | + Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR); |
|
96 | 96 | throw $e; |
97 | 97 | } |
98 | 98 | return $this; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | if (!$this->isLoaded()) { |
109 | 109 | $filename = sha1(get_class($this)); |
110 | - $cacheFilename = 'reflections' . DIRECTORY_SEPARATOR . substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2) . DIRECTORY_SEPARATOR . $filename . '.json'; |
|
110 | + $cacheFilename = 'reflections'.DIRECTORY_SEPARATOR.substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2).DIRECTORY_SEPARATOR.$filename.'.json'; |
|
111 | 111 | /** @var Cache $cacheService */ |
112 | 112 | $cacheService = Cache::getInstance(); |
113 | 113 | /** @var Config $configService */ |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | $this->setLoaded(); |
128 | - } else { |
|
129 | - Logger::log(get_class($this) . ' already loaded', LOG_INFO); |
|
128 | + }else { |
|
129 | + Logger::log(get_class($this).' already loaded', LOG_INFO); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public static function header($name, $default = null) |
124 | 124 | { |
125 | - return self::getInstance()->getHeader($name, $default); |
|
125 | + return self::getInstance()->getHeader($name, $default); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | $header = null; |
136 | 136 | if ($this->hasHeader($name)) { |
137 | 137 | $header = $this->header[$name]; |
138 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
139 | - $header = $this->query['h_' . strtolower($name)]; |
|
140 | - } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
141 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
138 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
139 | + $header = $this->query['h_'.strtolower($name)]; |
|
140 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
141 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
142 | 142 | } |
143 | 143 | return $header ?: $default; |
144 | 144 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | $url = $this->getServer('HTTP_ORIGIN'); |
243 | 243 | } |
244 | 244 | ob_start(); |
245 | - header('Location: ' . $url); |
|
245 | + header('Location: '.$url); |
|
246 | 246 | ob_end_clean(); |
247 | 247 | Security::getInstance()->updateSession(); |
248 | 248 | exit(t('Redirect...')); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $url = $this->getServerName(); |
259 | 259 | $protocol = $hasProtocol ? $this->getProtocol() : ''; |
260 | 260 | if (!empty($protocol)) { |
261 | - $url = $protocol . $url; |
|
261 | + $url = $protocol.$url; |
|
262 | 262 | } |
263 | 263 | $url = $this->checkServerPort($url); |
264 | 264 | return $url; |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | { |
273 | 273 | $port = (integer)$this->getServer('SERVER_PORT'); |
274 | 274 | $host = $this->getServer('HTTP_HOST'); |
275 | - if(!empty($host)) { |
|
275 | + if (!empty($host)) { |
|
276 | 276 | $parts = explode(':', $host); |
277 | 277 | $hostPort = (integer)end($parts); |
278 | - if(count($parts) > 1 && $hostPort !== $port) { |
|
278 | + if (count($parts) > 1 && $hostPort !== $port) { |
|
279 | 279 | $port = $hostPort; |
280 | 280 | } |
281 | 281 | } |
282 | 282 | if (!in_array($port, [80, 443], true)) { |
283 | - $url .= ':' . $port; |
|
283 | + $url .= ':'.$port; |
|
284 | 284 | } |
285 | 285 | return $url; |
286 | 286 | } |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function init() |
86 | 86 | { |
87 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE); |
|
87 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE); |
|
88 | 88 | if (empty($this->routing) || Config::getParam('debug', true)) { |
89 | 89 | $this->debugLoad(); |
90 | - } else { |
|
91 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE); |
|
90 | + }else { |
|
91 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE); |
|
92 | 92 | } |
93 | 93 | $this->checkExternalModules(false); |
94 | 94 | $this->setLoaded(); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | $notFoundRoute = Config::getParam('route.404'); |
131 | - if(null !== $notFoundRoute) { |
|
131 | + if (null !== $notFoundRoute) { |
|
132 | 132 | Request::getInstance()->redirect($this->getRoute($notFoundRoute, true)); |
133 | - } else { |
|
133 | + }else { |
|
134 | 134 | return $template->render('error.html.twig', array( |
135 | 135 | 'exception' => $exception, |
136 | 136 | 'trace' => $exception->getTraceAsString(), |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | try { |
182 | 182 | //Search action and execute |
183 | 183 | return $this->searchAction($route); |
184 | - } catch (AccessDeniedException $e) { |
|
185 | - Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']); |
|
184 | + }catch (AccessDeniedException $e) { |
|
185 | + Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']); |
|
186 | 186 | return Admin::staticAdminLogon($route); |
187 | - } catch (RouterException $r) { |
|
187 | + }catch (RouterException $r) { |
|
188 | 188 | Logger::log($r->getMessage(), LOG_WARNING); |
189 | - } catch (Exception $e) { |
|
189 | + }catch (Exception $e) { |
|
190 | 190 | Logger::log($e->getMessage(), LOG_ERR); |
191 | 191 | throw $e; |
192 | 192 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function searchAction($route) |
206 | 206 | { |
207 | - Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG); |
|
207 | + Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG); |
|
208 | 208 | //Revisamos si tenemos la ruta registrada |
209 | 209 | $parts = parse_url($route); |
210 | 210 | $path = array_key_exists('path', $parts) ? $parts['path'] : $route; |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | /** @var $class Controller */ |
220 | 220 | $class = RouterHelper::getClassToCall($action); |
221 | 221 | try { |
222 | - if($this->checkRequirements($action, $get)) { |
|
222 | + if ($this->checkRequirements($action, $get)) { |
|
223 | 223 | return $this->executeCachedRoute($route, $action, $class, $get); |
224 | - } else { |
|
224 | + }else { |
|
225 | 225 | throw new RouterException(t('La ruta no es válida'), 400); |
226 | 226 | } |
227 | - } catch (Exception $e) { |
|
227 | + }catch (Exception $e) { |
|
228 | 228 | Logger::log($e->getMessage(), LOG_ERR); |
229 | 229 | throw $e; |
230 | 230 | } |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | */ |
241 | 241 | private function checkRequirements(array $action, $params = []) { |
242 | 242 | Inspector::stats('[Router] Checking request requirements', Inspector::SCOPE_DEBUG); |
243 | - if(!empty($params) && !empty($action['requirements'])) { |
|
243 | + if (!empty($params) && !empty($action['requirements'])) { |
|
244 | 244 | $checked = 0; |
245 | - foreach(array_keys($params) as $key) { |
|
246 | - if(in_array($key, $action['requirements'], true)) { |
|
245 | + foreach (array_keys($params) as $key) { |
|
246 | + if (in_array($key, $action['requirements'], true)) { |
|
247 | 247 | $checked++; |
248 | 248 | } |
249 | 249 | } |
250 | 250 | $valid = count($action['requirements']) === $checked; |
251 | - } else { |
|
251 | + }else { |
|
252 | 252 | $valid = true; |
253 | 253 | } |
254 | 254 | return $valid; |
@@ -299,14 +299,14 @@ discard block |
||
299 | 299 | $this->checkExternalModules(); |
300 | 300 | if (file_exists($modulesPath)) { |
301 | 301 | $modules = $this->finder->directories()->in($modulesPath)->depth(0); |
302 | - if($modules->hasResults()) { |
|
302 | + if ($modules->hasResults()) { |
|
303 | 303 | foreach ($modules->getIterator() as $modulePath) { |
304 | 304 | $module = $modulePath->getBasename(); |
305 | - $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing); |
|
305 | + $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
309 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE); |
|
309 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $homeParams = NULL; |
324 | 324 | foreach ($this->routing as $pattern => $params) { |
325 | 325 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
326 | - if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) { |
|
326 | + if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) { |
|
327 | 327 | $homeParams = $params; |
328 | 328 | } |
329 | 329 | unset($method); |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | private function inspectDir($origen, $namespace = 'PSFS', $routing = []) |
347 | 347 | { |
348 | 348 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->depth('< 3')->name('*.php'); |
349 | - if($files->hasResults()) { |
|
349 | + if ($files->hasResults()) { |
|
350 | 350 | foreach ($files->getIterator() as $file) { |
351 | - if($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
352 | - $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
353 | - } else { |
|
351 | + if ($namespace !== 'PSFS' && method_exists($file, 'getRelativePathname')) { |
|
352 | + $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname())); |
|
353 | + }else { |
|
354 | 354 | $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname())); |
355 | 355 | } |
356 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace); |
|
356 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace); |
|
357 | 357 | } |
358 | 358 | } |
359 | 359 | $this->finder = new Finder(); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | private function addRouting($namespace, &$routing, $module = 'PSFS') |
381 | 381 | { |
382 | 382 | if (self::exists($namespace)) { |
383 | - if(I18nHelper::checkI18Class($namespace)) { |
|
383 | + if (I18nHelper::checkI18Class($namespace)) { |
|
384 | 384 | return $routing; |
385 | 385 | } |
386 | 386 | $reflection = new ReflectionClass($namespace); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | if (!$this->domains) { |
420 | 420 | $this->domains = []; |
421 | 421 | } |
422 | - $domain = '@' . $class->getConstant('DOMAIN') . '/'; |
|
422 | + $domain = '@'.$class->getConstant('DOMAIN').'/'; |
|
423 | 423 | if (!array_key_exists($domain, $this->domains)) { |
424 | 424 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
425 | 425 | } |
@@ -435,11 +435,11 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function simpatize() |
437 | 437 | { |
438 | - $translationFileName = 'translations' . DIRECTORY_SEPARATOR . 'routes_translations.php'; |
|
439 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
438 | + $translationFileName = 'translations'.DIRECTORY_SEPARATOR.'routes_translations.php'; |
|
439 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
440 | 440 | $this->generateSlugs($absoluteTranslationFileName); |
441 | 441 | GeneratorHelper::createDir(CONFIG_DIR); |
442 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
442 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
443 | 443 | |
444 | 444 | return $this; |
445 | 445 | } |
@@ -455,18 +455,18 @@ discard block |
||
455 | 455 | public function getRoute($slug = '', $absolute = FALSE, array $params = []) |
456 | 456 | { |
457 | 457 | if ('' === $slug) { |
458 | - return $absolute ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
458 | + return $absolute ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
459 | 459 | } |
460 | 460 | if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) { |
461 | 461 | throw new RouterException(t('No existe la ruta especificada')); |
462 | 462 | } |
463 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
463 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
464 | 464 | if (!empty($params)) { |
465 | 465 | foreach ($params as $key => $value) { |
466 | - $url = str_replace('{' . $key . '}', $value, $url); |
|
466 | + $url = str_replace('{'.$key.'}', $value, $url); |
|
467 | 467 | } |
468 | 468 | } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) { |
469 | - $url = $absolute ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
469 | + $url = $absolute ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]['default'] : $this->routing[$this->slugs[$slug]]['default']; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -485,15 +485,15 @@ discard block |
||
485 | 485 | * @param string $method |
486 | 486 | */ |
487 | 487 | private function checkPreActions($class, $method) { |
488 | - $preAction = 'pre' . ucfirst($method); |
|
489 | - if(method_exists($class, $preAction)) { |
|
488 | + $preAction = 'pre'.ucfirst($method); |
|
489 | + if (method_exists($class, $preAction)) { |
|
490 | 490 | Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG); |
491 | 491 | try { |
492 | - if(false === call_user_func_array([$class, $preAction])) { |
|
492 | + if (false === call_user_func_array([$class, $preAction])) { |
|
493 | 493 | Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]); |
494 | 494 | error_clear_last(); |
495 | 495 | } |
496 | - } catch (Exception $e) { |
|
496 | + }catch (Exception $e) { |
|
497 | 497 | Logger::log($e->getMessage(), LOG_ERR, [$class, $method]); |
498 | 498 | } |
499 | 499 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
512 | 512 | { |
513 | - Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG); |
|
513 | + Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG); |
|
514 | 514 | $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams()); |
515 | 515 | Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action); |
516 | 516 | $cache = Cache::needCache(); |
@@ -518,15 +518,15 @@ discard block |
||
518 | 518 | $return = null; |
519 | 519 | if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) { |
520 | 520 | list($path, $cacheDataName) = $this->cache->getRequestCacheHash(); |
521 | - $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache); |
|
521 | + $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache); |
|
522 | 522 | if (NULL !== $cachedData) { |
523 | - $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON); |
|
523 | + $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON); |
|
524 | 524 | Template::getInstance()->renderCache($cachedData, $headers); |
525 | 525 | $execute = FALSE; |
526 | 526 | } |
527 | 527 | } |
528 | 528 | if ($execute) { |
529 | - Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG); |
|
529 | + Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG); |
|
530 | 530 | $this->checkPreActions($class, $action['method']); |
531 | 531 | $return = call_user_func_array([$class, $action['method']], $params); |
532 | 532 | if (false === $return) { |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath) |
566 | 566 | { |
567 | 567 | $extModule = $modulePath->getBasename(); |
568 | - $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php'); |
|
569 | - if(file_exists($moduleAutoloader)) { |
|
568 | + $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php'); |
|
569 | + if (file_exists($moduleAutoloader)) { |
|
570 | 570 | include_once $moduleAutoloader; |
571 | 571 | if ($hydrateRoute) { |
572 | - $this->routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $this->routing); |
|
572 | + $this->routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $this->routing); |
|
573 | 573 | } |
574 | 574 | } |
575 | 575 | } |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | { |
584 | 584 | try { |
585 | 585 | $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module); |
586 | - $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src'; |
|
587 | - if(file_exists($externalModulePath)) { |
|
586 | + $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src'; |
|
587 | + if (file_exists($externalModulePath)) { |
|
588 | 588 | $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0); |
589 | - if($externalModule->hasResults()) { |
|
589 | + if ($externalModule->hasResults()) { |
|
590 | 590 | foreach ($externalModule->getIterator() as $modulePath) { |
591 | 591 | $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath); |
592 | 592 | } |
593 | 593 | } |
594 | 594 | } |
595 | - } catch (Exception $e) { |
|
595 | + }catch (Exception $e) { |
|
596 | 596 | Logger::log($e->getMessage(), LOG_WARNING); |
597 | 597 | $module = null; |
598 | 598 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | public function getServer($key, $default = null) |
22 | 22 | { |
23 | 23 | $value = null; |
24 | - if(array_key_exists($key, $this->server)) { |
|
24 | + if (array_key_exists($key, $this->server)) { |
|
25 | 25 | $value = $this->server[$key]; |
26 | 26 | } |
27 | 27 | return $value ?: $default; |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | { |
26 | 26 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
27 | 27 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
28 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
28 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
29 | 29 | $reflectionClass = new ReflectionClass($actionClass); |
30 | - if($reflectionClass->hasMethod('getInstance')) { |
|
30 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
31 | 31 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
32 | - } else { |
|
32 | + }else { |
|
33 | 33 | $class = new $actionClass; |
34 | 34 | } |
35 | 35 | return $class; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $expr = preg_quote($expr, '/'); |
119 | 119 | $expr = str_replace('###', '(.*)', $expr); |
120 | 120 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
121 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
121 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
122 | 122 | return $matched; |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public static function extractDomainInfo(ReflectionClass $class, $domain) |
131 | 131 | { |
132 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
132 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
133 | 133 | $templatesPath = 'templates'; |
134 | 134 | $publicPath = 'public'; |
135 | 135 | $modelsPath = 'models'; |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | $modelsPath = ucfirst($modelsPath); |
140 | 140 | } |
141 | 141 | if ($class->hasConstant('TPL')) { |
142 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
142 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
143 | 143 | } |
144 | 144 | return [ |
145 | 145 | 'base' => $path, |
146 | - 'template' => $path . $templatesPath, |
|
147 | - 'model' => $path . $modelsPath, |
|
148 | - 'public' => $path . $publicPath, |
|
146 | + 'template' => $path.$templatesPath, |
|
147 | + 'model' => $path.$modelsPath, |
|
148 | + 'public' => $path.$publicPath, |
|
149 | 149 | ]; |
150 | 150 | } |
151 | 151 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | foreach ($parameters as $param) { |
167 | 167 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
168 | 168 | $params[$param->getName()] = $param->getDefaultValue(); |
169 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
170 | - } elseif(!$param->isOptional()) { |
|
169 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
170 | + } elseif (!$param->isOptional()) { |
|
171 | 171 | $requirements[] = $param->getName(); |
172 | 172 | } |
173 | 173 | } |
174 | - } else { |
|
174 | + }else { |
|
175 | 175 | $default = $regex; |
176 | 176 | } |
177 | 177 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $httpMethod = AnnotationHelper::extractReflectionHttpMethod($docComments); |
201 | 201 | $icon = AnnotationHelper::extractDocIcon($docComments); |
202 | 202 | $label = AnnotationHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
203 | - $route = $httpMethod . "#|#" . $regex; |
|
203 | + $route = $httpMethod."#|#".$regex; |
|
204 | 204 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
205 | 205 | $info = [ |
206 | 206 | 'method' => $method->getName(), |
@@ -19,11 +19,11 @@ |
||
19 | 19 | public static function checkApiActions($namespace, $domain, $api) { |
20 | 20 | $actions = []; |
21 | 21 | $reflector = new ReflectionClass($namespace); |
22 | - if(null !== $reflector) { |
|
23 | - foreach($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
22 | + if (null !== $reflector) { |
|
23 | + foreach ($reflector->getMethods(ReflectionMethod::IS_PUBLIC) as $apiAction) { |
|
24 | 24 | $docComments = $apiAction->getDocComment(); |
25 | 25 | $action = AnnotationHelper::extractAction($docComments); |
26 | - if(null !== $action) { |
|
26 | + if (null !== $action) { |
|
27 | 27 | list($route, $info) = RouterHelper::extractRouteInfo($apiAction, $api, $domain); |
28 | 28 | list($method, $cleanRoute) = RouterHelper::extractHttpRoute($route); |
29 | 29 | $formAction = new FormAction(); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $label = self::getLabel($property->getDocComment()); |
32 | 32 | $values = self::getValues($property->getDocComment()); |
33 | 33 | $isArray = (bool)preg_match('/\[\]$/', $instanceType); |
34 | - if($isArray) { |
|
34 | + if ($isArray) { |
|
35 | 35 | $instanceType = str_replace('[]', '', $instanceType); |
36 | 36 | } |
37 | - if($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
37 | + if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
38 | 38 | list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType); |
39 | 39 | $variables[$property->getName()] = [ |
40 | 40 | 'type' => $type, |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'required' => $isRequired, |
43 | 43 | 'description' => $label, |
44 | 44 | ]; |
45 | - } else { |
|
45 | + }else { |
|
46 | 46 | $instance = new ReflectionClass($instanceType); |
47 | 47 | $variables[$property->getName()] = [ |
48 | 48 | 'is_array' => $isArray, |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'properties' => self::extractVariables($instance), |
52 | 52 | ]; |
53 | 53 | } |
54 | - if(!empty($values)){ |
|
54 | + if (!empty($values)) { |
|
55 | 55 | $variables[$property->getName()]['enum'] = $values; |
56 | 56 | } |
57 | 57 | } |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public static function constructInjectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
157 | 157 | { |
158 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
158 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
159 | 159 | $reflector = new ReflectionClass($calledClass); |
160 | 160 | $property = $reflector->getProperty($variable); |
161 | 161 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
162 | 162 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
163 | 163 | $instance = $varInstanceType::getInstance(); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $instance = new $varInstanceType(); |
166 | 166 | } |
167 | 167 | return $instance; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public static function getClassProperties($class) |
176 | 176 | { |
177 | 177 | $properties = []; |
178 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
178 | + Logger::log('Extracting annotations properties from class '.$class); |
|
179 | 179 | $selfReflector = new ReflectionClass($class); |
180 | 180 | if (false !== $selfReflector->getParentClass()) { |
181 | 181 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -92,7 +92,7 @@ |
||
92 | 92 | * @return string|null |
93 | 93 | */ |
94 | 94 | public static function extractFromDoc($needle, $comments, $default = null) { |
95 | - preg_match('/@' . $needle . '\ (.*)(\n|\r)/im', $comments, $matches); |
|
95 | + preg_match('/@'.$needle.'\ (.*)(\n|\r)/im', $comments, $matches); |
|
96 | 96 | return (count($matches) > 0) ? $matches[1] : $default; |
97 | 97 | } |
98 | 98 | } |