Chris@4: Chris@4: * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) Chris@4: * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence Chris@4: */ Chris@4: Chris@4: namespace PHP_CodeSniffer\Files; Chris@4: Chris@4: use PHP_CodeSniffer\Ruleset; Chris@4: use PHP_CodeSniffer\Config; Chris@4: Chris@4: class DummyFile extends File Chris@4: { Chris@4: Chris@4: Chris@4: /** Chris@4: * Creates a DummyFile object and sets the content. Chris@4: * Chris@4: * @param string $content The content of the file. Chris@4: * @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run. Chris@4: * @param \PHP_CodeSniffer\Config $config The config data for the run. Chris@4: * Chris@4: * @return void Chris@4: */ Chris@4: public function __construct($content, Ruleset $ruleset, Config $config) Chris@4: { Chris@4: $this->setContent($content); Chris@4: Chris@4: // See if a filename was defined in the content. Chris@4: // This is done by including: phpcs_input_file: [file path] Chris@4: // as the first line of content. Chris@4: $path = 'STDIN'; Chris@4: if ($content !== null) { Chris@4: if (substr($content, 0, 17) === 'phpcs_input_file:') { Chris@4: $eolPos = strpos($content, $this->eolChar); Chris@4: $filename = trim(substr($content, 17, ($eolPos - 17))); Chris@4: $content = substr($content, ($eolPos + strlen($this->eolChar))); Chris@4: $path = $filename; Chris@4: Chris@4: $this->setContent($content); Chris@4: } Chris@4: } Chris@4: Chris@4: // The CLI arg overrides anything passed in the content. Chris@4: if ($config->stdinPath !== null) { Chris@4: $path = $config->stdinPath; Chris@4: } Chris@4: Chris@4: return parent::__construct($path, $ruleset, $config); Chris@4: Chris@4: }//end __construct() Chris@4: Chris@4: Chris@4: /** Chris@4: * Set the error, warning, and fixable counts for the file. Chris@4: * Chris@4: * @param int $errorCount The number of errors found. Chris@4: * @param int $warningCount The number of warnings found. Chris@4: * @param int $fixableCount The number of fixable errors found. Chris@4: * @param int $fixedCount The number of errors that were fixed. Chris@4: * Chris@4: * @return void Chris@4: */ Chris@4: public function setErrorCounts($errorCount, $warningCount, $fixableCount, $fixedCount) Chris@4: { Chris@4: $this->errorCount = $errorCount; Chris@4: $this->warningCount = $warningCount; Chris@4: $this->fixableCount = $fixableCount; Chris@4: $this->fixedCount = $fixedCount; Chris@4: Chris@4: }//end setErrorCounts() Chris@4: Chris@4: Chris@4: }//end class