如何忽略 PHP_CodeSniffer 警告

How to ignore PHP_CodeSniffer warnings

我想知道是否有某种方法可以忽略 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:我不想排除与模型无关的警告(将它们保留在其他 class 提示中),最好排除 setter 和 getter每个论坛 属性

如果 "Comment" 是您创建的模型,请添加 class phpDoc 注释以提示 IDE 有关可用属性的信息。

/**
 * Class Comment
 * @property int id
 * @property string Message
 */
class Comment extends Model {

这也适用于自动完成