且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Symfony2 __toString()错误

更新时间:2023-11-19 16:26:22

我认为这些值是 null 然后。你尝试过:

I think those values are null then. Did you try:

public function __toString()
{
    return (string) $this->getType();
}

public function __toString()
{
    return (string) $this->getContact();
}

当值为 null 将被转换为字符串,你不应该得到这个例外。

That way when value is null will be casted to string and you should not get this exception.