Skip to content

Commit

Permalink
Merge 7cf68cc into 3abdfb3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerogiven committed Apr 21, 2022
2 parents 3abdfb3 + 7cf68cc commit e3f92c3
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/Check/CodingStandardCheck.php
Expand Up @@ -35,13 +35,39 @@ public function getDescription()
*/
public function run()
{
$arguments = [];
if (file_exists($this->getSuite()->getModuleRoot() . '/phpcs.xml.dist')) {
$includePaths = [];
$ignorePaths = [];
$moduleXml = file_get_contents($this->getSuite()->getModuleRoot() . '/phpcs.xml.dist');

preg_match_all('/<exclude-pattern>(.*)<\/exclude-pattern>/', $moduleXml, $ignorePaths);

if (count($ignorePaths) > 0 && count($ignorePaths[1]) > 0) {
foreach($ignorePaths[1] as $ignorePath) {
$arguments[] = '--ignore="' . $ignorePath . '"';
}
}

preg_match_all('/<file>(.*)<\/file>/', $moduleXml, $includePaths);

if (count($includePaths) > 0 && count($includePaths[1]) > 0) {
foreach($includePaths[1] as $includePath) {
$arguments[] = $this->getSuite()->getModuleRoot() . DIRECTORY_SEPARATOR . $includePath;
}
} else {
$arguments[] = $this->getSuite()->getModuleRoot();
}
} else {
$arguments[] = $this->getSuite()->getModuleRoot();
}

$standard = '--standard=' . escapeshellarg($this->getStandardsFile());
$path = $this->getSuite()->getModuleRoot();

$output = null;
exec(
'cd ' . $this->getProjectRoot() . ' && vendor/bin/phpcs -q '
. $standard . ' ' . $path,
. $standard . ' ' . implode(' ', $arguments),
$output,
$exitCode
);
Expand Down

0 comments on commit e3f92c3

Please sign in to comment.