Passed
Push — master ( ea0ac9...54e0c4 )
by Robbie
01:44
created

src/Check/CodingStandardCheck.php (1 issue)

1
<?php
2
3
namespace SilverStripe\ModuleRatings\Check;
4
5
use SilverStripe\ModuleRatings\Check;
6
use Symfony\Component\Config\Resource\ComposerResource;
0 ignored issues
show
The type Symfony\Component\Config\Resource\ComposerResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class CodingStandardCheck extends Check
9
{
10
    protected $points = 10;
11
12
    /**
13
     * The path to the PHPCS standards file
14
     *
15
     * @var string
16
     */
17
    protected $standardsFile = '';
18
19
    public function __construct()
20
    {
21
        $this->setStandardsFile(realpath(__DIR__) . '/CodingStandardCheck/phpcs.xml.dist');
22
    }
23
24
    public function getKey()
25
    {
26
        return 'coding_standards';
27
    }
28
29
    public function getDescription()
30
    {
31
        return 'The PHP code in this module passes the SilverStripe lint rules (mostly PSR-2)';
32
    }
33
34
    /**
35
     * Get PHP CodeSniffer and run it over the current module. Assigns a successful result if the codebase passes
36
     * the linting check with no errors.
37
     */
38
    public function run()
39
    {
40
        $standard = '--standard=' . escapeshellarg($this->getStandardsFile());
41
        $path = $this->getSuite()->getModuleRoot();
42
43
        $output = null;
44
        exec(
45
            'cd ' . dirname(__FILE__) . '/../../../../../ && vendor/bin/phpcs -q '
46
            . $standard . ' ' . $path,
47
            $ouput,
48
            $exitCode
49
        );
50
        if ($exitCode == 0) {
51
            $this->setSuccessful(true);
52
        }
53
    }
54
55
    public function setStandardsFile($standardsFile)
56
    {
57
        $this->standardsFile = $standardsFile;
58
        return $this;
59
    }
60
61
    public function getStandardsFile()
62
    {
63
        return $this->standardsFile;
64
    }
65
}
66