当前位置: 首页>>代码示例>>PHP>>正文


PHP File::__construct方法代码示例

本文整理汇总了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);
 }
开发者ID:thekabal,项目名称:tki,代码行数:40,代码来源:LocalFile.php

示例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);
 }
开发者ID:thekabal,项目名称:tki,代码行数:31,代码来源:DummyFile.php


注:本文中的PHP_CodeSniffer\Files\File::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。