简体   繁体   中英

How to ignore PHP_CodeSniffer warnings

I was wondering if there is some way to ignore warning generated by PHP_CodeSniffer which refer to Eloquent mappings.

For example:

/**
 * @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: I wouldn't want to exclude this warnings that are not related to Models (keep them for other class tipes), and preferably exclude setters and getters fora each property

If "Comment" is a Model you have created, add class phpDoc comments to hint the IDE about the properties available.

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

This is good for auto-complete as well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM