function DummyFile::__construct
Creates a DummyFile object and sets the content.
Parameters
string $content The content of the file.:
\PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run.:
\PHP_CodeSniffer\Config $config The config data for the run.:
Return value
void
Overrides File::__construct
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Files/ DummyFile.php, line 33
Class
Namespace
PHP_CodeSniffer\FilesCode
public function __construct($content, Ruleset $ruleset, Config $config) {
$this->setContent($content);
// See if a filename was defined in the content.
// This is done by including: phpcs_input_file: [file path]
// as the first line of content.
$path = 'STDIN';
if ($content !== '') {
if (substr($content, 0, 17) === 'phpcs_input_file:') {
$eolPos = strpos($content, $this->eolChar);
$filename = trim(substr($content, 17, $eolPos - 17));
$content = substr($content, $eolPos + strlen($this->eolChar));
$path = $filename;
$this->setContent($content);
}
}
// The CLI arg overrides anything passed in the content.
if ($config->stdinPath !== null) {
$path = $config->stdinPath;
}
parent::__construct($path, $ruleset, $config);
}