PHP_CodeSniffer_File::__construct PHP Method

__construct() public method

Constructs a PHP_CodeSniffer_File.
public __construct ( string $file, array $listeners, array $ruleset, PHP_CodeSniffer $phpcs )
$file string The absolute path to the file to process.
$listeners array
$ruleset array An array of rules from the ruleset.xml file. ruleset.xml file.
$phpcs PHP_CodeSniffer The PHP_CodeSniffer object controlling this run. this run.
    public function __construct($file, array $listeners, array $ruleset, PHP_CodeSniffer $phpcs)
    {
        $this->_file = trim($file);
        $this->_listeners = $listeners;
        $this->ruleset = $ruleset;
        $this->phpcs = $phpcs;
        $this->fixer = new PHP_CodeSniffer_Fixer();
        if (PHP_CODESNIFFER_INTERACTIVE === false) {
            $cliValues = $phpcs->cli->getCommandLineValues();
            if (isset($cliValues['showSources']) === true && $cliValues['showSources'] !== true) {
                $recordErrors = false;
                foreach ($cliValues['reports'] as $report => $output) {
                    $reportClass = $phpcs->reporting->factory($report);
                    if (property_exists($reportClass, 'recordErrors') === false || $reportClass->recordErrors === true) {
                        $recordErrors = true;
                        break;
                    }
                }
                $this->_recordErrors = $recordErrors;
            }
        }
    }