Skip to content

Commit

Permalink
[php-symfony] Fix return type in model setters. (OpenAPITools#6085)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
reznikartem authored and michaelpro1 committed May 7, 2020
1 parent bc706ac commit c635031
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
*
* @return $this
*/
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}}
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}})
{
$this->{{name}} = ${{name}};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function getShipDate(): ?\DateTime
*
* @return $this
*/
public function setShipDate(\DateTime $shipDate = null): ?\DateTime
public function setShipDate(\DateTime $shipDate = null)
{
$this->shipDate = $shipDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function getCategory(): ?Category
*
* @return $this
*/
public function setCategory(Category $category = null): ?Category
public function setCategory(Category $category = null)
{
$this->category = $category;

Expand Down Expand Up @@ -203,7 +203,7 @@ public function getPhotoUrls(): array
*
* @return $this
*/
public function setPhotoUrls(array $photoUrls): array
public function setPhotoUrls(array $photoUrls)
{
$this->photoUrls = $photoUrls;

Expand All @@ -227,7 +227,7 @@ public function getTags(): ?array
*
* @return $this
*/
public function setTags(array $tags = null): ?array
public function setTags(array $tags = null)
{
$this->tags = $tags;

Expand Down

0 comments on commit c635031

Please sign in to comment.