[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 07dd9715
This commit is contained in:
Artem 2020-04-30 21:03:05 +02:00 committed by GitHub
parent 3bbaedd9bc
commit 0032e04530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -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}};

View File

@ -197,7 +197,7 @@ class Order
*
* @return $this
*/
public function setShipDate(\DateTime $shipDate = null): ?\DateTime
public function setShipDate(\DateTime $shipDate = null)
{
$this->shipDate = $shipDate;

View File

@ -155,7 +155,7 @@ class Pet
*
* @return $this
*/
public function setCategory(Category $category = null): ?Category
public function setCategory(Category $category = null)
{
$this->category = $category;
@ -203,7 +203,7 @@ class Pet
*
* @return $this
*/
public function setPhotoUrls(array $photoUrls): array
public function setPhotoUrls(array $photoUrls)
{
$this->photoUrls = $photoUrls;
@ -227,7 +227,7 @@ class Pet
*
* @return $this
*/
public function setTags(array $tags = null): ?array
public function setTags(array $tags = null)
{
$this->tags = $tags;