Completed
Push — master ( fcb010...ba73f2 )
by Martijn
19s
created
tests/output/docblock comment in method/source.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
 class Example
14 14
 {
15 15
 
16
-    public function Dummy()
17
-    {
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
23
-         */
24
-        $app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) {
25
-            // ...
26
-        });
27
-    }
16
+	public function Dummy()
17
+	{
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
23
+		 */
24
+		$app->get('/v1/users/{id:[0-9]+}', function ($request, $response, $args) {
25
+			// ...
26
+		});
27
+	}
28 28
 
29 29
 }
Please login to merge, or discard this patch.
tests/Parser/Text/ParserTest.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -5,191 +5,191 @@
 block discarded – undo
5 5
 class ParserTest extends \SwaggerGen_TestCase
6 6
 {
7 7
 
8
-    /**
9
-     * @covers \SwaggerGen\Parser\Text\Parser::__construct
10
-     */
11
-    public function testConstructor_Empty()
12
-    {
13
-        $object = new \SwaggerGen\Parser\Text\Parser();
14
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
15
-    }
16
-
17
-    /**
18
-     * @covers \SwaggerGen\Parser\Text\Parser::__construct
19
-     */
20
-    public function testConstructor_Dirs()
21
-    {
22
-        $this->markTestIncomplete('Not yet implemented.');
23
-    }
24
-
25
-    /**
26
-     * @covers \SwaggerGen\Parser\Text\Parser::addDirs
27
-     */
28
-    public function testAddDirs()
29
-    {
30
-        $this->markTestIncomplete('Not yet implemented.');
31
-    }
32
-
33
-    /**
34
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
35
-     */
36
-    public function testParseText()
37
-    {
38
-        $object = new \SwaggerGen\Parser\Text\Parser();
39
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
40
-
41
-        $statements = $object->parseText('title Some words');
42
-
43
-        $this->assertCount(1, $statements);
44
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
45
-        $this->assertSame('title', $statements[0]->getCommand());
46
-        $this->assertSame('Some words', $statements[0]->getData());
47
-    }
48
-
49
-    /**
50
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
51
-     */
52
-    public function testParseText_Whitespace()
53
-    {
54
-        $object = new \SwaggerGen\Parser\Text\Parser();
55
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
56
-
57
-        $statements = $object->parseText(" \t title   \t\t Some words \t ");
58
-
59
-        $this->assertCount(1, $statements);
60
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
61
-        $this->assertSame('title', $statements[0]->getCommand());
62
-        $this->assertSame('Some words', $statements[0]->getData());
63
-    }
64
-
65
-    /**
66
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
67
-     */
68
-    public function testParseText_Multiple_LF()
69
-    {
70
-        $object = new \SwaggerGen\Parser\Text\Parser();
71
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
72
-
73
-        $statements = $object->parseText("title Some words\nSome Random words");
74
-
75
-        $this->assertCount(2, $statements);
76
-
77
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
78
-        $this->assertSame('title', $statements[0]->getCommand());
79
-        $this->assertSame('Some words', $statements[0]->getData());
80
-
81
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
82
-        $this->assertSame('Some', $statements[1]->getCommand());
83
-        $this->assertSame('Random words', $statements[1]->getData());
84
-    }
85
-
86
-    /**
87
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
88
-     */
89
-    public function testParseText_Multiple_CR()
90
-    {
91
-        $object = new \SwaggerGen\Parser\Text\Parser();
92
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
93
-
94
-        $statements = $object->parseText("title Some words\rSome Random words");
95
-
96
-        $this->assertCount(2, $statements);
97
-
98
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
99
-        $this->assertSame('title', $statements[0]->getCommand());
100
-        $this->assertSame('Some words', $statements[0]->getData());
101
-
102
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
103
-        $this->assertSame('Some', $statements[1]->getCommand());
104
-        $this->assertSame('Random words', $statements[1]->getData());
105
-    }
106
-
107
-    /**
108
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
109
-     */
110
-    public function testParseText_Multiple_CRLF()
111
-    {
112
-        $object = new \SwaggerGen\Parser\Text\Parser();
113
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
114
-
115
-        $statements = $object->parseText("title Some words\r\nSome Random words");
116
-
117
-        $this->assertCount(2, $statements);
118
-
119
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
120
-        $this->assertSame('title', $statements[0]->getCommand());
121
-        $this->assertSame('Some words', $statements[0]->getData());
122
-
123
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
124
-        $this->assertSame('Some', $statements[1]->getCommand());
125
-        $this->assertSame('Random words', $statements[1]->getData());
126
-    }
127
-
128
-    /**
129
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
130
-     */
131
-    public function testParseText_Multiple_BlankLines()
132
-    {
133
-        $object = new \SwaggerGen\Parser\Text\Parser();
134
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
135
-
136
-        $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words");
137
-
138
-        $this->assertCount(2, $statements);
139
-
140
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
141
-        $this->assertSame('title', $statements[0]->getCommand());
142
-        $this->assertSame('Some words', $statements[0]->getData());
143
-
144
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
145
-        $this->assertSame('Some', $statements[1]->getCommand());
146
-        $this->assertSame('Random words', $statements[1]->getData());
147
-    }
148
-
149
-    /**
150
-     * @covers \SwaggerGen\Parser\Text\Parser::parseText
151
-     */
152
-    public function testParseText_Dirs()
153
-    {
154
-        $object = new \SwaggerGen\Parser\Text\Parser();
155
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
156
-
157
-        $statements = $object->parseText("title Some words\r\n\n\n\rSome Random words", array(
158
-            __DIR__ . '/ParserTest/not used by text parser',
159
-        ));
160
-
161
-        $this->assertCount(2, $statements);
162
-
163
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
164
-        $this->assertSame('title', $statements[0]->getCommand());
165
-        $this->assertSame('Some words', $statements[0]->getData());
166
-
167
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
168
-        $this->assertSame('Some', $statements[1]->getCommand());
169
-        $this->assertSame('Random words', $statements[1]->getData());
170
-    }
171
-
172
-    /**
173
-     * @covers \SwaggerGen\Parser\Text\Parser::parse
174
-     */
175
-    public function testParse()
176
-    {
177
-        $object = new \SwaggerGen\Parser\Text\Parser();
178
-        $this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
179
-
180
-        $statements = $object->parse(__DIR__ . '/ParserTest/testParse.txt', array(
181
-            __DIR__ . '/ParserTest/not used by text parser',
182
-        ));
183
-
184
-        $this->assertCount(2, $statements);
185
-
186
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
187
-        $this->assertSame('title', $statements[0]->getCommand());
188
-        $this->assertSame('Some words', $statements[0]->getData());
189
-
190
-        $this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
191
-        $this->assertSame('Some', $statements[1]->getCommand());
192
-        $this->assertSame('Random words', $statements[1]->getData());
193
-    }
8
+	/**
9
+	 * @covers \SwaggerGen\Parser\Text\Parser::__construct
10
+	 */
11
+	public function testConstructor_Empty()
12
+	{
13
+		$object = new \SwaggerGen\Parser\Text\Parser();
14
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
15
+	}
16
+
17
+	/**
18
+	 * @covers \SwaggerGen\Parser\Text\Parser::__construct
19
+	 */
20
+	public function testConstructor_Dirs()
21
+	{
22
+		$this->markTestIncomplete('Not yet implemented.');
23
+	}
24
+
25
+	/**
26
+	 * @covers \SwaggerGen\Parser\Text\Parser::addDirs
27
+	 */
28
+	public function testAddDirs()
29
+	{
30
+		$this->markTestIncomplete('Not yet implemented.');
31
+	}
32
+
33
+	/**
34
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
35
+	 */
36
+	public function testParseText()
37
+	{
38
+		$object = new \SwaggerGen\Parser\Text\Parser();
39
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
40
+
41
+		$statements = $object->parseText('title Some words');
42
+
43
+		$this->assertCount(1, $statements);
44
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
45
+		$this->assertSame('title', $statements[0]->getCommand());
46
+		$this->assertSame('Some words', $statements[0]->getData());
47
+	}
48
+
49
+	/**
50
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
51
+	 */
52
+	public function testParseText_Whitespace()
53
+	{
54
+		$object = new \SwaggerGen\Parser\Text\Parser();
55
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
56
+
57
+		$statements = $object->parseText(" \t title   \t\t Some words \t ");
58
+
59
+		$this->assertCount(1, $statements);
60
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
61
+		$this->assertSame('title', $statements[0]->getCommand());
62
+		$this->assertSame('Some words', $statements[0]->getData());
63
+	}
64
+
65
+	/**
66
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
67
+	 */
68
+	public function testParseText_Multiple_LF()
69
+	{
70
+		$object = new \SwaggerGen\Parser\Text\Parser();
71
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
72
+
73
+		$statements = $object->parseText("title Some words\nSome Random words");
74
+
75
+		$this->assertCount(2, $statements);
76
+
77
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
78
+		$this->assertSame('title', $statements[0]->getCommand());
79
+		$this->assertSame('Some words', $statements[0]->getData());
80
+
81
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
82
+		$this->assertSame('Some', $statements[1]->getCommand());
83
+		$this->assertSame('Random words', $statements[1]->getData());
84
+	}
85
+
86
+	/**
87
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
88
+	 */
89
+	public function testParseText_Multiple_CR()
90
+	{
91
+		$object = new \SwaggerGen\Parser\Text\Parser();
92
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
93
+
94
+		$statements = $object->parseText("title Some words\rSome Random words");
95
+
96
+		$this->assertCount(2, $statements);
97
+
98
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
99
+		$this->assertSame('title', $statements[0]->getCommand());
100
+		$this->assertSame('Some words', $statements[0]->getData());
101
+
102
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
103
+		$this->assertSame('Some', $statements[1]->getCommand());
104
+		$this->assertSame('Random words', $statements[1]->getData());
105
+	}
106
+
107
+	/**
108
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
109
+	 */
110
+	public function testParseText_Multiple_CRLF()
111
+	{
112
+		$object = new \SwaggerGen\Parser\Text\Parser();
113
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
114
+
115
+		$statements = $object->parseText("title Some words\r\nSome Random words");
116
+
117
+		$this->assertCount(2, $statements);
118
+
119
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
120
+		$this->assertSame('title', $statements[0]->getCommand());
121
+		$this->assertSame('Some words', $statements[0]->getData());
122
+
123
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
124
+		$this->assertSame('Some', $statements[1]->getCommand());
125
+		$this->assertSame('Random words', $statements[1]->getData());
126
+	}
127
+
128
+	/**
129
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
130
+	 */
131
+	public function testParseText_Multiple_BlankLines()
132
+	{
133
+		$object = new \SwaggerGen\Parser\Text\Parser();
134
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
135
+
136
+		$statements = $object->parseText("title Some words\r\n\n\n\rSome Random words");
137
+
138
+		$this->assertCount(2, $statements);
139
+
140
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
141
+		$this->assertSame('title', $statements[0]->getCommand());
142
+		$this->assertSame('Some words', $statements[0]->getData());
143
+
144
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
145
+		$this->assertSame('Some', $statements[1]->getCommand());
146
+		$this->assertSame('Random words', $statements[1]->getData());
147
+	}
148
+
149
+	/**
150
+	 * @covers \SwaggerGen\Parser\Text\Parser::parseText
151
+	 */
152
+	public function testParseText_Dirs()
153
+	{
154
+		$object = new \SwaggerGen\Parser\Text\Parser();
155
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
156
+
157
+		$statements = $object->parseText("title Some words\r\n\n\n\rSome Random words", array(
158
+			__DIR__ . '/ParserTest/not used by text parser',
159
+		));
160
+
161
+		$this->assertCount(2, $statements);
162
+
163
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
164
+		$this->assertSame('title', $statements[0]->getCommand());
165
+		$this->assertSame('Some words', $statements[0]->getData());
166
+
167
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
168
+		$this->assertSame('Some', $statements[1]->getCommand());
169
+		$this->assertSame('Random words', $statements[1]->getData());
170
+	}
171
+
172
+	/**
173
+	 * @covers \SwaggerGen\Parser\Text\Parser::parse
174
+	 */
175
+	public function testParse()
176
+	{
177
+		$object = new \SwaggerGen\Parser\Text\Parser();
178
+		$this->assertInstanceOf('\SwaggerGen\Parser\Text\Parser', $object);
179
+
180
+		$statements = $object->parse(__DIR__ . '/ParserTest/testParse.txt', array(
181
+			__DIR__ . '/ParserTest/not used by text parser',
182
+		));
183
+
184
+		$this->assertCount(2, $statements);
185
+
186
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[0]);
187
+		$this->assertSame('title', $statements[0]->getCommand());
188
+		$this->assertSame('Some words', $statements[0]->getData());
189
+
190
+		$this->assertInstanceOf('\SwaggerGen\Statement', $statements[1]);
191
+		$this->assertSame('Some', $statements[1]->getCommand());
192
+		$this->assertSame('Random words', $statements[1]->getData());
193
+	}
194 194
 
195 195
 }
Please login to merge, or discard this patch.
tests/output/global response/source.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/ExternalDocumentation.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@
 block discarded – undo
14 14
 class ExternalDocumentation extends AbstractObject
15 15
 {
16 16
 
17
-    private $url;
18
-    private $description;
19
-
20
-    public function __construct(AbstractObject $parent, $url, $description = null)
21
-    {
22
-        parent::__construct($parent);
23
-        $this->url = $url;
24
-        $this->description = $description;
25
-    }
26
-
27
-    /**
28
-     * @param string $command
29
-     * @param string $data
30
-     * @return AbstractObject|boolean
31
-     */
32
-    public function handleCommand($command, $data = null)
33
-    {
34
-        switch (strtolower($command)) {
35
-            case 'url':
36
-            case 'description':
37
-                $this->$command = $data;
38
-                return $this;
39
-        }
40
-
41
-        return parent::handleCommand($command, $data);
42
-    }
43
-
44
-    public function toArray(): array
45
-    {
46
-        return self::arrayFilterNull(array_merge(array(
47
-            'url' => $this->url,
48
-            'description' => empty($this->description) ? null : $this->description,
49
-        ), parent::toArray()));
50
-    }
51
-
52
-    public function __toString()
53
-    {
54
-        return __CLASS__ . ' ' . $this->url;
55
-    }
17
+	private $url;
18
+	private $description;
19
+
20
+	public function __construct(AbstractObject $parent, $url, $description = null)
21
+	{
22
+		parent::__construct($parent);
23
+		$this->url = $url;
24
+		$this->description = $description;
25
+	}
26
+
27
+	/**
28
+	 * @param string $command
29
+	 * @param string $data
30
+	 * @return AbstractObject|boolean
31
+	 */
32
+	public function handleCommand($command, $data = null)
33
+	{
34
+		switch (strtolower($command)) {
35
+			case 'url':
36
+			case 'description':
37
+				$this->$command = $data;
38
+				return $this;
39
+		}
40
+
41
+		return parent::handleCommand($command, $data);
42
+	}
43
+
44
+	public function toArray(): array
45
+	{
46
+		return self::arrayFilterNull(array_merge(array(
47
+			'url' => $this->url,
48
+			'description' => empty($this->description) ? null : $this->description,
49
+		), parent::toArray()));
50
+	}
51
+
52
+	public function __toString()
53
+	{
54
+		return __CLASS__ . ' ' . $this->url;
55
+	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Type/Property.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -16,82 +16,82 @@
 block discarded – undo
16 16
 class Property extends AbstractObject
17 17
 {
18 18
 
19
-    /**
20
-     * Description of this property
21
-     * @var string
22
-     */
23
-    private $description;
19
+	/**
20
+	 * Description of this property
21
+	 * @var string
22
+	 */
23
+	private $description;
24 24
 
25
-    /**
26
-     * Whether property is read only
27
-     * @var bool
28
-     */
29
-    private $readOnly;
25
+	/**
26
+	 * Whether property is read only
27
+	 * @var bool
28
+	 */
29
+	private $readOnly;
30 30
 
31
-    /**
32
-     * Type definition of this property
33
-     * @var AbstractType
34
-     */
35
-    private $Type;
31
+	/**
32
+	 * Type definition of this property
33
+	 * @var AbstractType
34
+	 */
35
+	private $Type;
36 36
 
37
-    /**
38
-     * Create a new property
39
-     * @param AbstractObject $parent
40
-     * @param string $definition Either a built-in type or a definition name
41
-     * @param string $description description of the property
42
-     * @param bool $readOnly Whether the property is read only
43
-     * @throws Exception
44
-     */
45
-    public function __construct(AbstractObject $parent, $definition, $description = null, $readOnly = null)
46
-    {
47
-        parent::__construct($parent);
48
-        $this->Type = AbstractType::typeFactory($this, $definition, "Not a property: '%s'");
49
-        $this->description = $description;
50
-        $this->readOnly = $readOnly;
51
-    }
37
+	/**
38
+	 * Create a new property
39
+	 * @param AbstractObject $parent
40
+	 * @param string $definition Either a built-in type or a definition name
41
+	 * @param string $description description of the property
42
+	 * @param bool $readOnly Whether the property is read only
43
+	 * @throws Exception
44
+	 */
45
+	public function __construct(AbstractObject $parent, $definition, $description = null, $readOnly = null)
46
+	{
47
+		parent::__construct($parent);
48
+		$this->Type = AbstractType::typeFactory($this, $definition, "Not a property: '%s'");
49
+		$this->description = $description;
50
+		$this->readOnly = $readOnly;
51
+	}
52 52
 
53
-    /**
54
-     * @param string $command The comment command
55
-     * @param string $data Any data added after the command
56
-     * @return self|boolean
57
-     * @throws Exception
58
-     */
59
-    public function handleCommand($command, $data = null)
60
-    {
61
-        // Pass through to Type
62
-        if ($this->Type && $this->Type->handleCommand($command, $data)) {
63
-            return $this;
64
-        }
53
+	/**
54
+	 * @param string $command The comment command
55
+	 * @param string $data Any data added after the command
56
+	 * @return self|boolean
57
+	 * @throws Exception
58
+	 */
59
+	public function handleCommand($command, $data = null)
60
+	{
61
+		// Pass through to Type
62
+		if ($this->Type && $this->Type->handleCommand($command, $data)) {
63
+			return $this;
64
+		}
65 65
 
66
-        return parent::handleCommand($command, $data);
67
-    }
66
+		return parent::handleCommand($command, $data);
67
+	}
68 68
 
69
-    public function toArray(): array
70
-    {
71
-        // Reference + readonly/description result in allOf construct
72
-        // as it's semantically the same and that's what swagger tools
73
-        // like swagger-ui can understand
74
-        $requiresWrap =
75
-            $this->Type instanceof ReferenceObjectType
76
-            && (!empty($this->description) || !is_null($this->readOnly));
69
+	public function toArray(): array
70
+	{
71
+		// Reference + readonly/description result in allOf construct
72
+		// as it's semantically the same and that's what swagger tools
73
+		// like swagger-ui can understand
74
+		$requiresWrap =
75
+			$this->Type instanceof ReferenceObjectType
76
+			&& (!empty($this->description) || !is_null($this->readOnly));
77 77
 
78
-        $valueType = $this->Type->toArray();
78
+		$valueType = $this->Type->toArray();
79 79
 
80
-        if ($requiresWrap) {
81
-            $valueType = array(
82
-                'allOf' => array($valueType),
83
-            );
84
-        }
80
+		if ($requiresWrap) {
81
+			$valueType = array(
82
+				'allOf' => array($valueType),
83
+			);
84
+		}
85 85
 
86
-        return self::arrayFilterNull(array_merge($valueType, array(
87
-            'description' => empty($this->description) ? null : $this->description,
88
-            'readOnly' => $this->readOnly
89
-        ), parent::toArray()));
90
-    }
86
+		return self::arrayFilterNull(array_merge($valueType, array(
87
+			'description' => empty($this->description) ? null : $this->description,
88
+			'readOnly' => $this->readOnly
89
+		), parent::toArray()));
90
+	}
91 91
 
92
-    public function __toString()
93
-    {
94
-        return __CLASS__;
95
-    }
92
+	public function __toString()
93
+	{
94
+		return __CLASS__;
95
+	}
96 96
 
97 97
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Tag.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@
 block discarded – undo
13 13
 class Tag extends AbstractDocumentableObject
14 14
 {
15 15
 
16
-    private $name;
17
-    private $description;
18
-
19
-    public function __construct(AbstractObject $parent, $name, $description = null)
20
-    {
21
-        parent::__construct($parent);
22
-        $this->name = $name;
23
-        $this->description = $description;
24
-    }
25
-
26
-    /**
27
-     * @param string $command
28
-     * @param string $data
29
-     * @return AbstractObject|boolean
30
-     */
31
-    public function handleCommand($command, $data = null)
32
-    {
33
-        if (strtolower($command) === 'description') {
34
-            $this->description = $data;
35
-            return $this;
36
-        }
37
-
38
-        return parent::handleCommand($command, $data);
39
-    }
40
-
41
-    public function toArray(): array
42
-    {
43
-        return self::arrayFilterNull(array_merge(array(
44
-            'name' => $this->name,
45
-            'description' => empty($this->description) ? null : $this->description,
46
-        ), parent::toArray()));
47
-    }
48
-
49
-    public function getName()
50
-    {
51
-        return $this->name;
52
-    }
53
-
54
-    public function __toString()
55
-    {
56
-        return __CLASS__ . ' ' . $this->name;
57
-    }
16
+	private $name;
17
+	private $description;
18
+
19
+	public function __construct(AbstractObject $parent, $name, $description = null)
20
+	{
21
+		parent::__construct($parent);
22
+		$this->name = $name;
23
+		$this->description = $description;
24
+	}
25
+
26
+	/**
27
+	 * @param string $command
28
+	 * @param string $data
29
+	 * @return AbstractObject|boolean
30
+	 */
31
+	public function handleCommand($command, $data = null)
32
+	{
33
+		if (strtolower($command) === 'description') {
34
+			$this->description = $data;
35
+			return $this;
36
+		}
37
+
38
+		return parent::handleCommand($command, $data);
39
+	}
40
+
41
+	public function toArray(): array
42
+	{
43
+		return self::arrayFilterNull(array_merge(array(
44
+			'name' => $this->name,
45
+			'description' => empty($this->description) ? null : $this->description,
46
+		), parent::toArray()));
47
+	}
48
+
49
+	public function getName()
50
+	{
51
+		return $this->name;
52
+	}
53
+
54
+	public function __toString()
55
+	{
56
+		return __CLASS__ . ' ' . $this->name;
57
+	}
58 58
 
59 59
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Schema.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -17,88 +17,88 @@
 block discarded – undo
17 17
 class Schema extends AbstractDocumentableObject implements IDefinition
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    private $description;
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    private $title = null;
29
-
30
-    /**
31
-     * @var bool
32
-     */
33
-    private $readOnly = null;
34
-
35
-    /**
36
-     * @var AbstractType
37
-     */
38
-    private $type;
39
-
40
-    /**
41
-     * @param string $description
42
-     * @throws Exception
43
-     */
44
-    public function __construct(AbstractObject $parent, $definition = 'object', $description = null)
45
-    {
46
-        parent::__construct($parent);
47
-
48
-        // Check if definition set
49
-        if ($this->getSwagger()->hasDefinition($definition)) {
50
-            $this->type = new Type\ReferenceObjectType($this, $definition);
51
-        } else {
52
-            $this->type = Type\AbstractType::typeFactory($this, $definition);
53
-        }
54
-
55
-        $this->description = $description;
56
-    }
57
-
58
-    /**
59
-     * @param string $command
60
-     * @param string $data
61
-     * @return AbstractObject|boolean
62
-     * @throws Exception
63
-     */
64
-    public function handleCommand($command, $data = null)
65
-    {
66
-        // Pass through to Type
67
-        if ($this->type && $this->type->handleCommand($command, $data)) {
68
-            return $this;
69
-        }
70
-
71
-        // handle all the rest manually
72
-        switch (strtolower($command)) {
73
-            case 'description':
74
-                $this->description = $data;
75
-                return $this;
76
-
77
-            case 'title':
78
-                $this->title = $data;
79
-                return $this;
80
-        }
81
-
82
-        return parent::handleCommand($command, $data);
83
-    }
84
-
85
-    public function toArray(): array
86
-    {
87
-        return self::arrayFilterNull(array_merge($this->type->toArray(), array(
88
-            'title' => empty($this->title) ? null : $this->title,
89
-            'description' => empty($this->description) ? null : $this->description,
90
-            'readOnly' => $this->readOnly
91
-        ), parent::toArray()));
92
-    }
93
-
94
-    public function __toString()
95
-    {
96
-        return __CLASS__;
97
-    }
98
-
99
-    public function setReadOnly()
100
-    {
101
-        $this->readOnly = true;
102
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	private $description;
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	private $title = null;
29
+
30
+	/**
31
+	 * @var bool
32
+	 */
33
+	private $readOnly = null;
34
+
35
+	/**
36
+	 * @var AbstractType
37
+	 */
38
+	private $type;
39
+
40
+	/**
41
+	 * @param string $description
42
+	 * @throws Exception
43
+	 */
44
+	public function __construct(AbstractObject $parent, $definition = 'object', $description = null)
45
+	{
46
+		parent::__construct($parent);
47
+
48
+		// Check if definition set
49
+		if ($this->getSwagger()->hasDefinition($definition)) {
50
+			$this->type = new Type\ReferenceObjectType($this, $definition);
51
+		} else {
52
+			$this->type = Type\AbstractType::typeFactory($this, $definition);
53
+		}
54
+
55
+		$this->description = $description;
56
+	}
57
+
58
+	/**
59
+	 * @param string $command
60
+	 * @param string $data
61
+	 * @return AbstractObject|boolean
62
+	 * @throws Exception
63
+	 */
64
+	public function handleCommand($command, $data = null)
65
+	{
66
+		// Pass through to Type
67
+		if ($this->type && $this->type->handleCommand($command, $data)) {
68
+			return $this;
69
+		}
70
+
71
+		// handle all the rest manually
72
+		switch (strtolower($command)) {
73
+			case 'description':
74
+				$this->description = $data;
75
+				return $this;
76
+
77
+			case 'title':
78
+				$this->title = $data;
79
+				return $this;
80
+		}
81
+
82
+		return parent::handleCommand($command, $data);
83
+	}
84
+
85
+	public function toArray(): array
86
+	{
87
+		return self::arrayFilterNull(array_merge($this->type->toArray(), array(
88
+			'title' => empty($this->title) ? null : $this->title,
89
+			'description' => empty($this->description) ? null : $this->description,
90
+			'readOnly' => $this->readOnly
91
+		), parent::toArray()));
92
+	}
93
+
94
+	public function __toString()
95
+	{
96
+		return __CLASS__;
97
+	}
98
+
99
+	public function setReadOnly()
100
+	{
101
+		$this->readOnly = true;
102
+	}
103 103
 
104 104
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/Header.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
 class Header extends AbstractObject
16 16
 {
17 17
 
18
-    private $type;
19
-    private $description;
18
+	private $type;
19
+	private $description;
20 20
 
21
-    /**
22
-     * @throws Exception
23
-     */
24
-    public function __construct(AbstractObject $parent, $type, $description = null)
25
-    {
26
-        parent::__construct($parent);
21
+	/**
22
+	 * @throws Exception
23
+	 */
24
+	public function __construct(AbstractObject $parent, $type, $description = null)
25
+	{
26
+		parent::__construct($parent);
27 27
 
28
-        $this->type = strtolower($type);
29
-        if (!in_array($this->type, array('string', 'number', 'integer', 'boolean', 'array'))) {
30
-            throw new Exception('Header type not valid: \'' . $type . '\'');
31
-        }
28
+		$this->type = strtolower($type);
29
+		if (!in_array($this->type, array('string', 'number', 'integer', 'boolean', 'array'))) {
30
+			throw new Exception('Header type not valid: \'' . $type . '\'');
31
+		}
32 32
 
33
-        $this->description = $description;
34
-    }
33
+		$this->description = $description;
34
+	}
35 35
 
36
-    /**
37
-     * @param string $command
38
-     * @param string $data
39
-     * @return AbstractObject|boolean
40
-     */
41
-    public function handleCommand($command, $data = null)
42
-    {
43
-        if (strtolower($command) === 'description') {
44
-            $this->description = $data;
45
-            return $this;
46
-        }
36
+	/**
37
+	 * @param string $command
38
+	 * @param string $data
39
+	 * @return AbstractObject|boolean
40
+	 */
41
+	public function handleCommand($command, $data = null)
42
+	{
43
+		if (strtolower($command) === 'description') {
44
+			$this->description = $data;
45
+			return $this;
46
+		}
47 47
 
48
-        return parent::handleCommand($command, $data);
49
-    }
48
+		return parent::handleCommand($command, $data);
49
+	}
50 50
 
51
-    public function toArray(): array
52
-    {
53
-        return self::arrayFilterNull(array_merge(array(
54
-            'type' => $this->type,
55
-            'description' => empty($this->description) ? null : $this->description,
56
-        ), parent::toArray()));
57
-    }
51
+	public function toArray(): array
52
+	{
53
+		return self::arrayFilterNull(array_merge(array(
54
+			'type' => $this->type,
55
+			'description' => empty($this->description) ? null : $this->description,
56
+		), parent::toArray()));
57
+	}
58 58
 
59
-    public function __toString()
60
-    {
61
-        return __CLASS__ . ' ' . $this->type;
62
-    }
59
+	public function __toString()
60
+	{
61
+		return __CLASS__ . ' ' . $this->type;
62
+	}
63 63
 
64 64
 }
Please login to merge, or discard this patch.
SwaggerGen/Swagger/AbstractDocumentableObject.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,38 +14,38 @@
 block discarded – undo
14 14
 abstract class AbstractDocumentableObject extends AbstractObject
15 15
 {
16 16
 
17
-    /**
18
-     * External documentation
19
-     * @var ExternalDocumentation
20
-     */
21
-    private $externalDocs = null;
17
+	/**
18
+	 * External documentation
19
+	 * @var ExternalDocumentation
20
+	 */
21
+	private $externalDocs = null;
22 22
 
23
-    /**
24
-     * @param string $command
25
-     * @param string $data
26
-     * @return AbstractObject|boolean
27
-     */
28
-    public function handleCommand($command, $data = null)
29
-    {
30
-        switch (strtolower($command)) {
31
-            case 'doc':
32
-            case 'docs':
33
-                $url = self::wordShift($data);
34
-                $this->externalDocs = new ExternalDocumentation($this, $url, $data);
35
-                return $this->externalDocs;
36
-        }
23
+	/**
24
+	 * @param string $command
25
+	 * @param string $data
26
+	 * @return AbstractObject|boolean
27
+	 */
28
+	public function handleCommand($command, $data = null)
29
+	{
30
+		switch (strtolower($command)) {
31
+			case 'doc':
32
+			case 'docs':
33
+				$url = self::wordShift($data);
34
+				$this->externalDocs = new ExternalDocumentation($this, $url, $data);
35
+				return $this->externalDocs;
36
+		}
37 37
 
38
-        return parent::handleCommand($command, $data);
39
-    }
38
+		return parent::handleCommand($command, $data);
39
+	}
40 40
 
41
-    /**
42
-     * @return array
43
-     */
44
-    public function toArray(): array
45
-    {
46
-        return self::arrayFilterNull(array_merge(array(
47
-            'externalDocs' => $this->externalDocs ? $this->externalDocs->toArray() : null,
48
-        ), parent::toArray()));
49
-    }
41
+	/**
42
+	 * @return array
43
+	 */
44
+	public function toArray(): array
45
+	{
46
+		return self::arrayFilterNull(array_merge(array(
47
+			'externalDocs' => $this->externalDocs ? $this->externalDocs->toArray() : null,
48
+		), parent::toArray()));
49
+	}
50 50
 
51 51
 }
Please login to merge, or discard this patch.