<?php
namespace XYZ\Model;
interface user{
public function getName() : string;
}
?>
现在发生的情况是,该字符串被假定为类型
XYZ\Model\string
,因此,我制作的任何实现接口的类都不匹配(在不同的命名空间中)。如果我使用
\string
,那么代码将失败,并显示 Scalar type declaration must be unqualified
。此外,布尔类型可以有多少种?删除一些提示后,我得到了下面的结果:
Return value of xxxxx::save() must be an instance of boolean, boolean returned in xxxxxx.php:41
。
string
类型声明更改为boolean
。这样对其他用户会更有帮助。 - bodo