public function fixCodeStyle($filePath, array $fixers, $level = null)
{
if (defined('HHVM_VERSION_ID') && HHVM_VERSION_ID < 30500) {
throw new Exception("HHVM needs to be a minimum version of HHVM 3.5.0");
} elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306) {
throw new Exception("PHP needs to be a minimum version of PHP 5.3.6");
}
// @codeCoverageIgnoreEnd
if (!file_exists($filePath)) {
throw new Exception('File "' . $filePath . '" does not exist, cannot fix it');
}
$options = array('--no-interaction' => true, 'command' => 'fix', 'path' => $filePath);
$fix = array();
foreach ($fixers as $fixer) {
if ($this->isAFixer($fixer)) {
$fix[] = $fixer;
}
}
$options['--fixers'] = implode(',', $fix);
if ($this->isALevel($level)) {
$options['--level'] = $level;
}
$input = new ArrayInput($options);
$output = new BufferedOutput();
$application = new \Symfony\CS\Console\Application();
$application->setAutoExit(false);
$application->run($input, $output);
return $output->fetch();
}