如何忽略PHP_CodeSniffer警告

问题描述 投票:1回答:1

我想知道是否有某种方法可以忽略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:我不想排除与模型无关的警告(将其用于其他课堂提示),并且最好排除每个属性的设置方法和获取方法

php laravel static-analysis phpcs
1个回答
0
投票

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

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

这也适合自动完成

© www.soinside.com 2019 - 2024. All rights reserved.