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

PHPCSStandards / PHP_CodeSniffer / 12278947850

11 Dec 2024 02:55PM UTC coverage: 78.121%. Remained the same
12278947850

Pull #758

github

web-flow
Merge 224a57f7c into 799e2935b
Pull Request #758: Publish release checklist and automate release verification

24395 of 31227 relevant lines covered (78.12%)

65.22 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 $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
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