I am constantly getting this weird error
Warning: Declaration of Proxies\__CG__\AppBundle\Entity\MyEntity::setName(string $name):
AppBundle\Entity\MyEntity should be compatible with AppBundle\Entity\MyEntity::setName(?string $name):
AppBundle\Entity\MyEntity
Why on earth is this happening? Why can I not have
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
as my setter? It works if I remove '?', but I do need it for other purpose
As I mentioned in the comments already: According to this issue older versions of doctrine/common (specifically older than 2.7.1) might have problems creating a matching proxy class if you are using optional parameter type hints.
Updating doctrine/common seems to fix the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With