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