Skip to content

Commit 326496c

Browse files
VasekPurchartondrejmirtes
authored andcommitted
Extract getting Neon
1 parent 9cf91e1 commit 326496c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/Command/ErrorFormatter/BaselineNeonErrorFormatter.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPStan\File\RelativePathHelper;
1010
use function ksort;
1111
use function preg_quote;
12+
use function substr;
1213
use const SORT_STRING;
1314

1415
class BaselineNeonErrorFormatter
@@ -24,11 +25,7 @@ public function formatErrors(
2425
): int
2526
{
2627
if (!$analysisResult->hasErrors()) {
27-
$output->writeRaw(Neon::encode([
28-
'parameters' => [
29-
'ignoreErrors' => [],
30-
],
31-
], Neon::BLOCK));
28+
$output->writeRaw($this->getNeon([]));
3229
return 0;
3330
}
3431

@@ -63,13 +60,21 @@ public function formatErrors(
6360
}
6461
}
6562

66-
$output->writeRaw(Neon::encode([
67-
'parameters' => [
68-
'ignoreErrors' => $errorsToOutput,
69-
],
70-
], Neon::BLOCK));
63+
$output->writeRaw($this->getNeon($errorsToOutput));
7164

7265
return 1;
7366
}
7467

68+
/**
69+
* @param array<int, array{message: string, count: int, path: string}> $ignoreErrors
70+
*/
71+
private function getNeon(array $ignoreErrors): string
72+
{
73+
return Neon::encode([
74+
'parameters' => [
75+
'ignoreErrors' => $ignoreErrors,
76+
],
77+
], Neon::BLOCK);
78+
}
79+
7580
}

0 commit comments

Comments
 (0)