我想知道是否有某种方法可以忽略PHP_CodeSniffer生成的警告,该警告引用了Eloquent映射。
例如:
/**
* @param User $user
* @param string $message
* @param string $type
* @return Comment
* @throws Exception
*/
public function createComment(User $user, $message, $type)
{
$comment = new Comment();
$comment->creator()->associate($user);
$comment->Message = $message; //PHPCS warning: Property accessed via magic method
$comment->AddedDate = new Carbon();
$comment->Type = $type;
$comment->save();
return $comment;
}
P.S:我不想排除与模型无关的警告(将其用于其他课堂提示),并且最好排除每个属性的设置方法和获取方法
如果“ Comment”是您创建的模型,请添加类phpDoc注释以向IDE提示有关可用属性的信息。
/**
* Class Comment
* @property int id
* @property string Message
*/
class Comment extends Model {
这也适合自动完成