@@ -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 | } |
@@ -122,27 +122,27 @@ discard block |
||
122 | 122 | $behaviors = $tableMap->getBehaviors(); |
123 | 123 | foreach ($map::getFieldNames() as $field) { |
124 | 124 | $fDto = self::parseFormField($domain, $tableMap, $field, $behaviors); |
125 | - if(null !== $fDto) { |
|
125 | + if (null !== $fDto) { |
|
126 | 126 | $form->addField($fDto); |
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - if(array_key_exists('i18n', $behaviors)) { |
|
131 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
132 | - if(null !== $relateI18n) { |
|
130 | + if (array_key_exists('i18n', $behaviors)) { |
|
131 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
132 | + if (null !== $relateI18n) { |
|
133 | 133 | $i18NTableMap = $relateI18n->getLocalTable(); |
134 | - foreach($i18NTableMap->getColumns() as $columnMap) { |
|
134 | + foreach ($i18NTableMap->getColumns() as $columnMap) { |
|
135 | 135 | $columnName = self::getColumnMapName($columnMap); |
136 | - if(!$form->fieldExists($columnName)) { |
|
136 | + if (!$form->fieldExists($columnName)) { |
|
137 | 137 | /** @var Field $fDto */ |
138 | 138 | $fDto = self::parseFormField($domain, $i18NTableMap, $columnMap->getPhpName(), $i18NTableMap->getBehaviors()); |
139 | - if(null !== $fDto) { |
|
139 | + if (null !== $fDto) { |
|
140 | 140 | $fDto->pk = false; |
141 | 141 | $fDto->required = true; |
142 | - if(strtolower($fDto->name) === 'locale') { |
|
142 | + if (strtolower($fDto->name) === 'locale') { |
|
143 | 143 | $fDto->type = Field::COMBO_TYPE; |
144 | 144 | $languages = explode(',', Config::getParam('i18n.locales', Config::getParam('default.language', 'es_ES'))); |
145 | - foreach($languages as $language) { |
|
145 | + foreach ($languages as $language) { |
|
146 | 146 | $fDto->data[] = [ |
147 | 147 | $fDto->name => $language, |
148 | 148 | 'Label' => t($language), |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | { |
170 | 170 | $column = null; |
171 | 171 | try { |
172 | - foreach($tableMap->getColumns() as $tableMapColumn) { |
|
172 | + foreach ($tableMap->getColumns() as $tableMapColumn) { |
|
173 | 173 | $columnName = $tableMapColumn->getPhpName(); |
174 | - if(preg_match('/^'.$field.'$/i', $columnName)) { |
|
174 | + if (preg_match('/^'.$field.'$/i', $columnName)) { |
|
175 | 175 | $column = $tableMapColumn; |
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
179 | - } catch (\Exception $e) { |
|
179 | + }catch (\Exception $e) { |
|
180 | 180 | Logger::log($e->getMessage(), LOG_DEBUG); |
181 | 181 | } |
182 | 182 | return $column; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public static function getFieldTypes() { |
189 | 189 | $configType = Config::getParam('api.field.case', TableMap::TYPE_PHPNAME); |
190 | - switch($configType) { |
|
190 | + switch ($configType) { |
|
191 | 191 | default: |
192 | 192 | case 'UpperCamelCase': |
193 | 193 | case TableMap::TYPE_PHPNAME: |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | //Generating the templates translations |
45 | 45 | $translations = $this->tpl->regenerateTemplates(); |
46 | 46 | |
47 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
48 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
47 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
48 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
49 | 49 | |
50 | 50 | //xgettext localizations |
51 | 51 | $translations = array_merge($translations, I18nHelper::findTranslations(SOURCE_DIR, $locale)); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $translations = array_merge($translations, I18nHelper::findTranslations(CACHE_DIR, $locale)); |
54 | 54 | |
55 | 55 | $translations[] = "msgfmt {$localePath}translations.po -o {$localePath}translations.mo"; |
56 | - $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '. $localePath . 'translations.po -o ' . $localePath . 'translations.mo'); |
|
56 | + $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '.$localePath.'translations.po -o '.$localePath.'translations.mo'); |
|
57 | 57 | return $this->render('translations.html.twig', array( |
58 | 58 | 'translations' => $translations, |
59 | 59 | )); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | // Creates the src folder |
25 | 25 | GeneratorHelper::createDir($modPath); |
26 | 26 | // Create module path |
27 | - GeneratorHelper::createDir($modPath . $module); |
|
27 | + GeneratorHelper::createDir($modPath.$module); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | Logger::log("Generamos la estructura"); |
41 | 41 | $paths = [ |
42 | 42 | "Api", "Config", "Controller", "Models", "Public", "Templates", "Services", "Test", "Doc", |
43 | - "Locale", "Locale/" . Config::getParam('default.locale', 'es_ES'), "Locale/" . Config::getParam('default.locale', 'es_ES') . "/LC_MESSAGES" |
|
43 | + "Locale", "Locale/".Config::getParam('default.locale', 'es_ES'), "Locale/".Config::getParam('default.locale', 'es_ES')."/LC_MESSAGES" |
|
44 | 44 | ]; |
45 | - $modulePath = $modPath . $module; |
|
45 | + $modulePath = $modPath.$module; |
|
46 | 46 | foreach ($paths as $path) { |
47 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . $path); |
|
47 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR.$path); |
|
48 | 48 | } |
49 | 49 | //Creamos las carpetas de los assets |
50 | 50 | $htmlPaths = array("css", "js", "img", "media", "font"); |
51 | 51 | foreach ($htmlPaths as $path) { |
52 | - GeneratorHelper::createDir($modulePath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
52 | + GeneratorHelper::createDir($modulePath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | //Generamos el fichero de configuración |
65 | 65 | Logger::log("Generamos ficheros para assets base"); |
66 | 66 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
67 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
67 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
68 | 68 | $force); |
69 | 69 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
70 | - $modPath . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
70 | + $modPath.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
71 | 71 | $force); |
72 | 72 | return ($css && $js); |
73 | 73 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | "class" => $class, |
90 | 90 | )); |
91 | 91 | return $this->writeTemplateToFile($controller, |
92 | - $modPath . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
92 | + $modPath.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
93 | 93 | $force); |
94 | 94 | } |
95 | 95 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | "autoloader" => preg_replace('/(\\\|\/)/', '_', $module), |
109 | 109 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
110 | 110 | )); |
111 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
111 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
112 | 112 | |
113 | 113 | Logger::log("Generamos el phpunit"); |
114 | 114 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
115 | 115 | "module" => $module, |
116 | 116 | )); |
117 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
117 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
118 | 118 | return $autoload && $phpunit; |
119 | 119 | } |
120 | 120 | } |
@@ -28,11 +28,11 @@ |
||
28 | 28 | try { |
29 | 29 | Cache::getInstance()->storeData($filename, $fileContent, Cache::TEXT, true); |
30 | 30 | $created = true; |
31 | - } catch (\Exception $e) { |
|
31 | + }catch (\Exception $e) { |
|
32 | 32 | Logger::log($e->getMessage(), LOG_ERR); |
33 | 33 | } |
34 | - } else { |
|
35 | - Logger::log($filename . t(' not exists or cant write'), LOG_ERR); |
|
34 | + }else { |
|
35 | + Logger::log($filename.t(' not exists or cant write'), LOG_ERR); |
|
36 | 36 | } |
37 | 37 | return $created; |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function extractApiEndpoints(array $module) |
46 | 46 | { |
47 | - $modulePath = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
47 | + $modulePath = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
48 | 48 | $moduleName = $module['name']; |
49 | 49 | $endpoints = []; |
50 | 50 | if (file_exists($modulePath)) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** @var SplFileInfo $file */ |
55 | 55 | foreach ($finder as $file) { |
56 | 56 | $filename = str_replace([$modulePath, '/'], ['', '\\'], $file->getPathname()); |
57 | - $namespace = "\\{$moduleName}\\Api" . str_replace('.php', '', $filename); |
|
57 | + $namespace = "\\{$moduleName}\\Api".str_replace('.php', '', $filename); |
|
58 | 58 | $info = $this->extractApiInfo($namespace, $moduleName); |
59 | 59 | if (!empty($info)) { |
60 | 60 | $endpoints[$namespace] = $info; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if (NULL !== $mInfo) { |
85 | 85 | $info[] = $mInfo; |
86 | 86 | } |
87 | - } catch (Exception $e) { |
|
87 | + }catch (Exception $e) { |
|
88 | 88 | Logger::log($e->getMessage(), LOG_ERR); |
89 | 89 | } |
90 | 90 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | // Gather always the base translations |
50 | 50 | $standardTranslations = []; |
51 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']); |
|
51 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']); |
|
52 | 52 | if (file_exists(self::$filename)) { |
53 | 53 | $standardTranslations = json_decode(file_get_contents(self::$filename), true); |
54 | 54 | } |
@@ -66,32 +66,32 @@ discard block |
||
66 | 66 | $session = Security::getInstance(); |
67 | 67 | self::$locale = I18nHelper::extractLocale($session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY)); |
68 | 68 | $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION); |
69 | - $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1'); |
|
69 | + $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1'); |
|
70 | 70 | if ($forceReload) { |
71 | 71 | Inspector::stats('[translationsCheckLoad] Force translations reload', Inspector::SCOPE_DEBUG); |
72 | 72 | self::dropInstance(); |
73 | 73 | $version = null; |
74 | 74 | self::$translations = []; |
75 | 75 | } |
76 | - if(count(self::$translations) === 0) { |
|
76 | + if (count(self::$translations) === 0) { |
|
77 | 77 | Inspector::stats('[translationsCheckLoad] Extracting translations', Inspector::SCOPE_DEBUG); |
78 | 78 | self::$generate = (boolean)Config::getParam('i18n.autogenerate', false); |
79 | - if(null !== $version && $version === $configVersion) { |
|
79 | + if (null !== $version && $version === $configVersion) { |
|
80 | 80 | Inspector::stats('[translationsCheckLoad] Translations loaded from session', Inspector::SCOPE_DEBUG); |
81 | 81 | self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG); |
82 | - } else { |
|
82 | + }else { |
|
83 | 83 | if (!$useBase) { |
84 | 84 | $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY); |
85 | 85 | } |
86 | 86 | $standardTranslations = self::extractBaseTranslations(); |
87 | 87 | // If the project has custom translations, gather them |
88 | 88 | if (null !== $customKey) { |
89 | - Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO); |
|
90 | - self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']); |
|
89 | + Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO); |
|
90 | + self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']); |
|
91 | 91 | } |
92 | 92 | // Finally we merge base and custom translations to complete all the i18n set |
93 | 93 | if (file_exists(self::$filename)) { |
94 | - Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO); |
|
94 | + Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO); |
|
95 | 95 | self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true)); |
96 | 96 | $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations); |
97 | 97 | $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | public function getFilters() |
118 | 118 | { |
119 | 119 | return array( |
120 | - new TwigFilter('trans', function ($message) { |
|
120 | + new TwigFilter('trans', function($message) { |
|
121 | 121 | return self::_($message); |
122 | 122 | }), |
123 | 123 | ); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public static function _($message, $customKey = null, $forceReload = false) |
141 | 141 | { |
142 | - if(0 === count(self::$translations) || $forceReload) { |
|
142 | + if (0 === count(self::$translations) || $forceReload) { |
|
143 | 143 | self::translationsCheckLoad($customKey, $forceReload); |
144 | 144 | } |
145 | 145 | if (is_array(self::$translations) && array_key_exists($message, self::$translations)) { |
146 | 146 | $translation = self::$translations[$message]; |
147 | - } else { |
|
147 | + }else { |
|
148 | 148 | $translation = gettext($message); |
149 | 149 | } |
150 | 150 | if (self::$generate) { |