Mercurial > hg > isophonics-drupal-site
comparison vendor/squizlabs/php_codesniffer/src/Files/DummyFile.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 /** | |
3 * A dummy file represents a chunk of text that does not have a file system location. | |
4 * | |
5 * Dummy files can also represent a changed (but not saved) version of a file | |
6 * and so can have a file path either set manually, or set by putting | |
7 * phpcs_input_file: /path/to/file | |
8 * as the first line of the file contents. | |
9 * | |
10 * @author Greg Sherwood <gsherwood@squiz.net> | |
11 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) | |
12 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence | |
13 */ | |
14 | |
15 namespace PHP_CodeSniffer\Files; | |
16 | |
17 use PHP_CodeSniffer\Ruleset; | |
18 use PHP_CodeSniffer\Config; | |
19 | |
20 class DummyFile extends File | |
21 { | |
22 | |
23 | |
24 /** | |
25 * Creates a DummyFile object and sets the content. | |
26 * | |
27 * @param string $content The content of the file. | |
28 * @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run. | |
29 * @param \PHP_CodeSniffer\Config $config The config data for the run. | |
30 * | |
31 * @return void | |
32 */ | |
33 public function __construct($content, Ruleset $ruleset, Config $config) | |
34 { | |
35 $this->setContent($content); | |
36 | |
37 // See if a filename was defined in the content. | |
38 // This is done by including: phpcs_input_file: [file path] | |
39 // as the first line of content. | |
40 $path = 'STDIN'; | |
41 if ($content !== null) { | |
42 if (substr($content, 0, 17) === 'phpcs_input_file:') { | |
43 $eolPos = strpos($content, $this->eolChar); | |
44 $filename = trim(substr($content, 17, ($eolPos - 17))); | |
45 $content = substr($content, ($eolPos + strlen($this->eolChar))); | |
46 $path = $filename; | |
47 | |
48 $this->setContent($content); | |
49 } | |
50 } | |
51 | |
52 // The CLI arg overrides anything passed in the content. | |
53 if ($config->stdinPath !== null) { | |
54 $path = $config->stdinPath; | |
55 } | |
56 | |
57 return parent::__construct($path, $ruleset, $config); | |
58 | |
59 }//end __construct() | |
60 | |
61 | |
62 /** | |
63 * Set the error, warning, and fixable counts for the file. | |
64 * | |
65 * @param int $errorCount The number of errors found. | |
66 * @param int $warningCount The number of warnings found. | |
67 * @param int $fixableCount The number of fixable errors found. | |
68 * @param int $fixedCount The number of errors that were fixed. | |
69 * | |
70 * @return void | |
71 */ | |
72 public function setErrorCounts($errorCount, $warningCount, $fixableCount, $fixedCount) | |
73 { | |
74 $this->errorCount = $errorCount; | |
75 $this->warningCount = $warningCount; | |
76 $this->fixableCount = $fixableCount; | |
77 $this->fixedCount = $fixedCount; | |
78 | |
79 }//end setErrorCounts() | |
80 | |
81 | |
82 }//end class |