FOSCommentBundle symfony 3 严重错误

FOSCommentBundle symfony 3 critical error

我正在我的项目中安装 foscomment 包,我正在按照 git hub

中随该包提供的文档进行操作

这是link

documentation git hub

当我想更新我的数据库模式时,这个异常出现在我面前,我无法弄清楚是什么问题

 [2017-02-11 17:06:57] php.CRITICAL: Fatal Compile Error: Declaration of Group\GroupBundle\Entity\Comment::setThread() must be compatible with FOS\CommentBundle\Model\CommentInterface::setThread(FOS\CommentBundle\Model\ThreadInterface $thread) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Compile Error: Declaration of Group\GroupBundle\Entity\Comment::setThread() must be compatible with FOS\CommentBundle\Model\CommentInterface::setThread(FOS\CommentBundle\Model\ThreadInterface $thread) at C:\wamp\www\E-Randopi\src\Group\GroupBundle\Entity\Comment.php:18)"} 


[Symfony\Component\Debug\Exception\FatalErrorException]                      
Compile Error: Declaration of Group\GroupBundle\Entity\Comment::setThread()  
 must be compatible with FOS\CommentBundle\Model\CommentInterface::setThrea  
 d(FOS\CommentBundle\Model\ThreadInterface $thread)                           


doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

这是我的错误输出

这是我的评论实体

<?php

 namespace Group\GroupBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;


/**
   * Commentaire
  *
  * @ORM\Table(name="commentaire")
   * @ORM\Entity
   * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")

 */
 class Comment extends BaseComment
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;

/**
 * Thread of this comment
 *
 * @var Thread
 * @ORM\ManyToOne(targetEntity="Group\GroupBundle\Entity\Thread")
 */
protected $thread;

/**
 * @var string
 *
 * @ORM\Column(name="description", type="string", length=100, nullable=false)
 */
private $description;

/**
 * @var integer
 *
 * @ORM\Column(name="id_createur", type="integer", nullable=false)
 */
private $idCreateur;

/**
 * @var integer
 *
 * @ORM\Column(name="id_publication", type="integer", nullable=false)
 */
private $idPublication;

/**
 * @var string
 *
 * @ORM\Column(name="photo", type="string", length=100, nullable=false)
 */
private $photo;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="date_commentaire", type="date", nullable=false)
 */
private $dateCommentaire;

/**
 * @return int
 */
public function getId()
{
    return $this->id;
}

/**
 * @param int $id
 */
public function setId($id)
{
    $this->id = $id;
}

/**
 * @return Thread
 */
public function getThread()
{
    return $this->thread;
}

/**
 * @param Thread $thread
 */
public function setThread($thread)
{
    $this->thread = $thread;
}

/**
 * @return string
 */
public function getDescription()
{
    return $this->description;
}

/**
 * @param string $description
 */
public function setDescription($description)
{
    $this->description = $description;
}

/**
 * @return int
 */
public function getIdCreateur()
{
    return $this->idCreateur;
}

/**
 * @param int $idCreateur
 */
public function setIdCreateur($idCreateur)
{
    $this->idCreateur = $idCreateur;
}

/**
 * @return int
 */
public function getIdPublication()
{
    return $this->idPublication;
}

/**
 * @param int $idPublication
 */
public function setIdPublication($idPublication)
{
    $this->idPublication = $idPublication;
}

/**
 * @return string
 */
public function getPhoto()
{
    return $this->photo;
}

/**
 * @param string $photo
 */
public function setPhoto($photo)
{
    $this->photo = $photo;
}

/**
 * @return \DateTime
 */
public function getDateCommentaire()
{
    return $this->dateCommentaire;
}

/**
 * @param \DateTime $dateCommentaire
 */
public function setDateCommentaire($dateCommentaire)
{
    $this->dateCommentaire = $dateCommentaire;
}


}

必须根据 FOSCommentBundle 的 CommentInterface::setThread() 声明 setThread() 方法,即:

/**
 * @param ThreadInterface $thread
 */
public function setThread(ThreadInterface $thread);

并且您的 Comment::setThread() 声明是:

/**
 * @param Thread $thread
 */
public function setThread($thread)
{
    $this->thread = $thread;
}