Skip to content

Commit 536d2f1

Browse files
committed
Fix tip
1 parent d51b7ad commit 536d2f1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Command/ErrorFormatter/TableErrorFormatter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,15 @@ public function formatErrors(
7777
$fileErrors[$fileSpecificError->getFile()][] = $fileSpecificError;
7878
}
7979

80+
$fixableErrorsCount = 0;
8081
foreach ($fileErrors as $file => $errors) {
8182
$rows = [];
8283
foreach ($errors as $error) {
8384
$message = $error->getMessage();
85+
if ($error->getFixedErrorDiff() !== null) {
86+
$message .= ' 🔧';
87+
$fixableErrorsCount++;
88+
}
8489
$filePath = $error->getTraitFilePath() ?? $error->getFilePath();
8590
if ($error->getIdentifier() !== null && $error->canBeIgnored()) {
8691
$message .= "\n";
@@ -157,6 +162,11 @@ public function formatErrors(
157162
$style->warning($finalMessage);
158163
}
159164

165+
if ($fixableErrorsCount > 0) {
166+
$output->writeLineFormatted(sprintf('🔧 %d %s can be fixed automatically. Run PHPStan again with <fg=cyan>--fix</>.', $fixableErrorsCount, $fixableErrorsCount === 1 ? 'error' : 'errors'));
167+
$output->writeLineFormatted('');
168+
}
169+
160170
return $analysisResult->getTotalErrorsCount() > 0 ? 1 : 0;
161171
}
162172

0 commit comments

Comments
 (0)