Skip to content

Commit 0032e04

Browse files
authored
[php-symfony] Fix return type in model setters. (#6085)
* Fix return type in model setters. Previously return type was same, as method arguments. It`s wrong, and cause errors like "Return value of Foo::setSuccess() must be of the type bool, object returned" We cant use self and current {{classname}} as return type, because that can break class inheritance. So, better remove type hint on setters, until PHP-devs dont make realization for return static * Add return self type hint for setters * Revert "Add return self type hint for setters" This reverts commit 07dd971
1 parent 3bbaedd commit 0032e04

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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}}){{#vendorExtensions.x-parameter-type}}: {{^required}}?{{/required}}{{vendorExtensions.x-parameter-type}}{{/vendorExtensions.x-parameter-type}}
38+
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}})
3939
{
4040
$this->{{name}} = ${{name}};
4141

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function getShipDate(): ?\DateTime
197197
*
198198
* @return $this
199199
*/
200-
public function setShipDate(\DateTime $shipDate = null): ?\DateTime
200+
public function setShipDate(\DateTime $shipDate = null)
201201
{
202202
$this->shipDate = $shipDate;
203203

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getCategory(): ?Category
155155
*
156156
* @return $this
157157
*/
158-
public function setCategory(Category $category = null): ?Category
158+
public function setCategory(Category $category = null)
159159
{
160160
$this->category = $category;
161161

@@ -203,7 +203,7 @@ public function getPhotoUrls(): array
203203
*
204204
* @return $this
205205
*/
206-
public function setPhotoUrls(array $photoUrls): array
206+
public function setPhotoUrls(array $photoUrls)
207207
{
208208
$this->photoUrls = $photoUrls;
209209

@@ -227,7 +227,7 @@ public function getTags(): ?array
227227
*
228228
* @return $this
229229
*/
230-
public function setTags(array $tags = null): ?array
230+
public function setTags(array $tags = null)
231231
{
232232
$this->tags = $tags;
233233

0 commit comments

Comments
 (0)