Skip to content

Commit

Permalink
Support for phpstan 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
cuchac authored Feb 3, 2020
1 parent 2b1af68 commit 2db5acb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/CodeclimateErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ public function formatErrors(AnalysisResult $analysisResult, Output $style): int
{
$errorsArray = [];

$root = rtrim(dirname($analysisResult->getProjectConfigFile()), '/');

foreach ($analysisResult->getFileSpecificErrors() as $fileSpecificError) {
$error = [
'type' => 'issue',
'check_name' => 'PHPStan',
'description' => $fileSpecificError->getMessage(),
'categories' => ['Style'],
'location' => [
'path' => $fileSpecificError->getFile(),
'path' => str_replace(
$root . '/',
'',
$fileSpecificError->getFile()
),
'lines' => [
'begin' => $fileSpecificError->getLine(),
],
Expand Down Expand Up @@ -53,7 +59,7 @@ public function formatErrors(AnalysisResult $analysisResult, Output $style): int
'description' => $notFileSpecificError,
'categories' => ['Style'],
'location' => [
'path' => $analysisResult->getCurrentDirectory() . "/.",
'path' => $root . "/.",
'positions' => [
'offset' => 0,
],
Expand All @@ -67,7 +73,7 @@ public function formatErrors(AnalysisResult $analysisResult, Output $style): int

$json = Json::encode($errorsArray, Json::PRETTY);

$style->write($json);
$style->writeRaw($json);

return $analysisResult->hasErrors() ? 1 : 0;
}
Expand Down

0 comments on commit 2db5acb

Please sign in to comment.