PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Source for file DummyFile.php

Documentation is available at DummyFile.php

  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($contentRuleset $rulesetConfig $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($content017=== 'phpcs_input_file:'{
  43.                 $eolPos   strpos($content$this->eolChar);
  44.                 $filename trim(substr($content17($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

Documentation generated on Mon, 11 Mar 2019 15:27:24 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.