Skip to content

Commit fcab922

Browse files
xviloMikailBag
authored andcommitted
Add return types to getter and fluent setter (OpenAPITools#5348)
* Add return types to getter and fluent setter * Add build example output
1 parent 8822660 commit fcab922

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

modules/openapi-generator/src/main/resources/php-symfony/model_generic.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
2323
*
2424
* @return {{{vendorExtensions.x-comment-type}}}{{^required}}|null{{/required}}
2525
*/
26-
public function {{getter}}()
26+
public function {{getter}}(){{#vendorExtensions.x-parameter-type}}: {{^required}}?{{/required}}{{vendorExtensions.x-parameter-type}}{{/vendorExtensions.x-parameter-type}}
2727
{
2828
return $this->{{name}};
2929
}
@@ -35,7 +35,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
3535
*
3636
* @return $this
3737
*/
38-
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}})
38+
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}}){{#vendorExtensions.x-parameter-type}}: {{^required}}?{{/required}}{{vendorExtensions.x-parameter-type}}{{/vendorExtensions.x-parameter-type}}
3939
{
4040
$this->{{name}} = ${{name}};
4141

samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Order.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function setQuantity($quantity = null)
185185
*
186186
* @return \DateTime|null
187187
*/
188-
public function getShipDate()
188+
public function getShipDate(): ?\DateTime
189189
{
190190
return $this->shipDate;
191191
}
@@ -197,7 +197,7 @@ public function getShipDate()
197197
*
198198
* @return $this
199199
*/
200-
public function setShipDate(\DateTime $shipDate = null)
200+
public function setShipDate(\DateTime $shipDate = null): ?\DateTime
201201
{
202202
$this->shipDate = $shipDate;
203203

samples/server/petstore/php-symfony/SymfonyBundle-php/Model/Pet.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function setId($id = null)
143143
*
144144
* @return OpenAPI\Server\Model\Category|null
145145
*/
146-
public function getCategory()
146+
public function getCategory(): ?Category
147147
{
148148
return $this->category;
149149
}
@@ -155,7 +155,7 @@ public function getCategory()
155155
*
156156
* @return $this
157157
*/
158-
public function setCategory(Category $category = null)
158+
public function setCategory(Category $category = null): ?Category
159159
{
160160
$this->category = $category;
161161

@@ -191,7 +191,7 @@ public function setName($name)
191191
*
192192
* @return string[]
193193
*/
194-
public function getPhotoUrls()
194+
public function getPhotoUrls(): array
195195
{
196196
return $this->photoUrls;
197197
}
@@ -203,7 +203,7 @@ public function getPhotoUrls()
203203
*
204204
* @return $this
205205
*/
206-
public function setPhotoUrls(array $photoUrls)
206+
public function setPhotoUrls(array $photoUrls): array
207207
{
208208
$this->photoUrls = $photoUrls;
209209

@@ -215,7 +215,7 @@ public function setPhotoUrls(array $photoUrls)
215215
*
216216
* @return OpenAPI\Server\Model\Tag[]|null
217217
*/
218-
public function getTags()
218+
public function getTags(): ?array
219219
{
220220
return $this->tags;
221221
}
@@ -227,7 +227,7 @@ public function getTags()
227227
*
228228
* @return $this
229229
*/
230-
public function setTags(array $tags = null)
230+
public function setTags(array $tags = null): ?array
231231
{
232232
$this->tags = $tags;
233233

0 commit comments

Comments
 (0)