Skip to content

Commit 0339518

Browse files
committed
Fix phpcsfixer exception
1 parent e6cd28d commit 0339518

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/PhpGitHooks/Infrastructure/PhpCsFixer/PhpCsFixerHandler.php

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use IgnoreFiles\IgnoreFiles;
66
use PhpGitHooks\Application\Message\MessageConfigData;
7+
use PhpGitHooks\Command\BadJobLogo;
78
use PhpGitHooks\Command\OutputHandlerInterface;
89
use PhpGitHooks\Infrastructure\Common\InteractiveToolInterface;
910
use PhpGitHooks\Infrastructure\Common\ToolHandler;
@@ -75,10 +76,11 @@ public function run(array $messages)
7576
}
7677

7778
if ($errors) {
78-
$this->writeOutputError(
79-
new PhpCsFixerException(implode('', $errors)),
80-
$messages[MessageConfigData::KEY_ERROR_MESSAGE]
81-
);
79+
$this->outputHandler->setError($this->getErrors($errors));
80+
$this->output->writeln($this->outputHandler->getError());
81+
$this->output->writeln(BadJobLogo::paint($messages[MessageConfigData::KEY_ERROR_MESSAGE]));
82+
83+
throw new PhpCsFixerException();
8284
}
8385

8486
$this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
@@ -116,4 +118,20 @@ public function setLevels(array $levels)
116118
{
117119
$this->levels = $levels;
118120
}
121+
122+
/**
123+
* @param array $errors
124+
*
125+
* @return null|string
126+
*/
127+
private function getErrors(array $errors)
128+
{
129+
$errorText = null;
130+
131+
foreach ($errors as $error) {
132+
$errorText .= trim($error)."\n";
133+
}
134+
135+
return $errorText;
136+
}
119137
}

0 commit comments

Comments
 (0)