@@ -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 | } |
@@ -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 | 'Type' => $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: |