@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | $label = self::getLabel($property->getDocComment()); |
| 28 | 28 | $values = self::getValues($property->getDocComment()); |
| 29 | 29 | $isArray = (bool)preg_match('/\[\]$/', $instanceType); |
| 30 | - if($isArray) { |
|
| 30 | + if ($isArray) { |
|
| 31 | 31 | $instanceType = str_replace('[]', '', $instanceType); |
| 32 | 32 | } |
| 33 | - if($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 33 | + if ($instanceType === '\\DateTime' || !Router::exists($instanceType)) { |
|
| 34 | 34 | list($type, $format) = DocumentorHelper::translateSwaggerFormats($instanceType); |
| 35 | 35 | $variables[$property->getName()] = [ |
| 36 | 36 | 'type' => $type, |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'required' => $isRequired, |
| 39 | 39 | 'description' => $label, |
| 40 | 40 | ]; |
| 41 | - } else { |
|
| 41 | + }else { |
|
| 42 | 42 | $instance = new \ReflectionClass($instanceType); |
| 43 | 43 | $variables[$property->getName()] = [ |
| 44 | 44 | 'is_array' => $isArray, |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'properties' => self::extractVariables($instance), |
| 48 | 48 | ]; |
| 49 | 49 | } |
| 50 | - if(!empty($values)){ |
|
| 50 | + if (!empty($values)) { |
|
| 51 | 51 | $variables[$property->getName()]['enum'] = $values; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $visible = false; |
| 116 | 116 | if (false !== preg_match('/@visible\s+([^\s]+)/', $doc, $matches)) { |
| 117 | - $visible = count($matches) < 2 || 'false' !== strtolower($matches[1]); |
|
| 117 | + $visible = count($matches) < 2 || 'false' !== strtolower($matches[1]); |
|
| 118 | 118 | } |
| 119 | 119 | return $visible; |
| 120 | 120 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | // Extract description |
| 128 | 128 | $label = null; |
| 129 | 129 | preg_match('/@label\ (.*)\n/i', $doc, $matches); |
| 130 | - if(count($matches) > 1) { |
|
| 130 | + if (count($matches) > 1) { |
|
| 131 | 131 | $label = t($matches[1]); |
| 132 | 132 | } |
| 133 | 133 | return $label; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | // Extract description |
| 142 | 142 | $label = null; |
| 143 | 143 | preg_match('/@values\ (.*)\n/i', $doc, $matches); |
| 144 | - if(count($matches) > 1) { |
|
| 144 | + if (count($matches) > 1) { |
|
| 145 | 145 | $label = t($matches[1]); |
| 146 | 146 | } |
| 147 | 147 | return false !== strpos($label, '|') ? explode('|', $label) : $label; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | public static function getDefaultValue($doc) { |
| 155 | 155 | $default = null; |
| 156 | 156 | preg_match('/@default\ (.*)\n/i', $doc, $matches); |
| 157 | - if(count($matches) > 1) { |
|
| 157 | + if (count($matches) > 1) { |
|
| 158 | 158 | $default = $matches[1]; |
| 159 | 159 | } |
| 160 | 160 | return $default; |
@@ -169,13 +169,13 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public static function constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass) |
| 171 | 171 | { |
| 172 | - Logger::log('Create inyectable instance for ' . $classNameSpace); |
|
| 172 | + Logger::log('Create inyectable instance for '.$classNameSpace); |
|
| 173 | 173 | $reflector = new \ReflectionClass($calledClass); |
| 174 | 174 | $property = $reflector->getProperty($variable); |
| 175 | 175 | $varInstanceType = (null === $classNameSpace) ? InjectorHelper::extractVarType($property->getDocComment()) : $classNameSpace; |
| 176 | 176 | if (true === $singleton && method_exists($varInstanceType, 'getInstance')) { |
| 177 | 177 | $instance = $varInstanceType::getInstance(); |
| 178 | - } else { |
|
| 178 | + }else { |
|
| 179 | 179 | $instance = new $varInstanceType(); |
| 180 | 180 | } |
| 181 | 181 | return $instance; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public static function getClassProperties($class) |
| 190 | 190 | { |
| 191 | 191 | $properties = []; |
| 192 | - Logger::log('Extracting annotations properties from class ' . $class); |
|
| 192 | + Logger::log('Extracting annotations properties from class '.$class); |
|
| 193 | 193 | $selfReflector = new \ReflectionClass($class); |
| 194 | 194 | if (false !== $selfReflector->getParentClass()) { |
| 195 | 195 | $properties = self::getClassProperties($selfReflector->getParentClass()->getName()); |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | private static function searchPayloadParam($params, $variable) { |
| 16 | 16 | $exists = false; |
| 17 | - if(null !== $params && count($params)) { |
|
| 18 | - foreach($params as $param) { |
|
| 19 | - if($param['name'] === $variable) { |
|
| 17 | + if (null !== $params && count($params)) { |
|
| 18 | + foreach ($params as $param) { |
|
| 19 | + if ($param['name'] === $variable) { |
|
| 20 | 20 | $exists = true; |
| 21 | 21 | break; |
| 22 | 22 | } |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | ]; |
| 41 | 41 | if ($endpoint['payload']['is_array']) { |
| 42 | 42 | $schema['items'] = [ |
| 43 | - '$ref' => '#/definitions/' . $endpoint['payload']['type'], |
|
| 43 | + '$ref' => '#/definitions/'.$endpoint['payload']['type'], |
|
| 44 | 44 | ]; |
| 45 | - } else { |
|
| 46 | - $schema['$ref'] = '#/definitions/' . $endpoint['payload']['type']; |
|
| 45 | + }else { |
|
| 46 | + $schema['$ref'] = '#/definitions/'.$endpoint['payload']['type']; |
|
| 47 | 47 | } |
| 48 | - if(!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) { |
|
| 48 | + if (!self::searchPayloadParam($paths[$url][$method]['parameters'], $endpoint['payload']['type'])) { |
|
| 49 | 49 | $paths[$url][$method]['parameters'][] = [ |
| 50 | 50 | 'in' => 'body', |
| 51 | 51 | 'name' => $endpoint['payload']['type'], |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
| 75 | 75 | $classDefinition = [ |
| 76 | 76 | 'type' => 'object', |
| 77 | - '$ref' => '#/definitions/' . $class, |
|
| 77 | + '$ref' => '#/definitions/'.$class, |
|
| 78 | 78 | ]; |
| 79 | - } else { |
|
| 79 | + }else { |
|
| 80 | 80 | $classDefinition = [ |
| 81 | 81 | 'type' => 'array', |
| 82 | 82 | 'items' => [ |
| 83 | - '$ref' => '#/definitions/' . $class, |
|
| 83 | + '$ref' => '#/definitions/'.$class, |
|
| 84 | 84 | ], |
| 85 | 85 | ]; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') { |
|
| 88 | + if ($paths[$url][$method]['responses'][200]['schema']['properties']['data']['type'] === 'boolean') { |
|
| 89 | 89 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; |
| 90 | 90 | } |
| 91 | 91 | $dtos += self::extractSwaggerDefinition($class, $object); |
@@ -163,18 +163,18 @@ discard block |
||
| 163 | 163 | ], |
| 164 | 164 | ]; |
| 165 | 165 | foreach ($fields as $field => $info) { |
| 166 | - if(array_key_exists('type', $info) && in_array($info['type'], ['array', 'object'])) { |
|
| 166 | + if (array_key_exists('type', $info) && in_array($info['type'], ['array', 'object'])) { |
|
| 167 | 167 | $definition[$name]['properties'][$field] = $info; |
| 168 | - } elseif(array_key_exists('type', $info)) { |
|
| 168 | + } elseif (array_key_exists('type', $info)) { |
|
| 169 | 169 | list($type, $format) = self::translateSwaggerFormats($info['type']); |
| 170 | 170 | $fieldData = [ |
| 171 | 171 | "type" => $type, |
| 172 | 172 | "required" => $info['required'], |
| 173 | 173 | ]; |
| 174 | - if(array_key_exists('description', $info)) { |
|
| 174 | + if (array_key_exists('description', $info)) { |
|
| 175 | 175 | $fieldData['description'] = $info['description']; |
| 176 | 176 | } |
| 177 | - if(array_key_exists('format', $info)) { |
|
| 177 | + if (array_key_exists('format', $info)) { |
|
| 178 | 178 | $fieldData['format'] = $info['format']; |
| 179 | 179 | } |
| 180 | 180 | $dto['properties'][$field] = $fieldData; |