i'm trying to keep my php rest server properly documents, so i was wondering how do we document that the return value can be one of 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);
}
nowing that both FailMessage and SuccessMessage are just empty classes to act as a consistent data structure
something more like this.
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;
}
}