本文整理汇总了PHP中PHP_CodeSniffer\Files\File::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP File::__construct方法的具体用法?PHP File::__construct怎么用?PHP File::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeSniffer\Files\File
的用法示例。
在下文中一共展示了File::__construct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a LocalFile object and sets the content.
*
* @param string $path The absolute path to the file.
* @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run.
* @param \PHP_CodeSniffer\Config $config The config data for the run.
*
* @return void
*/
public function __construct($path, Ruleset $ruleset, Config $config)
{
$path = trim($path);
if (is_readable($path) === false) {
parent::__construct($path, $ruleset, $config);
$error = 'Error opening file; file no longer exists or you do not have access to read the file';
$this->addMessage(true, $error, 1, 1, 'Internal.LocalFile', array(), 5, false);
$this->ignored = true;
return;
}
// Before we go and spend time tokenizing this file, just check
// to see if there is a tag up top to indicate that the whole
// file should be ignored. It must be on one of the first two lines.
$handle = fopen($path, 'r');
if ($handle !== false) {
$firstContent = fgets($handle);
$firstContent .= fgets($handle);
fclose($handle);
if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) {
// We are ignoring the whole file.
if (PHP_CODESNIFFER_VERBOSITY > 0) {
echo 'Ignoring ' . basename($path) . PHP_EOL;
}
$this->ignored = true;
return;
}
}
$this->path = $path;
$this->reloadContent();
return parent::__construct($path, $ruleset, $config);
}
示例2: __construct
/**
* Creates a DummyFile object and sets the content.
*
* @param string $content The content of the file.
* @param \PHP_CodeSniffer\Ruleset $ruleset The ruleset used for the run.
* @param \PHP_CodeSniffer\Config $config The config data for the run.
*
* @return void
*/
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 !== null) {
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;
}
return parent::__construct($path, $ruleset, $config);
}