3
的,我經常收到這種奇怪的錯誤主義PHP7 +類型提示,聲明代理錯誤
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
地球上
這究竟是爲什麼?爲什麼我沒有
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
作爲我的二傳手?如果我刪除'?',但我確實需要它用於其他用途
通常這可以通過清除symfony緩存來解決。你已經這樣做了嗎? –
您是否嘗試過使用'public function setName(string $ name = null):self'? – yceruto
@TobiasXy,是的,我嘗試使用symfony命令並刪除緩存目錄。它不利於這種情況。 – user7808407