@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $match = array(); |
47 | 47 | if (preg_match(self::REGEX_START . self::REGEX_FORMAT . self::REGEX_DEFAULT_START . $this->regex . self::REGEX_DEFAULT_END . self::REGEX_END, $definition, $match) !== 1) { |
48 | - throw new \SwaggerGen\Exception("Unparseable {$this->format} definition: '{$definition}'"); |
|
48 | + throw new \SwaggerGen\Exception("unparseable {$this->format} definition: '{$definition}'"); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if (strtolower($match[1] !== $this->format)) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $value = parent::validateDefault($value); |
62 | 62 | |
63 | 63 | if (preg_match('/' . $this->pattern . '/', $value) !== 1) { |
64 | - throw new \SwaggerGen\Exception("Invalid {$this->format} default value"); |
|
64 | + throw new \SwaggerGen\Exception("invalid {$this->format} default value"); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | return $value; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | { |
162 | 162 | if (empty($value)) { |
163 | 163 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
164 | - throw new \SwaggerGen\Exception("Empty {$type} default"); |
|
164 | + throw new \SwaggerGen\Exception("empty {$type} default"); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | if (!empty($this->enum) && !in_array($value, $this->enum)) { |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | |
171 | 171 | if ($this->maxLength !== null && mb_strlen($value) > $this->maxLength) { |
172 | 172 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
173 | - throw new \SwaggerGen\Exception("Default {$type} length beyond maximum: '{$value}'"); |
|
173 | + throw new \SwaggerGen\Exception("default {$type} length beyond maximum: '{$value}'"); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if ($this->minLength !== null && mb_strlen($value) < $this->minLength) { |
177 | 177 | $type = $this->format ?: ($this->enum ? 'enum' : 'string'); |
178 | - throw new \SwaggerGen\Exception("Default {$type} length beyond minimum: '{$value}'"); |
|
178 | + throw new \SwaggerGen\Exception("default {$type} length beyond minimum: '{$value}'"); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $value; |
@@ -175,7 +175,7 @@ |
||
175 | 175 | return new $class($parent, $definition); |
176 | 176 | } elseif (isset(self::$classTypes[$format])) { |
177 | 177 | $type = self::$classTypes[$format]; |
178 | - $class = "\\SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
178 | + $class = "\\SwaggerGen\\Swagger\\Type\\{$type}type"; |
|
179 | 179 | return new $class($parent, $definition); |
180 | 180 | } else { |
181 | 181 | return new ReferenceObjectType($parent, $definition); |
@@ -111,7 +111,7 @@ |
||
111 | 111 | $this->Type = new $class($this, $definition); |
112 | 112 | } elseif (isset(self::$classTypes[$format])) { |
113 | 113 | $type = self::$classTypes[$format]; |
114 | - $class = "\\SwaggerGen\\Swagger\\Type\\{$type}Type"; |
|
114 | + $class = "\\SwaggerGen\\Swagger\\Type\\{$type}type"; |
|
115 | 115 | $this->Type = new $class($this, $definition); |
116 | 116 | } else { |
117 | 117 | throw new \SwaggerGen\Exception("Type format not recognized: '{$format}'"); |
@@ -159,6 +159,9 @@ |
||
159 | 159 | ), parent::toArray())); |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string|null $items |
|
164 | + */ |
|
162 | 165 | private function validateItems($items) |
163 | 166 | { |
164 | 167 | if (empty($items)) { |
@@ -140,6 +140,9 @@ |
||
140 | 140 | return __CLASS__; |
141 | 141 | } |
142 | 142 | |
143 | + /** |
|
144 | + * @param string|null $value |
|
145 | + */ |
|
143 | 146 | private function validateDefault($value) |
144 | 147 | { |
145 | 148 | if (preg_match('~^-?\d+$~', $value) !== 1) { |
@@ -131,6 +131,9 @@ |
||
131 | 131 | return __CLASS__; |
132 | 132 | } |
133 | 133 | |
134 | + /** |
|
135 | + * @param string|null $value |
|
136 | + */ |
|
134 | 137 | private function validateDefault($value) |
135 | 138 | { |
136 | 139 | if (preg_match('~^-?(?:\\d*\\.?\\d+|\\d+\\.\\d*)$~', $value) !== 1) { |
@@ -16,10 +16,10 @@ |
||
16 | 16 | public function Dummy() |
17 | 17 | { |
18 | 18 | /** |
19 | - * @rest\endpoint /v1/users/{id} |
|
20 | - * @rest\method GET Return a JSON with all the user attributes |
|
21 | - * @rest\path Int id The ID of the User |
|
22 | - * @rest\response 200 User |
|
19 | + * @rest\endpoint /v1/users/{id} |
|
20 | + * @rest\method GET Return a JSON with all the user attributes |
|
21 | + * @rest\path Int id The ID of the User |
|
22 | + * @rest\response 200 User |
|
23 | 23 | */ |
24 | 24 | $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) { |
25 | 25 | // ... |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * @rest\path Int id The ID of the User |
22 | 22 | * @rest\response 200 User |
23 | 23 | */ |
24 | - $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) { |
|
24 | + $app->get('/v1/users/{id:[0-9]+}', function($request, $response, $args) { |
|
25 | 25 | // ... |
26 | 26 | }); |
27 | 27 | } |
@@ -221,41 +221,41 @@ |
||
221 | 221 | $this->assertStatement($statements[0], 'title', 'Some words'); |
222 | 222 | } |
223 | 223 | |
224 | - /** |
|
225 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | - */ |
|
227 | - public function testParse_PropertyReadOnly() |
|
228 | - { |
|
229 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | - |
|
232 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | - |
|
234 | - $this->assertCount(4, $statements); |
|
235 | - |
|
236 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | - $this->assertStatement($statements[1], 'version', '2'); |
|
238 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | - $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | - */ |
|
245 | - public function testParse_PropertyOptional() |
|
246 | - { |
|
247 | - $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | - $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | - |
|
250 | - $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | - |
|
252 | - $this->assertCount(4, $statements); |
|
253 | - |
|
254 | - $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | - $this->assertStatement($statements[1], 'version', '2'); |
|
256 | - $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | - $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | - } |
|
224 | + /** |
|
225 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
226 | + */ |
|
227 | + public function testParse_PropertyReadOnly() |
|
228 | + { |
|
229 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
230 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
231 | + |
|
232 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyReadOnly.php'); |
|
233 | + |
|
234 | + $this->assertCount(4, $statements); |
|
235 | + |
|
236 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
237 | + $this->assertStatement($statements[1], 'version', '2'); |
|
238 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
239 | + $this->assertStatement($statements[3], 'property!', 'string bar'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @covers \SwaggerGen\Parser\Php\Parser::parse |
|
244 | + */ |
|
245 | + public function testParse_PropertyOptional() |
|
246 | + { |
|
247 | + $object = new \SwaggerGen\Parser\Php\Parser(); |
|
248 | + $this->assertInstanceOf('\SwaggerGen\Parser\Php\Parser', $object); |
|
249 | + |
|
250 | + $statements = $object->parse(__DIR__ . '/ParserTest/testParse_PropertyOptional.php'); |
|
251 | + |
|
252 | + $this->assertCount(4, $statements); |
|
253 | + |
|
254 | + $this->assertStatement($statements[0], 'title', 'Some words'); |
|
255 | + $this->assertStatement($statements[1], 'version', '2'); |
|
256 | + $this->assertStatement($statements[2], 'definition', 'Foo'); |
|
257 | + $this->assertStatement($statements[3], 'property?', 'string bar'); |
|
258 | + } |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * @covers \SwaggerGen\Parser\Php\Parser::parse |