Php 错误:方法\uuuToString()不能引发异常symfony2

Php 错误:方法\uuuToString()不能引发异常symfony2,php,symfony,tostring,Php,Symfony,Tostring,我正在使用Symfony2,我遇到了一个错误: 错误:方法代理\uuucg\uuuu\Sprint\SiteBundle\Entity\Task::\uuuuuToString()不能引发异常 这是我的Entity\Task.php中的代码: /** * @return string */ public function __toString() { return $this->title; } 主要的问题是,在我的本地版本的这个网站上,一切正常,我只有在我的实时网站上才有这

我正在使用Symfony2,我遇到了一个错误:

错误:方法代理\uuucg\uuuu\Sprint\SiteBundle\Entity\Task::\uuuuuToString()不能引发异常

这是我的
Entity\Task.php
中的代码:

/**
 * @return string
 */
public function __toString()
{
    return $this->title;
}
主要的问题是,在我的本地版本的这个网站上,一切正常,我只有在我的实时网站上才有这个错误。但他们是相似的

这里是my Entity\Task.php代码:

class Task
    {

    use TraitDateTimeFields;

    use TraitCreatorTimeFields;

    use TraitTaskTeamFields;

    use TraitTimeTrackFields;

    use TraitTagFields;
    /**
     * @ORM\ManyToMany(targetEntity="Sprint\SiteBundle\Entity\Tag")
     * @ORM\JoinTable(
     *  name="s_task_tags",
     *  joinColumns={
     *      @ORM\JoinColumn(name="task_id", referencedColumnName="id")
     *  },
     *  inverseJoinColumns={
     *      @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
     *  }
     *  )
     */
    private $tags;

    /**
     * @ORM\Column(type="integer", name="id")
     * @ORM\Id
     * @ORM\GeneratedValue
     * @Gedmo\TreePathSource
     * @var integer
     */
    private $id;

    /**
     * @ORM\Column(type="integer", name="depth", nullable=true)
     * @Gedmo\TreeLevel
     * @var integer
     */
    private $depth;

    /**
     * @ORM\Column(type="string", name="path", length=255, nullable=true)
     * @Gedmo\TreePath
     * @var string
     */
    private $path;

    /** Это группа
     * @ORM\Column(type="boolean", name="flag_group")
     * @var string
     */
    private $flagGroup = false;

    /** Архив
     *
     * @ORM\Column(type="boolean", name="flag_archive")
     * @var string
     */
    private $flagArchive = false;

    /**
     * @ORM\Column(type="string", name="number", nullable=false)
     * @var string
     */
    protected $number = '';

    /**
     * @ORM\Column(type="string", name="title", nullable=true)
     * @var string
     */
    protected $title;

    /**
     * @ORM\Column(type="integer", name="resource")
     * @var string
     * @deprecated
     */
    protected $resource = 0;

    /**
     * @ORM\Column(type="integer", name="bonus")
     * @var string
     */
    protected $bonus = 0;

    /**
     * @ORM\Column(type="integer", name="state")
     * @var string
     */
    protected $state = TaskState::C_WORKING;

    /**
     * @ORM\Column(type="integer", name="ttype")
     * @var string
     */
    protected $type = TaskType::C_INNER;

    /** Начало
     *
     * @ORM\Column(type="datetime", name="start_to", nullable=true)
     * @var \DateTime
     */
    private $startTo;

    /** Дедлайн
     *
     * @ORM\Column(type="datetime", name="deadline_to", nullable=true)
     * @var \DateTime
     */
    private $deadlineTo;

    /** Срочно
     *
     * @ORM\Column(type="boolean", name="flag_quicly")
     * @var string
     */
    private $flagQuickly = false;

    /** Формирование бюджета
     *
     * @ORM\Column(type="boolean", name="flag_budget")
     * @var string
     */
    private $flagBudget = true;

    /**
     * @ORM\OneToMany(targetEntity="Sprint\SiteBundle\Entity\EstimateOperatingRow", mappedBy="task", cascade={"detach","persist"}, orphanRemoval=false)
     * @var \Doctrine\Common\Collections\ArrayCollection
     */
    protected $estimateRows;


    /**
     * @ORM\ManyToOne(targetEntity="Sprint\SiteBundle\Entity\Project", inversedBy="tasks")
     * @ORM\JoinColumn(name="project_id", referencedColumnName="id", onDelete="CASCADE")
     * @var \Sprint\SiteBundle\Entity\Project
     */
    protected $project;

    /**
     * @ORM\ManyToOne(targetEntity="Sprint\SiteBundle\Entity\Task", inversedBy="children")
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
     * @Gedmo\TreeParent
     * @var \Sprint\SiteBundle\Entity\Task
     */
    protected $parent;

    /**  Подзадачи
     *
     * @ORM\OneToMany(targetEntity="Sprint\SiteBundle\Entity\Task", mappedBy="parent", cascade={"all"}, orphanRemoval=true)
     * @var \Doctrine\Common\Collections\ArrayCollection
     */
    public $children;

    /**  Задания
     *
     * @ORM\OneToMany(targetEntity="Sprint\SiteBundle\Entity\TaskAssignment", mappedBy="task", cascade={"all"}, orphanRemoval=true)
     * @var \Doctrine\Common\Collections\ArrayCollection
     */
    public $assignment;

    /**  Активность
     *
     * @ORM\OneToMany(targetEntity="Sprint\SiteBundle\Entity\TaskActivityItem", mappedBy="task", cascade={"all"}, orphanRemoval=true)
     * @var \Doctrine\Common\Collections\ArrayCollection
     */
    public $activity;

    private $activitySummary = [];

    protected $operationItems = [];

    /**
     * Task constructor.
     */
    public function __construct()
    {
        $this->children      = new \Doctrine\Common\Collections\ArrayCollection();
        $this->activity      = new \Doctrine\Common\Collections\ArrayCollection();
        $this->auditors      = new \Doctrine\Common\Collections\ArrayCollection();
        $this->staff         = new \Doctrine\Common\Collections\ArrayCollection();
        $this->tags          = new \Doctrine\Common\Collections\ArrayCollection();
        $this->estimateRows  = new \Doctrine\Common\Collections\ArrayCollection();
        $this->assignment    = new \Doctrine\Common\Collections\ArrayCollection();
    }

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

    public function getTreeTitle()
    {
        return str_pad('', ($this->depth-1)*6*4, ' ', STR_PAD_LEFT) . ($this->flagGroup ? ' ' : ' ') . $this->title;
    }

    /**
     * @return array
     */
    public function getPaySummary()
    {
        $result = [
            'total'   => 0,
            'paid'    => 0,
            'remains' => 0,
            'credit'  => 0
        ];

        $now = new \DateTime();

        foreach ($this->getOperationItems() as $opt) {
            $optSummary = $opt->getSummary();

            $result['total']   += $optSummary['total'];
            $result['paid']    += $optSummary['paid'];
            $result['remains'] += $optSummary['remains'];

            if ($opt->getExpectedAt()) {
                $df = $now->diff($opt->getExpectedAt());

                if ($df->invert) {
                    $result['credit'] += $optSummary['remains'];
                }
            }
        }

        return $result;
    }

    /**
     * @return array
     */
    public function getActivitySummary($hourPrice, $forced = false)
    {
        if ($forced) {
            $this->activitySummary = [];
        }
        if ($this->activitySummary) {
            return $this->activitySummary;
        }
        $result = [
            'plannedHours' => 0,
            'plannedSmens' => 0,
            'plannedPrice' => 0,

            'plannedHoursRemains' => 0,
            'plannedSmensRemains' => 0,
            'plannedPriceRemains' => 0,

            'developHours' => 0,
            'developSmens' => 0,
            'developPrice' => 0,

            'developHoursRemains' => 0,
            'developSmensRemains' => 0,
            'developPriceRemains' => 0,

            'innerHours' => 0,
            'innerSmens' => 0,
            'innerPrice' => 0,

            'innerHoursRemains' => 0,
            'innerSmensRemains' => 0,
            'innerPriceRemains' => 0,

            'outherHours' => 0,
            'outherSmens' => 0,
            'outherPrice' => 0,

            'outherHoursRemains' => 0,
            'outherSmensRemains' => 0,
            'outherPriceRemains' => 0,

            'resource'     => 0
        ];


        if ($this->flagGroup) {
            $childs = $this->getChildren();

            if (!$childs->isEmpty()) {
                $cnt         = $childs->count();
                $planSummary = 0.0;

                foreach ($childs as $c) {
                    $planSummary += $c->getPlannedHours();
                    $cRes = $c->getActivitySummary($hourPrice, $forced);

                    foreach ($cRes as $k => $v) {
                        $result[$k] += $v;
                    }
                }

                $this->setPlannedHours($planSummary);
            }
        } else {
            foreach ($this->activity as $a) {
                switch ($a->getActivity()) {
                    case TaskActivity::C_DEVELOP :
                        $result['plannedHours'] += $a->getSpend();
                        $result['developHours'] += $a->getSpend();
                        break;
                    case TaskActivity::C_INNER :
                        $result['plannedHours'] += $a->getSpend();
                        $result['innerHours'] += $a->getSpend();
                        break;
                    case TaskActivity::C_OUTHER :
                        $result['plannedHours'] += $a->getSpend();
                        $result['outherHours'] += $a->getSpend();
                        break;
                }
            }

            $result['plannedHoursRemains'] = $this->getPlannedHours() - $result['plannedHours'];
            $result['developHoursRemains'] = $this->getDevelopHours() - $result['developHours'];
            $result['innerHoursRemains']   = $this->getInnerHours() - $result['innerHours'];
            $result['outherHoursRemains']  = $this->getOutherHours() - $result['outherHours'];
        }

        $result['plannedSmens'] = $result['plannedHours'] / 8;
        $result['developSmens'] = $result['developHours'] / 8;
        $result['innerSmens']   = $result['innerHours']   / 8;
        $result['outherSmens']  = $result['outherHours']  / 8;

        $result['plannedPrice'] = $result['plannedHours'] * $hourPrice;
        $result['developPrice'] = $result['developHours'] * $hourPrice;
        $result['innerPrice']   = $result['innerHours']   * $hourPrice;
        $result['outherPrice']  = $result['outherHours']  * $hourPrice;

        $result['plannedSmensRemains'] = $result['plannedHoursRemains'] / 8;
        $result['developSmensRemains'] = $result['developHoursRemains'] / 8;
        $result['innerSmensRemains']   = $result['innerHoursRemains']   / 8;
        $result['outherSmensRemains']  = $result['outherHoursRemains']  / 8;

        $result['plannedPriceRemains'] = $result['plannedHoursRemains'] * $hourPrice;
        $result['developPriceRemains'] = $result['developHoursRemains'] * $hourPrice;
        $result['innerPriceRemains']   = $result['innerHoursRemains']   * $hourPrice;
        $result['outherPriceRemains']  = $result['outherHoursRemains']  * $hourPrice;


        if ($this->plannedHours) {
            $result['resource'] = round(
                ($result['developHours'] + $result['innerHours'] + $result['outherHours']) / $this->plannedHours * 100
            );
        }

        $this->activitySummary = $result;
        return $this->activitySummary;
    }

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

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

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

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

    /**
     * @return bool|\DateInterval
     */
    public function getTimeToDeadline()
    {
        return $this->deadlineTo ? $this->deadlineTo->diff(new \DateTime()) : null;
    }

    /**
     * @return string
     */
    public function getFlagQuickly()
    {
        $interval = $this->getTimeToDeadline();
        return ($interval && $interval->invert && $interval->days*24 < 8);
    }

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

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

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

    /**
     * @param Project $project
     * @return Task
     */
    public function setProject($project)
    {
        $this->project = $project;

        return $this;
    }

    /**
     * @return Project
     */
    public function getProject()
    {
        return $this->project;
    }

    /**
     * @return ArrayCollection
     */
    public function getChildren()
    {
        return $this->children;
    }

    /**
     * @return \Doctrine\Common\Collections\Collection|static
     */
    public function getDisplayedChildren()
    {
        $criteria = Criteria::create();
        $criteria->orderBy(['createdAt' => 'DESC']);
        $criteria->where(Criteria::expr()->eq('parent', $this));
        return $this->children->matching($criteria);
    }

    /**
     * @param Task $parent
     * @return Task
     */
    public function setParent($parent)
    {
        $this->parent = $parent;

        return $this;
    }

    /**
     * @return Task
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * @param \DateTime $startTo
     * @return Task
     */
    public function setStartTo($startTo)
    {
        $this->startTo = $startTo;

        return $this;
    }

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

    /**
     * @param \DateTime $deadlineTo
     * @return Task
     */
    public function setDeadlineTo($deadlineTo)
    {
        $this->deadlineTo = $deadlineTo;

        return $this;
    }

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

    /**
     * @param string $number
     * @return Task
     */
    public function setNumber($number)
    {
        $this->number = $number;

        return $this;
    }

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

    /**
     * @param string $resource
     * @return Task
     */
    public function setResource($resource)
    {
        $this->resource = $resource;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getEstimateRows()
    {
        return $this->estimateRows;
    }

    /**
     * @param $estimateRow
     */
    public function addEstimateRow($estimateRow)
    {
        $estimateRow->setTask($this);
        $this->estimateRows->add($estimateRow);
    }

    /**
     * @param $estimateRow
     */
    public function removeEstimateRow($estimateRow)
    {
        $estimateRow->setTask(null);
        $this->estimateRows->removeElement($estimateRow);
    }

    /**
     * @param mixed $estimateRows
     */
    /*
    public function setEstimateRows($estimateRows)
    {
        $this->estimateRows = $estimateRows;
    }
    */

    /**
     * @return mixed
     */
    public function getState()
    {
        return $this->state;
    }

    /**
     * @param mixed $state
     */
    public function setState($state)
    {
        $this->state = $state;
    }

    /**
     * @return mixed
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * @param mixed $type
     */
    public function setType($type)
    {
        $this->type = $type;
    }

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

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

    /**
     * @return mixed
     */
    public function getBonus()
    {
        return $this->bonus;
    }

    /**
     * @param mixed $bonus
     */
    public function setBonus($bonus)
    {
        $this->bonus = $bonus;
    }

    /**
     * @return ArrayCollection
     */
    public function getActivity()
    {
        return $this->activity;
    }

    /**
     * @return ArrayCollection
     */
    public function getAssignment()
    {
        return $this->assignment;
    }

    /**
     * @return \Doctrine\Common\Collections\Collection|static
     */
    public function getDisplayedActivity()
    {
        $criteria = Criteria::create();
        $criteria->orderBy(['createdAt' => 'DESC']);
        $criteria->where(Criteria::expr()->isNull('parent'));
        return $this->activity->matching($criteria);
    }

    /**
     * @param $activity
     */
    public function addActivity($activity)
    {
        $this->activity->add($activity);
    }

    /**
     * @param $activity
     */
    public function removeActivity($activity)
    {
        $this->activity->removeElement($activity);
    }

    /**
     * @return mixed
     */
    public function getDepth()
    {
        return $this->depth;
    }

    /**
     * @param mixed $depth
     */
    public function setDepth($depth)
    {
        $this->depth = $depth;
    }

    /**
     * @return mixed
     */
    public function getPath()
    {
        return $this->path;
    }

    /**
     * @param mixed $path
     */
    public function setPath($path)
    {
        $this->path = $path;
    }

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

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

    public function getDirector()
    {
        return $this->project ? $this->project->getDirector() : $this->director;
    }

    /**
     * @return mixed
     */
    public function getFlagArchive()
    {
        return $this->flagArchive;
    }

    /**
     * @param mixed $flagArchive
     */
    public function setFlagArchive($flagArchive)
    {
        $this->flagArchive = $flagArchive;
    }

    /**
     * @return mixed
     */
    public function getOperationItems()
    {
        return $this->operationItems;
    }

    /**
     * @param mixed $operations
     */
    public function setOperationItems($operations)
    {
        $this->operationItems = $operations;
    }
}
类任务
{
使用TraitDateTimeFields;
使用traitcreatertimefields;
使用TraitTaskTeamFields;
使用trattimetrackfields;
使用跟踪场;
/**
*@ORM\ManyToMany(targetEntity=“Sprint\SiteBundle\Entity\Tag”)
*@ORM\JoinTable(
*name=“s\u任务\u标签”,
*连接柱={
*@ORM\JoinColumn(name=“task\u id”,referencedColumnName=“id”)
*  },
*反向连接柱={
*@ORM\JoinColumn(name=“tag\u id”,referencedColumnName=“id”)
*  }
*  )
*/
私人$tags;
/**
*@ORM\Column(type=“integer”,name=“id”)
*@ORM\Id
*@ORM\GeneratedValue
*@Gedmo\TreePathSource
*@var整数
*/
私人$id;
/**
*@ORM\Column(type=“integer”,name=“depth”,nullable=true)
*@Gedmo\TreeLevel
*@var整数
*/
私人深度;
/**
*@ORM\Column(type=“string”,name=“path”,length=255,nullable=true)
*@Gedmo\TreePath
*@var字符串
*/
私家路;;
/** Это группа
*@ORM\Column(type=“boolean”,name=“flag\u group”)
*@var字符串
*/
private$flagGroup=false;
/** Архив
*
*@ORM\Column(type=“boolean”,name=“flag\u archive”)
*@var字符串
*/
私有$flagArchive=false;
/**
*@ORM\Column(type=“string”,name=“number”,nullable=false)
*@var字符串
*/
受保护的$number='';
/**
*@ORM\Column(type=“string”,name=“title”,nullable=true)
*@var字符串
*/
受保护的产权;
/**
*@ORM\Column(type=“integer”,name=“resource”)
*@var字符串
*@弃用
*/
受保护的$resource=0;
/**
*@ORM\Column(type=“integer”,name=“bonus”)
*@var字符串
*/
受保护的$bonus=0;
/**
*@ORM\Column(type=“integer”,name=“state”)
*@var字符串
*/
受保护的$state=TaskState::C_工作;
/**
*@ORM\Column(type=“integer”,name=“ttype”)
*@var字符串
*/
受保护的$type=TaskType::C_-INNER;
/** Начало
*
*@ORM\Column(type=“datetime”,name=“start\u to”,nullable=true)
*@var\DateTime
*/
私人$startTo;
/** Дедлайн
*
*@ORM\Column(type=“datetime”,name=“deadline\u to”,nullable=true)
*@var\DateTime
*/
私人$deadlineTo;
/** Срочно
*
*@ORM\Column(type=“boolean”,name=“flag\u quicly”)
*@var字符串
*/
private$flagflast=false;
/** Формирование бюджета
*
*@ORM\Column(type=“boolean”,name=“flag\u预算”)
*@var字符串
*/
私有$flagBudget=true;
/**
*@ORM\OneToMany(targetEntity=“Sprint\SiteBundle\Entity\EstimateOperatingRow”,mappedBy=“task”,cascade={“detach”,“persist”},orphanRemoving=false)
*@var\doctor\Common\Collections\ArrayCollection
*/
受保护的$estimateRows;
/**
*@ORM\manytone(targetEntity=“Sprint\SiteBundle\Entity\Project”,inversedBy=“tasks”)
*@ORM\JoinColumn(name=“project\u id”,referencedColumnName=“id”,onDelete=“CASCADE”)
*@var\Sprint\SiteBundle\Entity\Project
*/
受保护的项目;
/**
*@ORM\manytone(targetEntity=“Sprint\SiteBundle\Entity\Task”,inversedBy=“children”)
*@ORM\JoinColumn(name=“parent\u id”,referencedColumnName=“id”,onDelete=“CASCADE”)
*@Gedmo\TreeParent
*@var\Sprint\SiteBundle\Entity\Task
*/
受保护的$父母;
/**  Подзадачи
*
*@ORM\OneToMany(targetEntity=“Sprint\SiteBundle\Entity\Task”,mappedBy=“parent”,cascade={“all”},orphanRemoving=true)
*@var\doctor\Common\Collections\ArrayCollection
*/
公共儿童基金会;
/**  Задания
*
*@ORM\OneToMany(targetEntity=“Sprint\SiteBundle\Entity\tasksignment”,mappedBy=“task”,cascade={“all”},orphanRemoving=true)
*@var\doctor\Common\Collections\ArrayCollection
*/
公帑转让;
/**  Активность
*
*@ORM\OneToMany(targetEntity=“Sprint\SiteBundle\Entity\TaskActivityItem”,mappedBy=“task”,cascade={“all”},孤立删除=true)
*@var\doctor\Common\Collections\ArrayCollection
*/
公共活动;
私有$activitySummary=[];
受保护的$operationItems=[];
/**
*任务构造函数。
*/
公共函数构造()
{
$this->children=new\Doctrine\Common\Collections\ArrayCollection();
$this->activity=new\Doctrine\Common\Collections\ArrayCollection();
$this->auditors=new\Doctrine\Common\Collections\ArrayCollection();
$this->staff=new\Doctrine\Common\Collections\ArrayCollection();
$this->tags=new\Doctrine\Common\Collections\ArrayCollection();
$this->estimateRows=new\Doctrine\Common\Collections\ArrayCollection();
$this->assignment=new\Doctrine\Common\Collections\ArrayCollection();
}
/**
*@返回字符串
*/
公共函数
{
返回$this->title;
}
公共函数getTreeTitle()
{
返回stru-pad(“”,($this->depth-1)*6*4,”,stru-pad_-LEFT)。($this->flagGroup?;':';)。$this->title;
}
/**
*@return数组
*/
公共函数getPaySummary()
{
$result=[
“总计”=>0,
“已支付”=>0,
“剩余”=>0,
'信用'=>0
];
$now=new\DateTime();
外汇
public function __toString() 
{ 
   return (string)$this->title; 
}
/**
 * @return string
 */
public function __toString()
{
    return (isset($this) && $this->title !== '')
        ? (string)$this->title
        : '';
}