Skip to content

Commit 49429f1

Browse files
committed
don't assume numeric line numbers
1 parent a76a39b commit 49429f1

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

CodeSniffer/Reports/Full.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,8 @@ public function generateFileReport(
7777
echo 'AFFECTING '.count($report['messages']).' LINE(S)'.PHP_EOL;
7878
echo str_repeat('-', $width).PHP_EOL;
7979

80-
// Work out the max line number for formatting.
81-
$maxLine = 0;
82-
foreach ($report['messages'] as $line => $lineErrors) {
83-
if ($line > $maxLine) {
84-
$maxLine = $line;
85-
}
86-
}
87-
88-
$maxLineLength = strlen($maxLine);
80+
// Work out the max line number length for formatting.
81+
$maxLineLength = max(array_map('strlen', array_keys($report['messages'])));
8982

9083
// The length of the word ERROR or WARNING; used for padding.
9184
if ($report['warnings'] > 0) {

0 commit comments

Comments
 (0)