PHP_CodeSniffer_File::getErrorCount PHP Method

getErrorCount() public method

Returns the number of errors raised.
public getErrorCount ( ) : integer
return integer
    public function getErrorCount()
    {
        return $this->_errorCount;
    }

Usage Example

 /**
  * Process the sniffs for a single file.
  *
  * Does raw processing only. No interactive support or error checking.
  *
  * @param string $file     The file to process.
  * @param string $contents The contents to parse. If NULL, the content
  *                         is taken from the file system.
  *
  * @return PHP_CodeSniffer_File
  * @see    processFile()
  */
 private function _processFile($file, $contents)
 {
     $stdin = false;
     $cliValues = $this->cli->getCommandLineValues();
     if (empty($cliValues['files']) === true) {
         $stdin = true;
     }
     if (PHP_CODESNIFFER_VERBOSITY > 0 || PHP_CODESNIFFER_CBF === true && $stdin === false) {
         $startTime = microtime(true);
         echo 'Processing ' . basename($file) . ' ';
         if (PHP_CODESNIFFER_VERBOSITY > 1) {
             echo PHP_EOL;
         }
     }
     $phpcsFile = new PHP_CodeSniffer_File($file, $this->_tokenListeners, $this->ruleset, $this);
     $phpcsFile->start($contents);
     if (PHP_CODESNIFFER_VERBOSITY > 0 || PHP_CODESNIFFER_CBF === true && $stdin === false) {
         $timeTaken = (microtime(true) - $startTime) * 1000;
         if ($timeTaken < 1000) {
             $timeTaken = round($timeTaken);
             echo "DONE in {$timeTaken}ms";
         } else {
             $timeTaken = round($timeTaken / 1000, 2);
             echo "DONE in {$timeTaken} secs";
         }
         if (PHP_CODESNIFFER_CBF === true) {
             $errors = $phpcsFile->getFixableCount();
             echo " ({$errors} fixable violations)" . PHP_EOL;
         } else {
             $errors = $phpcsFile->getErrorCount();
             $warnings = $phpcsFile->getWarningCount();
             echo " ({$errors} errors, {$warnings} warnings)" . PHP_EOL;
         }
     }
     return $phpcsFile;
 }
All Usage Examples Of PHP_CodeSniffer_File::getErrorCount