Log output when reports fail to process

This commit is contained in:
Dan Cryer 2014-05-22 11:59:26 +01:00
parent 967e75e568
commit da3dba0939
2 changed files with 8 additions and 4 deletions

View file

@ -157,7 +157,7 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
);
$output = $this->phpci->getLastOutput();
list($errors, $warnings, $data) = $this->processReport(json_decode(trim($output), true));
list($errors, $warnings, $data) = $this->processReport($output);
$this->phpci->logExecOutput(true);
@ -198,9 +198,12 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
return array($ignore, $standard, $suffixes);
}
protected function processReport($data)
protected function processReport($output)
{
$data = json_decode(trim($output), true);
if (!is_array($data)) {
$this->phpci->log($output);
throw new \Exception('Could not process PHPCS report JSON.');
}

View file

@ -124,11 +124,12 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
}
protected function processReport($xml)
protected function processReport($xmlString)
{
$xml = simplexml_load_string($xml);
$xml = simplexml_load_string($xmlString);
if ($xml === false) {
$this->phpci->log($xmlString);
throw new \Exception('Could not process PHPMD report XML.');
}