Symfony 4:参数的类型提示无效
尝试清除prod server中的缓存和composer安装时出现此错误: !!类中“addShow”方法中参数“show”的类型提示 “应用\实体\!!类型”无效 这是addShow方法:Symfony 4:参数的类型提示无效,symfony,type-hinting,typehints,Symfony,Type Hinting,Typehints,尝试清除prod server中的缓存和composer安装时出现此错误: !!类中“addShow”方法中参数“show”的类型提示 “应用\实体\!!类型”无效 这是addShow方法: public function addShow(Show $show): self { if (!$this->shows->contains($show)) { $this->shows[] = $show;
public function addShow(Show $show): self
{
if (!$this->shows->contains($show)) {
$this->shows[] = $show;
$show->setType($this);
}
return $this;
}
您需要指定作为参数传递的类 您可以将所有路径放入类以指定类型:
public function addShow(App\Bundle\Show $show): self
{
if (!$this->shows->contains($show)) {
$this->shows[] = $show;
$show->setType($this);
}
return $this;
}
或加上:
use App\Bundle\Show;
只要在同一名称空间中实际有一个
Show
实体(或者有一个适当的use子句),看起来就很合理。我希望Show实体不是新的,还没有部署^^