• 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/Reports/Svnblame.php
1
<?php
2
/**
3
 * SVN blame report for PHP_CodeSniffer.
4
 *
5
 * @author    Greg Sherwood <gsherwood@squiz.net>
6
 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
 * @license   https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
 */
9

10
namespace PHP_CodeSniffer\Reports;
11

12
use PHP_CodeSniffer\Exceptions\DeepExitException;
13
use PHP_CodeSniffer\Util\ExitCode;
14

15
class Svnblame extends VersionControl
16
{
17

18
    /**
19
     * The name of the report we want in the output
20
     *
21
     * @var string
22
     */
23
    protected $reportName = 'SVN';
24

25

26
    /**
27
     * Extract the author from a blame line.
28
     *
29
     * @param string $line Line to parse.
30
     *
31
     * @return mixed string or false if impossible to recover.
32
     */
33
    protected function getAuthor($line)
×
34
    {
35
        $blameParts = [];
×
36
        preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts);
×
37

38
        if (isset($blameParts[2]) === false) {
×
39
            return false;
×
40
        }
41

42
        return $blameParts[2];
×
43

44
    }//end getAuthor()
45

46

47
    /**
48
     * Gets the blame output.
49
     *
50
     * @param string $filename File to blame.
51
     *
52
     * @return array
53
     * @throws \PHP_CodeSniffer\Exceptions\DeepExitException
54
     */
55
    protected function getBlameContent($filename)
×
56
    {
57
        $command = 'svn blame "'.$filename.'" 2>&1';
×
58
        $handle  = popen($command, 'r');
×
59
        if ($handle === false) {
×
60
            $error = 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
×
61
            throw new DeepExitException($error, ExitCode::PROCESS_ERROR);
×
62
        }
63

64
        $rawContent = stream_get_contents($handle);
×
65
        pclose($handle);
×
66

67
        $blames = explode("\n", $rawContent);
×
68

69
        return $blames;
×
70

71
    }//end getBlameContent()
72

73

74
}//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