[英]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;
}
PS:我不想排除這些與模型無關的警告(將它們保留用於其他類提示),並且最好排除每個屬性的 setter 和 getter
如果“注釋”是您創建的模型,請添加類 phpDoc 注釋以提示 IDE 有關可用屬性的信息。
/**
* Class Comment
* @property int id
* @property string Message
*/
class Comment extends Model {
這也有利於自動完成
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.