Skip to content
Snippets Groups Projects

Support custom phpstan rules

@@ -83,16 +83,20 @@ class Phpstan extends BuildTaskBase implements BuildStepInterface, BuildTaskInte
return 0;
}
$this->addPhpstanNeon();
// Run phpstan.
$source_dir = $this->environment->getExecContainerSourceDir();
$project_dir = $this->codebase->getProjectConfigDirectory(FALSE);
$work_dir = $this->environment->getContainerWorkDir();
$this->io->writeln('<info>Running PHPStan at ' . $source_dir);
// If phpstan file is missing, provide some basic deprecation checks.
if (!file_exists($work_dir . '/phpstan.neon') || !file_exists($work_dir . '/phpstan.neon.dist')) {
$this->addPhpstanNeon();
$neon = '-c ' . $work_dir . '/' . $this->pluginDir . '/phpstan.neon';
}
$result = $this->execEnvironmentCommands([
'cd ' . $project_dir . ' && sudo -u www-data ' . $source_dir . static::$phpstanExecutable . ' analyse --error-format checkstyle -c ' . $work_dir . '/' . $this->pluginDir . '/phpstan.neon . > ' . $work_dir . '/' . $this->pluginDir . '/phpstan_results.xml',
'cd ' . $project_dir . ' && sudo -u www-data ' . $source_dir . static::$phpstanExecutable . ' analyse --error-format checkstyle ' . $neon . ' > ' . $work_dir . '/' . $this->pluginDir . '/phpstan_results.xml',
]);
// Save phpstan results for later examination.
Loading