/** * 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. * @param array $restrictions The sniff codes to restrict the * violations to. * * @return PHP_CodeSniffer_File * @see processFile() */ private function _processFile($file, $contents, $restrictions) { if (PHP_CODESNIFFER_VERBOSITY > 0) { $startTime = time(); echo 'Processing ' . basename($file) . ' '; if (PHP_CODESNIFFER_VERBOSITY > 1) { echo PHP_EOL; } } $phpcsFile = new PHP_CodeSniffer_File($file, $this->_tokenListeners, $this->allowedFileExtensions, $this->ruleset, $restrictions, $this); $phpcsFile->start($contents); $phpcsFile->cleanUp(); if (PHP_CODESNIFFER_VERBOSITY > 0) { $timeTaken = time() - $startTime; if ($timeTaken === 0) { echo 'DONE in < 1 second'; } else { if ($timeTaken === 1) { echo 'DONE in 1 second'; } else { echo "DONE in {$timeTaken} seconds"; } } $errors = $phpcsFile->getErrorCount(); $warnings = $phpcsFile->getWarningCount(); echo " ({$errors} errors, {$warnings} warnings)" . PHP_EOL; } return $phpcsFile; }