@@ -15,55 +15,55 @@ |
||
15 | 15 | class TypeRegistry |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Map of format-name => class-name |
|
20 | - * |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - private $formats = array(); |
|
18 | + /** |
|
19 | + * Map of format-name => class-name |
|
20 | + * |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + private $formats = array(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Add a type name from classname |
|
27 | - * |
|
28 | - * @param string $classname |
|
29 | - */ |
|
30 | - public function add(string $classname): void |
|
31 | - { |
|
32 | - if (is_subclass_of($classname, ICustomType::class)) { |
|
33 | - foreach ($classname::getFormats() as $format) { |
|
34 | - $this->formats[$format] = $classname; |
|
35 | - } |
|
36 | - } |
|
37 | - } |
|
25 | + /** |
|
26 | + * Add a type name from classname |
|
27 | + * |
|
28 | + * @param string $classname |
|
29 | + */ |
|
30 | + public function add(string $classname): void |
|
31 | + { |
|
32 | + if (is_subclass_of($classname, ICustomType::class)) { |
|
33 | + foreach ($classname::getFormats() as $format) { |
|
34 | + $this->formats[$format] = $classname; |
|
35 | + } |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Remove type format by explicitly nulling it (disables it) |
|
41 | - * |
|
42 | - * @param string $name |
|
43 | - */ |
|
44 | - public function remove($name) |
|
45 | - { |
|
46 | - $this->formats[$name] = null; |
|
47 | - } |
|
39 | + /** |
|
40 | + * Remove type format by explicitly nulling it (disables it) |
|
41 | + * |
|
42 | + * @param string $name |
|
43 | + */ |
|
44 | + public function remove($name) |
|
45 | + { |
|
46 | + $this->formats[$name] = null; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Is a type format known? |
|
51 | - * |
|
52 | - * @return bool |
|
53 | - */ |
|
54 | - public function has($name) |
|
55 | - { |
|
56 | - return !empty($this->formats[$name]); |
|
57 | - } |
|
49 | + /** |
|
50 | + * Is a type format known? |
|
51 | + * |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | + public function has($name) |
|
55 | + { |
|
56 | + return !empty($this->formats[$name]); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get the format class name |
|
61 | - * |
|
62 | - * @return null|string |
|
63 | - */ |
|
64 | - public function get($name) |
|
65 | - { |
|
66 | - return !empty($this->formats[$name]) ? $this->formats[$name] : null; |
|
67 | - } |
|
59 | + /** |
|
60 | + * Get the format class name |
|
61 | + * |
|
62 | + * @return null|string |
|
63 | + */ |
|
64 | + public function get($name) |
|
65 | + { |
|
66 | + return !empty($this->formats[$name]) ? $this->formats[$name] : null; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @copyright 2014-2017 Martijn van der Lee |
13 | 13 | * @license https://opensource.org/licenses/MIT MIT |
14 | 14 | */ |
15 | -class TypeRegistry |
|
16 | -{ |
|
15 | +class TypeRegistry |
|
16 | +{ |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Map of format-name => class-name |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function add(string $classname): void |
31 | 31 | { |
32 | - if (is_subclass_of($classname, ICustomType::class)) { |
|
33 | - foreach ($classname::getFormats() as $format) { |
|
32 | + if (is_subclass_of($classname, ICustomType::class)) { |
|
33 | + foreach ($classname::getFormats() as $format) { |
|
34 | 34 | $this->formats[$format] = $classname; |
35 | 35 | } |
36 | 36 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param string $name |
43 | 43 | */ |
44 | - public function remove($name) |
|
45 | - { |
|
44 | + public function remove($name) |
|
45 | + { |
|
46 | 46 | $this->formats[$name] = null; |
47 | 47 | } |
48 | 48 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return bool |
53 | 53 | */ |
54 | - public function has($name) |
|
55 | - { |
|
54 | + public function has($name) |
|
55 | + { |
|
56 | 56 | return !empty($this->formats[$name]); |
57 | 57 | } |
58 | 58 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return null|string |
63 | 63 | */ |
64 | - public function get($name) |
|
65 | - { |
|
64 | + public function get($name) |
|
65 | + { |
|
66 | 66 | return !empty($this->formats[$name]) ? $this->formats[$name] : null; |
67 | 67 | } |
68 | 68 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | class Base_PHPUnit7 extends PHPUnit\Framework\TestCase |
4 | 4 | { |
5 | - public function expectException(string $exception, string $message = ''): void |
|
6 | - { |
|
7 | - parent::expectException($exception); |
|
8 | - if ($message !== '') { |
|
9 | - parent::expectExceptionMessage($message); |
|
10 | - } |
|
11 | - } |
|
5 | + public function expectException(string $exception, string $message = ''): void |
|
6 | + { |
|
7 | + parent::expectException($exception); |
|
8 | + if ($message !== '') { |
|
9 | + parent::expectExceptionMessage($message); |
|
10 | + } |
|
11 | + } |
|
12 | 12 | } |
@@ -2,13 +2,13 @@ |
||
2 | 2 | |
3 | 3 | class Base_PHPUnit5 extends PHPUnit_Framework_TestCase |
4 | 4 | { |
5 | - /** |
|
6 | - * @param string $exception |
|
7 | - * @param string $message |
|
8 | - * @return void |
|
9 | - */ |
|
10 | - public function expectException($exception, $message = '') |
|
11 | - { |
|
12 | - parent::setExpectedException($exception, $message); |
|
13 | - } |
|
5 | + /** |
|
6 | + * @param string $exception |
|
7 | + * @param string $message |
|
8 | + * @return void |
|
9 | + */ |
|
10 | + public function expectException($exception, $message = '') |
|
11 | + { |
|
12 | + parent::setExpectedException($exception, $message); |
|
13 | + } |
|
14 | 14 | } |
@@ -2,16 +2,16 @@ |
||
2 | 2 | |
3 | 3 | class Base_PHPUnit6 extends PHPUnit\Framework\TestCase |
4 | 4 | { |
5 | - /** |
|
6 | - * @param string $exception |
|
7 | - * @param string $message |
|
8 | - * @return void |
|
9 | - */ |
|
10 | - public function expectException($exception, $message = '') |
|
11 | - { |
|
12 | - parent::expectException($exception); |
|
13 | - if ($message !== '') { |
|
14 | - parent::expectExceptionMessage($message); |
|
15 | - } |
|
16 | - } |
|
5 | + /** |
|
6 | + * @param string $exception |
|
7 | + * @param string $message |
|
8 | + * @return void |
|
9 | + */ |
|
10 | + public function expectException($exception, $message = '') |
|
11 | + { |
|
12 | + parent::expectException($exception); |
|
13 | + if ($message !== '') { |
|
14 | + parent::expectExceptionMessage($message); |
|
15 | + } |
|
16 | + } |
|
17 | 17 | } |
@@ -3,29 +3,29 @@ |
||
3 | 3 | class StatementTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Statement::__construct |
|
8 | - */ |
|
9 | - public function testConstructor() |
|
10 | - { |
|
11 | - $object = new \SwaggerGen\Statement('command', 'some data'); |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Statement::__construct |
|
8 | + */ |
|
9 | + public function testConstructor() |
|
10 | + { |
|
11 | + $object = new \SwaggerGen\Statement('command', 'some data'); |
|
12 | 12 | |
13 | - $this->assertInstanceOf('\SwaggerGen\Statement', $object); |
|
14 | - $this->assertSame('command', $object->getCommand()); |
|
15 | - $this->assertSame('some data', $object->getData()); |
|
16 | - } |
|
13 | + $this->assertInstanceOf('\SwaggerGen\Statement', $object); |
|
14 | + $this->assertSame('command', $object->getCommand()); |
|
15 | + $this->assertSame('some data', $object->getData()); |
|
16 | + } |
|
17 | 17 | |
18 | - /** |
|
19 | - * @covers \SwaggerGen\Statement::__construct |
|
20 | - */ |
|
21 | - public function testConstructor_File() |
|
22 | - { |
|
23 | - $object = new \SwaggerGen\Statement('command', 'some data', 'file', 123); |
|
24 | - $this->assertInstanceOf('\SwaggerGen\Statement', $object); |
|
18 | + /** |
|
19 | + * @covers \SwaggerGen\Statement::__construct |
|
20 | + */ |
|
21 | + public function testConstructor_File() |
|
22 | + { |
|
23 | + $object = new \SwaggerGen\Statement('command', 'some data', 'file', 123); |
|
24 | + $this->assertInstanceOf('\SwaggerGen\Statement', $object); |
|
25 | 25 | |
26 | - $this->assertSame('command', $object->getCommand()); |
|
27 | - $this->assertSame('some data', $object->getData()); |
|
28 | - $this->assertSame('file', $object->getFile()); |
|
29 | - $this->assertSame(123, $object->getLine()); |
|
30 | - } |
|
26 | + $this->assertSame('command', $object->getCommand()); |
|
27 | + $this->assertSame('some data', $object->getData()); |
|
28 | + $this->assertSame('file', $object->getFile()); |
|
29 | + $this->assertSame(123, $object->getLine()); |
|
30 | + } |
|
31 | 31 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | spl_autoload_register(function ($classname) { |
4 | - $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php'; |
|
5 | - if (is_file($file)) { |
|
6 | - require_once $file; |
|
7 | - } |
|
4 | + $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php'; |
|
5 | + if (is_file($file)) { |
|
6 | + require_once $file; |
|
7 | + } |
|
8 | 8 | }); |
9 | 9 | |
10 | 10 | |
@@ -16,20 +16,20 @@ discard block |
||
16 | 16 | // inbetween there was `expectException()` without type hint |
17 | 17 | |
18 | 18 | if (class_exists('PHPUnit\Runner\Version')) { |
19 | - $version = PHPUnit\Runner\Version::id(); |
|
19 | + $version = PHPUnit\Runner\Version::id(); |
|
20 | 20 | } else if (class_exists('PHPUnit_Runner_Version')) { |
21 | - $version = PHPUnit_Runner_Version::id(); |
|
21 | + $version = PHPUnit_Runner_Version::id(); |
|
22 | 22 | } else { |
23 | - throw new Exception('Cannot detect PHPUnit version'); |
|
23 | + throw new Exception('Cannot detect PHPUnit version'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | if (version_compare($version, '7.0.0', '>=')) { |
27 | - require dirname(__FILE__) . '/Base/PHPUnit7.php'; |
|
28 | - class_alias('Base_PHPUnit7', 'SwaggerGen_TestCase'); |
|
27 | + require dirname(__FILE__) . '/Base/PHPUnit7.php'; |
|
28 | + class_alias('Base_PHPUnit7', 'SwaggerGen_TestCase'); |
|
29 | 29 | } else if (version_compare($version, '6.0.0', '>=')) { |
30 | - require dirname(__FILE__) . '/Base/PHPUnit6.php'; |
|
31 | - class_alias('Base_PHPUnit6', 'SwaggerGen_TestCase'); |
|
30 | + require dirname(__FILE__) . '/Base/PHPUnit6.php'; |
|
31 | + class_alias('Base_PHPUnit6', 'SwaggerGen_TestCase'); |
|
32 | 32 | } else { |
33 | - require dirname(__FILE__) . '/Base/PHPUnit5.php'; |
|
34 | - class_alias('Base_PHPUnit5', 'SwaggerGen_TestCase'); |
|
33 | + require dirname(__FILE__) . '/Base/PHPUnit5.php'; |
|
34 | + class_alias('Base_PHPUnit5', 'SwaggerGen_TestCase'); |
|
35 | 35 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -spl_autoload_register(function ($classname) { |
|
3 | +spl_autoload_register(function($classname) { |
|
4 | 4 | $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $classname) . '.php'; |
5 | 5 | if (is_file($file)) { |
6 | 6 | require_once $file; |
@@ -3,57 +3,57 @@ |
||
3 | 3 | class OutputTest extends SwaggerGen_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * @covers \SwaggerGen\Exception::__construct |
|
8 | - * @dataProvider provideAllCases |
|
9 | - */ |
|
10 | - public function testAllCases($name, $files, $expected) |
|
11 | - { |
|
12 | - $SwaggerGen = new \SwaggerGen\SwaggerGen('example.com', '/base'); |
|
13 | - $actual = $SwaggerGen->getSwagger($files, array(), \SwaggerGen\SwaggerGen::FORMAT_JSON); |
|
14 | - $this->assertJsonStringEqualsJsonString($expected, $this->normalizeJson($actual), $name); |
|
15 | - } |
|
16 | - |
|
17 | - /** |
|
18 | - * Normalizes and pretty-prints json (whitespace mostly) |
|
19 | - * |
|
20 | - * This is useful to get better diff results when assertions fail. |
|
21 | - * |
|
22 | - * @param string $json |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - private function normalizeJson($json) |
|
26 | - { |
|
27 | - return json_encode( |
|
28 | - json_decode($json), |
|
29 | - PHP_VERSION_ID >= 50400 ? constant('JSON_PRETTY_PRINT') : 0 |
|
30 | - ); |
|
31 | - } |
|
32 | - |
|
33 | - public function provideAllCases() |
|
34 | - { |
|
35 | - $cases = array(); |
|
36 | - |
|
37 | - foreach (glob(__DIR__ . '/*', GLOB_ONLYDIR) as $dir) { |
|
38 | - $path = realpath($dir); |
|
39 | - $json = $this->normalizeJson(file_get_contents($path . '/expected.json')); |
|
40 | - |
|
41 | - $files = array(); |
|
42 | - if (file_exists($path . '/source.php')) { |
|
43 | - $files[] = $path . '/source.php'; |
|
44 | - } |
|
45 | - if (file_exists($path . '/source.txt')) { |
|
46 | - $files[] = $path . '/source.txt'; |
|
47 | - } |
|
48 | - |
|
49 | - $cases[] = array( |
|
50 | - basename($dir), |
|
51 | - $files, |
|
52 | - $json |
|
53 | - ); |
|
54 | - } |
|
55 | - |
|
56 | - return $cases; |
|
57 | - } |
|
6 | + /** |
|
7 | + * @covers \SwaggerGen\Exception::__construct |
|
8 | + * @dataProvider provideAllCases |
|
9 | + */ |
|
10 | + public function testAllCases($name, $files, $expected) |
|
11 | + { |
|
12 | + $SwaggerGen = new \SwaggerGen\SwaggerGen('example.com', '/base'); |
|
13 | + $actual = $SwaggerGen->getSwagger($files, array(), \SwaggerGen\SwaggerGen::FORMAT_JSON); |
|
14 | + $this->assertJsonStringEqualsJsonString($expected, $this->normalizeJson($actual), $name); |
|
15 | + } |
|
16 | + |
|
17 | + /** |
|
18 | + * Normalizes and pretty-prints json (whitespace mostly) |
|
19 | + * |
|
20 | + * This is useful to get better diff results when assertions fail. |
|
21 | + * |
|
22 | + * @param string $json |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + private function normalizeJson($json) |
|
26 | + { |
|
27 | + return json_encode( |
|
28 | + json_decode($json), |
|
29 | + PHP_VERSION_ID >= 50400 ? constant('JSON_PRETTY_PRINT') : 0 |
|
30 | + ); |
|
31 | + } |
|
32 | + |
|
33 | + public function provideAllCases() |
|
34 | + { |
|
35 | + $cases = array(); |
|
36 | + |
|
37 | + foreach (glob(__DIR__ . '/*', GLOB_ONLYDIR) as $dir) { |
|
38 | + $path = realpath($dir); |
|
39 | + $json = $this->normalizeJson(file_get_contents($path . '/expected.json')); |
|
40 | + |
|
41 | + $files = array(); |
|
42 | + if (file_exists($path . '/source.php')) { |
|
43 | + $files[] = $path . '/source.php'; |
|
44 | + } |
|
45 | + if (file_exists($path . '/source.txt')) { |
|
46 | + $files[] = $path . '/source.txt'; |
|
47 | + } |
|
48 | + |
|
49 | + $cases[] = array( |
|
50 | + basename($dir), |
|
51 | + $files, |
|
52 | + $json |
|
53 | + ); |
|
54 | + } |
|
55 | + |
|
56 | + return $cases; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | } |
@@ -13,14 +13,14 @@ |
||
13 | 13 | class Example |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @rest\endpoint /endpoint |
|
18 | - * @rest\method GET Something |
|
19 | - * @rest\response 200 uuid |
|
20 | - */ |
|
21 | - public function Dummy() |
|
22 | - { |
|
16 | + /** |
|
17 | + * @rest\endpoint /endpoint |
|
18 | + * @rest\method GET Something |
|
19 | + * @rest\response 200 uuid |
|
20 | + */ |
|
21 | + public function Dummy() |
|
22 | + { |
|
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
@@ -11,15 +11,15 @@ |
||
11 | 11 | class Example |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @rest\endpoint /endpoint/{listid} |
|
16 | - * @rest\method GET Something |
|
17 | - * @rest\param listid |
|
18 | - * @rest\response 200 |
|
19 | - */ |
|
20 | - public function Dummy() |
|
21 | - { |
|
14 | + /** |
|
15 | + * @rest\endpoint /endpoint/{listid} |
|
16 | + * @rest\method GET Something |
|
17 | + * @rest\param listid |
|
18 | + * @rest\response 200 |
|
19 | + */ |
|
20 | + public function Dummy() |
|
21 | + { |
|
22 | 22 | |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | 25 | } |