Skip to content

Commit

Permalink
Fix phpcsfixer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
bruli committed Mar 8, 2016
1 parent e6cd28d commit 0339518
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/PhpGitHooks/Infrastructure/PhpCsFixer/PhpCsFixerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use IgnoreFiles\IgnoreFiles;
use PhpGitHooks\Application\Message\MessageConfigData;
use PhpGitHooks\Command\BadJobLogo;
use PhpGitHooks\Command\OutputHandlerInterface;
use PhpGitHooks\Infrastructure\Common\InteractiveToolInterface;
use PhpGitHooks\Infrastructure\Common\ToolHandler;
Expand Down Expand Up @@ -75,10 +76,11 @@ public function run(array $messages)
}

if ($errors) {
$this->writeOutputError(
new PhpCsFixerException(implode('', $errors)),
$messages[MessageConfigData::KEY_ERROR_MESSAGE]
);
$this->outputHandler->setError($this->getErrors($errors));
$this->output->writeln($this->outputHandler->getError());
$this->output->writeln(BadJobLogo::paint($messages[MessageConfigData::KEY_ERROR_MESSAGE]));

throw new PhpCsFixerException();
}

$this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
Expand Down Expand Up @@ -116,4 +118,20 @@ public function setLevels(array $levels)
{
$this->levels = $levels;
}

/**
* @param array $errors
*
* @return null|string
*/
private function getErrors(array $errors)
{
$errorText = null;

foreach ($errors as $error) {
$errorText .= trim($error)."\n";
}

return $errorText;
}
}

0 comments on commit 0339518

Please sign in to comment.