我试图保持我的php rest服务器正常文档,所以我想知道我们如何记录返回值可以是2之一?
/**
* send email to a user that contain reset data
* it also create reset token, so if there was an old reset token it will be changed
*
* @param email $email {@type email"
* @return SuccessMessage|FailMessage
*/
public function getSearch($email){
// search for $email, if success return
if($this->doOperation()===true){
return new SuccessMessage($email);
}
return new FailMessage($email);
}
现在说FailMessage和SuccessMessage都只是一个空类来充当一致的数据结构
更像这样的东西。
class FailMessage extends Messages{
function __construct(string $message, int $uid) {
if(is_callable("parent::__construct")){
parent::__construct(...func_get_args());
}
$this->uid = $uid;
$this->message = $data;
}
}
答案 0 :(得分:2)
/**
* send email to a user that contain reset data
* it also create reset token, so if there was an old reset token it will be changed
*
* @param email $email {@type email"
* @return object SuccessMessage|FailMessage
*/
您自己的评论是好的但是您可以添加更多对象类型。另请阅读官方网站上的以下文件: