$file = $phpcsFile->getFilename(); if (strpos(file_get_contents($file), 'eval(') !== false) { $phpcsFile->addError('Use of eval() is not allowed', 0, 'EvalUsed'); }
$line = 5; $column = 10; $message = 'This is an error message'; $phpcsFile->addError($message, $line, $column, 'CustomErrorCode');In both examples, the addError method is used to report an error message. The first example reports an error if a particular string is found in the PHP file, while the second example adds an error message with a specific line and column number. Based on the use of PHP_CodeSniffer_File, it can be determined that this code is part of the PHP_CodeSniffer package library.