@@ -8,24 +8,24 @@ |
||
8 | 8 | defined('JSON_THROW_ON_ERROR') or define('JSON_THROW_ON_ERROR', 4194304); |
9 | 9 | defined('JSON_INVALID_UTF8_SUBSTITUTE') or define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152); |
10 | 10 | |
11 | -if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php')) { |
|
12 | - @require_once PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php'; |
|
11 | +if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php')) { |
|
12 | + @require_once PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__); |
16 | 16 | if (str_contains(SOURCE_DIR, 'vendor')) { |
17 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
18 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
19 | -} else { |
|
20 | - defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
21 | - defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
17 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
18 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
19 | +}else { |
|
20 | + defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
21 | + defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
22 | 22 | } |
23 | -defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
24 | -defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
25 | -defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
26 | -defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
27 | -defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
28 | -defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
23 | +defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
24 | +defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
25 | +defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
26 | +defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
27 | +defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
28 | +defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
29 | 29 | |
30 | 30 | if (!class_exists(bootstrap::class)) { |
31 | 31 | /** |
@@ -40,7 +40,9 @@ |
||
40 | 40 | { |
41 | 41 | if (!self::$loaded) { |
42 | 42 | defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true); |
43 | - if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
43 | + if (class_exists("\\PSFS\\base\\Logger")) { |
|
44 | + \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO); |
|
45 | + } |
|
44 | 46 | self::$loaded = true; |
45 | 47 | } |
46 | 48 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | // autoloader |
15 | 15 | function PSFSAutoloader($class): false |
16 | 16 | { |
17 | - Logger::log("Trying to load class {$class} with " . __FILE__); |
|
17 | + Logger::log("Trying to load class {$class} with ".__FILE__); |
|
18 | 18 | // it only autoload class into the Rain scope |
19 | 19 | if (str_contains($class, 'PSFS')) { |
20 | 20 | // Change order src |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $path = str_replace("\\", DIRECTORY_SEPARATOR, $class); |
24 | 24 | |
25 | 25 | // filepath |
26 | - $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php"; |
|
26 | + $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php"; |
|
27 | 27 | |
28 | 28 | // require the file |
29 | 29 | if (file_exists($abs_path)) { |
30 | 30 | require_once $abs_path; |
31 | - } else { |
|
32 | - Logger::log("{$class} not loaded with " . __FILE__); |
|
31 | + }else { |
|
32 | + Logger::log("{$class} not loaded with ".__FILE__); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | return false; |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @throws \PSFS\base\exception\GeneratorException |
17 | 17 | */ |
18 | 18 | public function getConnectionManager(string $module, string $path): array { |
19 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $path . $module); |
|
19 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $path.$module); |
|
20 | 20 | $generatorConfig = $this->getConfigGenerator($modulePath); |
21 | 21 | |
22 | 22 | $manager = new MigrationManager(); |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function createStructureModule(string $module, bool $force = false, string $type = "", string $apiClass = "", bool $skipMigration = false): void |
51 | 51 | { |
52 | - $modPath = CORE_DIR . DIRECTORY_SEPARATOR; |
|
52 | + $modPath = CORE_DIR.DIRECTORY_SEPARATOR; |
|
53 | 53 | $module = ucfirst($module); |
54 | 54 | $this->createModulePath($module, $modPath); |
55 | 55 | $this->createModulePathTree($module, $modPath); |
56 | 56 | $this->createModuleBaseFiles($module, $modPath, $force, $type); |
57 | 57 | $this->createModuleModels($module, $modPath); |
58 | 58 | $this->generateBaseApiTemplate($module, $modPath, $force, $apiClass); |
59 | - if(!$skipMigration) { |
|
59 | + if (!$skipMigration) { |
|
60 | 60 | $this->createModuleMigrations($module, $modPath); |
61 | 61 | } |
62 | 62 | //Redireccionamos al home definido |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function createModuleBaseFiles($module, $modPath, $force = false, $controllerType = '') |
75 | 75 | { |
76 | - $modulePath = $modPath . $module; |
|
76 | + $modulePath = $modPath.$module; |
|
77 | 77 | $this->generateControllerTemplate($module, $modulePath, $force, $controllerType); |
78 | 78 | $this->generateServiceTemplate($module, $modulePath, $force); |
79 | 79 | $this->generateSchemaTemplate($module, $modulePath, $force); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->genereateAutoloaderTemplate($module, $modulePath, $force); |
95 | 95 | $this->generatePropertiesTemplate($module, $modulePath, $force); |
96 | 96 | $this->generateConfigTemplate($modulePath, $force); |
97 | - $this->createModuleModels($module, CORE_DIR . DIRECTORY_SEPARATOR); |
|
97 | + $this->createModuleModels($module, CORE_DIR.DIRECTORY_SEPARATOR); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -114,26 +114,26 @@ discard block |
||
114 | 114 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
115 | 115 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
116 | 116 | "class" => $class, |
117 | - "controllerType" => $class . "Base", |
|
117 | + "controllerType" => $class."Base", |
|
118 | 118 | "is_base" => false |
119 | 119 | )); |
120 | - $controller = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
121 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
120 | + $controller = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
121 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
122 | 122 | |
123 | 123 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
124 | 124 | "module" => $module, |
125 | 125 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
126 | 126 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
127 | - "class" => $class . "Base", |
|
127 | + "class" => $class."Base", |
|
128 | 128 | "service" => $class, |
129 | 129 | "controllerType" => $controllerType, |
130 | 130 | "is_base" => true, |
131 | 131 | "domain" => $class, |
132 | 132 | )); |
133 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath . DIRECTORY_SEPARATOR . "Controller" . |
|
134 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
133 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $modPath.DIRECTORY_SEPARATOR."Controller". |
|
134 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
135 | 135 | |
136 | - $filename = $modPath . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php"; |
|
136 | + $filename = $modPath.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php"; |
|
137 | 137 | $test = true; |
138 | 138 | if (!file_exists($filename)) { |
139 | 139 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | private function createModuleModels($module, $path) |
156 | 156 | { |
157 | - $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $path . $module); |
|
157 | + $modulePath = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $path.$module); |
|
158 | 158 | $configGenerator = $this->getConfigGenerator($modulePath); |
159 | 159 | |
160 | 160 | $this->buildModels($configGenerator); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array( |
164 | 164 | "module" => $module, |
165 | 165 | )); |
166 | - $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $modulePath . DIRECTORY_SEPARATOR . "Config" . |
|
167 | - DIRECTORY_SEPARATOR . "config.php", true); |
|
166 | + $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$modulePath.DIRECTORY_SEPARATOR."Config". |
|
167 | + DIRECTORY_SEPARATOR."config.php", true); |
|
168 | 168 | Logger::log("Generado config genérico para propel"); |
169 | 169 | } |
170 | 170 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | if ($totalNbTables) { |
232 | 232 | Logger::log(sprintf('%d tables found in all databases.', $totalNbTables)); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | Logger::log('No table found in all databases'); |
235 | 235 | } |
236 | 236 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $migrationFileName = $manager->getMigrationFileName($timestamp); |
289 | 289 | $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp); |
290 | 290 | |
291 | - $file = $generatorConfig->getSection('paths')['migrationDir'] . DIRECTORY_SEPARATOR . $migrationFileName; |
|
291 | + $file = $generatorConfig->getSection('paths')['migrationDir'].DIRECTORY_SEPARATOR.$migrationFileName; |
|
292 | 292 | file_put_contents($file, $migrationClassBody); |
293 | 293 | |
294 | 294 | Logger::log(sprintf('"%s" file successfully created.', $file)); |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | private function generateBaseApiTemplate($module, $modPath, $force = false, $apiClass = "") |
307 | 307 | { |
308 | 308 | $created = true; |
309 | - $modelPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
310 | - $apiPath = $modPath . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
309 | + $modelPath = $modPath.$module.DIRECTORY_SEPARATOR.'Models'; |
|
310 | + $apiPath = $modPath.$module.DIRECTORY_SEPARATOR.'Api'; |
|
311 | 311 | if (file_exists($modelPath)) { |
312 | 312 | $dir = dir($modelPath); |
313 | 313 | $this->generateApiFiles($module, $force, $apiClass, $dir, $apiPath); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | //Generamos el fichero de configuración |
326 | 326 | Logger::log("Generamos fichero vacío de configuración"); |
327 | 327 | return $this->writeTemplateToFile("<?php\n\t", |
328 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
328 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
329 | 329 | $force); |
330 | 330 | } |
331 | 331 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | "db" => $this->config->get("db_name"), |
347 | 347 | )); |
348 | 348 | return $this->writeTemplateToFile($schema, |
349 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
349 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
350 | 350 | $force); |
351 | 351 | } |
352 | 352 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
365 | 365 | )); |
366 | 366 | return $this->writeTemplateToFile($buildProperties, |
367 | - $modPath . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.php", |
|
367 | + $modPath.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.php", |
|
368 | 368 | $force); |
369 | 369 | } |
370 | 370 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | "module" => $module, |
383 | 383 | )); |
384 | 384 | return $this->writeTemplateToFile($index, |
385 | - $modPath . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
385 | + $modPath.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
386 | 386 | $force); |
387 | 387 | } |
388 | 388 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | )); |
413 | 413 | |
414 | 414 | return $this->writeTemplateToFile($controller, |
415 | - $modPath . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
415 | + $modPath.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | "package" => $package, |
438 | 438 | )); |
439 | 439 | |
440 | - return $this->writeTemplateToFile($controller, $modPath . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
440 | + return $this->writeTemplateToFile($controller, $modPath.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -454,9 +454,9 @@ discard block |
||
454 | 454 | $base = $dir->path; |
455 | 455 | while ($file = $dir->read()) { |
456 | 456 | if (!in_array(strtolower($file), ['.', '..', 'base', 'map'])) { |
457 | - if (is_dir($base . DIRECTORY_SEPARATOR . $file)) { |
|
458 | - $this->generateApiFiles($module, $force, $apiClass, dir($base . DIRECTORY_SEPARATOR . $file), $apiPath . DIRECTORY_SEPARATOR . $file, $file); |
|
459 | - } else if (!preg_match('/Query\.php$/i', $file) |
|
457 | + if (is_dir($base.DIRECTORY_SEPARATOR.$file)) { |
|
458 | + $this->generateApiFiles($module, $force, $apiClass, dir($base.DIRECTORY_SEPARATOR.$file), $apiPath.DIRECTORY_SEPARATOR.$file, $file); |
|
459 | + }else if (!preg_match('/Query\.php$/i', $file) |
|
460 | 460 | && !preg_match('/I18n\.php$/i', $file) |
461 | 461 | && preg_match('/\.php$/i', $file) |
462 | 462 | ) { |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $parts[] = $package; |
486 | 486 | } |
487 | 487 | $parts[] = $filename; |
488 | - $namespace = '\\' . implode('\\', $parts); |
|
488 | + $namespace = '\\'.implode('\\', $parts); |
|
489 | 489 | $reflectorClass = new \ReflectionClass($namespace); |
490 | 490 | $isModel = $reflectorClass->isInstantiable(); |
491 | 491 | return $isModel; |
@@ -26,9 +26,10 @@ |
||
26 | 26 | function getallheaders(): array |
27 | 27 | { |
28 | 28 | $headers = []; |
29 | - foreach ($_SERVER as $h => $v) |
|
30 | - if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
29 | + foreach ($_SERVER as $h => $v) { |
|
30 | + if (preg_match('/HTTP_(.+)/', $h, $hp)) { |
|
31 | 31 | $headers[$hp[1]] = $v; |
32 | + } |
|
32 | 33 | } |
33 | 34 | return $headers; |
34 | 35 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | private function getPropelPaths(string $modulePath): array |
25 | 25 | { |
26 | - $moduleDir = CORE_DIR . DIRECTORY_SEPARATOR . $modulePath; |
|
26 | + $moduleDir = CORE_DIR.DIRECTORY_SEPARATOR.$modulePath; |
|
27 | 27 | GeneratorHelper::createDir($moduleDir); |
28 | 28 | $moduleDir = realpath($moduleDir); |
29 | - $configDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config'; |
|
30 | - $sqlDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Sql'; |
|
31 | - $migrationDir = $moduleDir . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'Migrations'; |
|
29 | + $configDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'; |
|
30 | + $sqlDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Sql'; |
|
31 | + $migrationDir = $moduleDir.DIRECTORY_SEPARATOR.'Config'.DIRECTORY_SEPARATOR.'Migrations'; |
|
32 | 32 | return [ |
33 | 33 | 'projectDir' => $moduleDir, |
34 | 34 | 'outputDir' => $moduleDir, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | * @param AbstractManager $manager |
90 | 90 | * @param string $workingDir |
91 | 91 | */ |
92 | - private function setupManager(GeneratorConfig $configGenerator, AbstractManager &$manager, string $workingDir = CORE_DIR): void |
|
92 | + private function setupManager(GeneratorConfig $configGenerator, AbstractManager & $manager, string $workingDir = CORE_DIR): void |
|
93 | 93 | { |
94 | 94 | $manager->setGeneratorConfig($configGenerator); |
95 | - $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'] . DIRECTORY_SEPARATOR . 'schema.xml'); |
|
95 | + $schemaFile = new \SplFileInfo($configGenerator->getSection('paths')['schemaDir'].DIRECTORY_SEPARATOR.'schema.xml'); |
|
96 | 96 | $manager->setSchemas([$schemaFile]); |
97 | - $manager->setLoggerClosure(function ($message) { |
|
97 | + $manager->setLoggerClosure(function($message) { |
|
98 | 98 | Logger::log($message, LOG_INFO); |
99 | 99 | }); |
100 | 100 | $manager->setWorkingDirectory($workingDir); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return array List of schema files |
110 | 110 | */ |
111 | - protected function getSchemas(array|string $directory, bool $recursive = false): array |
|
111 | + protected function getSchemas(array | string $directory, bool $recursive = false): array |
|
112 | 112 | { |
113 | 113 | $finder = new Finder(); |
114 | 114 | $finder |
@@ -21,7 +21,7 @@ discard block |
||
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; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getProtocol(): string |
62 | 62 | { |
63 | - if(Config::getParam('force.https', false)) { |
|
63 | + if (Config::getParam('force.https', false)) { |
|
64 | 64 | return 'https://'; |
65 | 65 | } |
66 | 66 | return ($this->getServer('HTTPS') || $this->getServer('https')) ? 'https://' : 'http://'; |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | { |
25 | 25 | Inspector::stats('[RouterHelper] Getting class to call for executing the request action', Inspector::SCOPE_DEBUG); |
26 | 26 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
27 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
27 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
28 | 28 | $reflectionClass = new ReflectionClass($actionClass); |
29 | 29 | if ($reflectionClass->hasMethod('getInstance')) { |
30 | 30 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
31 | - } else { |
|
31 | + }else { |
|
32 | 32 | $class = new $actionClass; |
33 | 33 | } |
34 | 34 | return $class; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $expr = preg_quote($expr, '/'); |
128 | 128 | $expr = str_replace('%%%', '(.*)', $expr); |
129 | 129 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
130 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
130 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
131 | 131 | return $matched; |
132 | 132 | } |
133 | 133 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public static function extractDomainInfo(ReflectionClass $class, string $domain): array |
140 | 140 | { |
141 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
141 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
142 | 142 | $templatesPath = 'templates'; |
143 | 143 | $publicPath = 'public'; |
144 | 144 | $modelsPath = 'models'; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $modelsPath = ucfirst($modelsPath); |
149 | 149 | } |
150 | 150 | if ($class->hasConstant('TPL')) { |
151 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
151 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
152 | 152 | } |
153 | 153 | return [ |
154 | 154 | 'base' => $path, |
155 | - 'template' => $path . $templatesPath, |
|
156 | - 'model' => $path . $modelsPath, |
|
157 | - 'public' => $path . $publicPath, |
|
155 | + 'template' => $path.$templatesPath, |
|
156 | + 'model' => $path.$modelsPath, |
|
157 | + 'public' => $path.$publicPath, |
|
158 | 158 | ]; |
159 | 159 | } |
160 | 160 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | foreach ($parameters as $param) { |
176 | 176 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
177 | 177 | $params[$param->getName()] = $param->getDefaultValue(); |
178 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
178 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue() ?: '', $regex ?: ''); |
|
179 | 179 | } elseif (!$param->isOptional()) { |
180 | 180 | $requirements[] = $param->getName(); |
181 | 181 | } |
182 | 182 | } |
183 | - } else { |
|
183 | + }else { |
|
184 | 184 | $default = $regex; |
185 | 185 | } |
186 | 186 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $httpMethod = AnnotationHelper::extractReflectionHttpMethod($docComments); |
211 | 211 | $icon = AnnotationHelper::extractDocIcon($docComments); |
212 | 212 | $label = AnnotationHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
213 | - $route = $httpMethod . "#|#" . $regex; |
|
213 | + $route = $httpMethod."#|#".$regex; |
|
214 | 214 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
215 | 215 | $info = [ |
216 | 216 | 'method' => $method->getName(), |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $path |
26 | 26 | * @return string|bool |
27 | 27 | */ |
28 | - public static function readFile(string $path): string|bool |
|
28 | + public static function readFile(string $path): string | bool |
|
29 | 29 | { |
30 | 30 | $data = false; |
31 | 31 | if (file_exists($path)) { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function generateHashFilename(string $verb, string $slug, array $query = []): string |
44 | 44 | { |
45 | - return sha1(strtolower($verb) . ' ' . $slug . ' ' . strtolower(http_build_query($query))); |
|
45 | + return sha1(strtolower($verb).' '.$slug.' '.strtolower(http_build_query($query))); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | { |
55 | 55 | $class = GeneratorHelper::extractClassFromNamespace($action['class']); |
56 | 56 | $filename = self::generateHashFilename($action['http'], $action['slug'], $query); |
57 | - $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2); |
|
58 | - return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR; |
|
57 | + $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2); |
|
58 | + return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |