• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 15253296250

26 May 2025 11:55AM UTC coverage: 78.632% (+0.3%) from 78.375%
15253296250

Pull #1105

github

web-flow
Merge d9441d98f into caf806050
Pull Request #1105: Skip tests when 'git' command is not available

19665 of 25009 relevant lines covered (78.63%)

88.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Files/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/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
 */
14

15
namespace PHP_CodeSniffer\Files;
16

17
use PHP_CodeSniffer\Config;
18
use PHP_CodeSniffer\Ruleset;
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 !== '') {
×
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
        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 $fixableErrorCount   The number of fixable errors found.
68
     * @param int $fixableWarningCount The number of fixable warning found.
69
     * @param int $fixedErrorCount     The number of errors that were fixed.
70
     * @param int $fixedWarningCount   The number of warning that were fixed.
71
     *
72
     * @return void
73
     */
74
    public function setErrorCounts($errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount)
×
75
    {
76
        $this->errorCount          = $errorCount;
×
77
        $this->warningCount        = $warningCount;
×
78
        $this->fixableErrorCount   = $fixableErrorCount;
×
79
        $this->fixableWarningCount = $fixableWarningCount;
×
80
        $this->fixedErrorCount     = $fixedErrorCount;
×
81
        $this->fixedWarningCount   = $fixedWarningCount;
×
82

83
    }//end setErrorCounts()
84

85

86
}//end class
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc