【发布时间】:2018-07-24 02:11:07
【问题描述】:
拥有以下实体:
ID; } /** * @return 字符串 */ 公共函数 getLat(): 字符串 { 返回 $this->lat; } /** * @param 字符串 $lat */ 公共函数 setLat(string $lat): 无效 { $this->lat = $lat; } /** * @return 字符串 */ 公共函数getLng():字符串 { 返回 $this->lng; } /** * @param 字符串 $lng */ 公共函数 setLng(字符串 $lng):无效 { $this->lng = $lng; } /** * @return 字符串 */ 公共函数 getStreet(): 字符串 { 返回 $this->street; } /** * @param 字符串 $street */ 公共函数 setStreet(string $street): 无效 { $this->street = $street; } /** * @return 字符串 */ 公共函数 getZipcode(): 字符串 { 返回 $this-> 邮政编码; } /** * @param 字符串 $zipcode */ 公共函数 setZipcode(string $zipcode): 无效 { $this->zipcode = $zipcode; } /** * @return 字符串 */ 公共函数getCity():字符串 { 返回 $this->city; } /** * @param 字符串 $city */ 公共函数 setCity(string $city): 无效 { $this->city = $city; } /** * @return 字符串 */ 公共函数getDescription():字符串 { 返回 $this-> 描述; } /** * @param 字符串 $description */ 公共函数 setDescription(string $description): 无效 { $this->description = $description; } /** * @var 字符串 * * @ORM\Column(name="lat", type="decimal", precision=10, scale=8, nullable=false) */ 私人 $lat; /** * @var 字符串 * * @ORM\Column(name="lng", type="decimal", precision=10, scale=8, nullable=false) */ 私人 $lng; /** * @var 字符串 * * @ORM\Column(name="street", type="string", length=255, nullable=false) */ 私人$街; /** * @var 字符串 * * @ORM\Column(name="zipcode", type="string", length=5, nullable=false) */ 私人 $zipcode; /** * @var 字符串 * * @ORM\Column(name="city", type="string", length=255, nullable=false) */ 私人$城市; /** * @var 字符串 * * @ORM\Column(name="description", type="text", nullable=false) */ 私人$描述; /** * @var 整数 * * @ORM\Column(name="id", type="integer") * @ORM\ID * @ORM\GeneratedValue(strategy="IDENTITY") */ 私人 $id; } 有一行数据的表: [![在此处输入图像描述][1]][1] [![在此处输入图像描述][2]][2] 我收到了这个错误: >> "类型": "https://www.rfc-editor.org/rfc/rfc2616#section-10", "title": "发生错误", "detail": "类型错误:App\\Entity\\Address::getLat() 的返回值必须是字符串类型,返回 null", [![在此处输入图像描述][3]][3] 我的错在哪里?使用 Symfony 4.0。 [1]:https://i.stack.imgur.com/OQw4b.png [2]:https://i.stack.imgur.com/HrFT3.png [3]:https://i.stack.imgur.com/PCPww.png【问题讨论】: